Merge branch 'fc/maint-format-patch-pathspec-dashes'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:46:09 +0000 (14:46 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:46:09 +0000 (14:46 -0800)
Conflicts:
t/t4014-format-patch.sh

1  2 
builtin-log.c
t/t4014-format-patch.sh
diff --combined builtin-log.c
index 33fa6ea6c855df904cfcf30f0b413cb8bca61fa9,cac98afddbde735a75828c1354100308a0972e18..1766349550f5b4204e77f6f6eeca486cee322ca1
@@@ -50,12 -50,6 +50,12 @@@ static void cmd_log_init(int argc, cons
        if (default_date_mode)
                rev->date_mode = parse_date_format(default_date_mode);
  
 +      /*
 +       * Check for -h before setup_revisions(), or "git log -h" will
 +       * fail when run without a git directory.
 +       */
 +      if (argc == 2 && !strcmp(argv[1], "-h"))
 +              usage(builtin_log_usage);
        argc = setup_revisions(argc, argv, rev, "HEAD");
  
        if (rev->diffopt.pickaxe || rev->diffopt.filter)
@@@ -897,7 -891,6 +897,7 @@@ int cmd_format_patch(int argc, const ch
        struct patch_ids ids;
        char *add_signoff = NULL;
        struct strbuf buf = STRBUF_INIT;
 +      int use_patch_format = 0;
        const struct option builtin_format_patch_options[] = {
                { OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
                            "use [PATCH n/m] even with a single patch",
                            "don't output binary diffs"),
                OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
                            "don't include a patch matching a commit upstream"),
 +              { OPTION_BOOLEAN, 'p', "no-stat", &use_patch_format, NULL,
 +                "show patch format instead of default (patch + stat)",
 +                PARSE_OPT_NONEG | PARSE_OPT_NOARG },
                OPT_GROUP("Messaging"),
                { OPTION_CALLBACK, 0, "add-header", NULL, "header",
                            "add email header", PARSE_OPT_NONEG,
         */
        argc = parse_options(argc, argv, prefix, builtin_format_patch_options,
                             builtin_format_patch_usage,
-                            PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN);
+                            PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
+                            PARSE_OPT_KEEP_DASHDASH);
  
        if (do_signoff) {
                const char *committer;
        if (argc > 1)
                die ("unrecognized argument: %s", argv[1]);
  
 -      if (!rev.diffopt.output_format
 -              || rev.diffopt.output_format == DIFF_FORMAT_PATCH)
 -              rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
 +      if (rev.diffopt.output_format & DIFF_FORMAT_NAME)
 +              die("--name-only does not make sense");
 +      if (rev.diffopt.output_format & DIFF_FORMAT_NAME_STATUS)
 +              die("--name-status does not make sense");
 +      if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)
 +              die("--check does not make sense");
 +
 +      if (!use_patch_format &&
 +              (!rev.diffopt.output_format ||
 +               rev.diffopt.output_format == DIFF_FORMAT_PATCH))
 +              rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY;
 +
 +      /* Always generate a patch */
 +      rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
  
        if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
                DIFF_OPT_SET(&rev.diffopt, BINARY);
@@@ -1258,9 -1238,6 +1259,9 @@@ int cmd_cherry(int argc, const char **a
                argv++;
        }
  
 +      if (argc > 1 && !strcmp(argv[1], "-h"))
 +              usage(cherry_usage);
 +
        switch (argc) {
        case 4:
                limit = argv[3];
  
                if (verbose) {
                        struct strbuf buf = STRBUF_INIT;
 +                      struct pretty_print_context ctx = {0};
                        pretty_print_commit(CMIT_FMT_ONELINE, commit,
 -                                          &buf, 0, NULL, NULL, 0, 0);
 +                                          &buf, &ctx);
                        printf("%c %s %s\n", sign,
                               sha1_to_hex(commit->object.sha1), buf.buf);
                        strbuf_release(&buf);
diff --combined t/t4014-format-patch.sh
index 7f267f9ed1d888eeb4b3c780a048c7d09e29db3b,437807e41ecf3fbde2b1b717960b4a384bc66bab..3bc1cccf8869aef26e175e207dc2923d3ddb1e65
@@@ -455,27 -455,6 +455,27 @@@ test_expect_success 'format-patch respe
  
  '
  
 +cat > expect << EOF
 +
 +diff --git a/file b/file
 +index 40f36c6..2dc5c23 100644
 +--- a/file
 ++++ b/file
 +@@ -14,3 +14,19 @@ C
 + D
 + E
 + F
 ++5
 +EOF
 +
 +test_expect_success 'format-patch -p suppresses stat' '
 +
 +      git format-patch -p -2 &&
 +      sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
 +      test_cmp expect output
 +
 +'
 +
  test_expect_success 'format-patch from a subdirectory (1)' '
        filename=$(
                rm -rf sub &&
@@@ -536,20 -515,9 +536,25 @@@ test_expect_success 'format-patch --sig
        grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
  '
  
 +echo "fatal: --name-only does not make sense" > expect.name-only
 +echo "fatal: --name-status does not make sense" > expect.name-status
 +echo "fatal: --check does not make sense" > expect.check
 +
 +test_expect_success 'options no longer allowed for format-patch' '
 +      test_must_fail git format-patch --name-only 2> output &&
 +      test_cmp expect.name-only output &&
 +      test_must_fail git format-patch --name-status 2> output &&
 +      test_cmp expect.name-status output &&
 +      test_must_fail git format-patch --check 2> output &&
 +      test_cmp expect.check output'
 +
 +test_expect_success 'format-patch --numstat should produce a patch' '
 +      git format-patch --numstat --stdout master..side > output &&
 +      test 6 = $(grep "^diff --git a/" output | wc -l)'
 +
+ test_expect_success 'format-patch -- <path>' '
+       git format-patch master..side -- file 2>error &&
+       ! grep "Use .--" error
+ '
  test_done