Skip to content

Commit

Permalink
Merge branch 'jk/maint-format-patch-p-suppress-stat' into maint
Browse files Browse the repository at this point in the history
* jk/maint-format-patch-p-suppress-stat:
  format-patch: make "-p" suppress diffstat
  • Loading branch information
Junio C Hamano committed Nov 16, 2009
2 parents 3ad1243 + 1d46f2e commit 1f9d282
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
9 changes: 7 additions & 2 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
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",
Expand Down Expand Up @@ -920,6 +921,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
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"),
Expand Down Expand Up @@ -1027,8 +1030,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
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)
Expand Down
21 changes: 21 additions & 0 deletions t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,27 @@ test_expect_success 'format-patch respects -U' '
'

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 &&
Expand Down

0 comments on commit 1f9d282

Please sign in to comment.