Merge branch 'fc/maint-format-patch-pathspec-dashes' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 Dec 2009 21:54:25 +0000 (13:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Dec 2009 21:54:25 +0000 (13:54 -0800)
* fc/maint-format-patch-pathspec-dashes:
format-patch: add test for parsing of "--"
format-patch: fix parsing of "--" on the command line

1  2 
builtin-log.c
t/t4014-format-patch.sh
diff --combined builtin-log.c
index 7b91c914236a8e196190663fdbc3be4581539791,cac98afddbde735a75828c1354100308a0972e18..0cf978e0942a896606db9e4c17c9b9f0f3417daa
@@@ -891,7 -891,6 +891,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",
                            PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback },
                OPT_BOOLEAN(0, "no-binary", &no_binary_diff,
                            "don't output binary diffs"),
 +              OPT_BOOLEAN('p', NULL, &use_patch_format,
 +                      "show patch format instead of default (patch + stat)"),
                OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
                            "don't include a patch matching a commit upstream"),
                OPT_GROUP("Messaging"),
         */
        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)
 +      if (use_patch_format)
 +              rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
 +      else 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 (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
diff --combined t/t4014-format-patch.sh
index cab6ce2e97b2439730915c12b5b141e634e759c5,437807e41ecf3fbde2b1b717960b4a384bc66bab..74e5b63bbf7895f383323917c614679afd2d29b1
@@@ -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,4 -515,9 +536,9 @@@ test_expect_success 'format-patch --sig
        grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
  '
  
+ test_expect_success 'format-patch -- <path>' '
+       git format-patch master..side -- file 2>error &&
+       ! grep "Use .--" error
+ '
  test_done