git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH bg/format-patch-p-noop] log-tree: always add --- marker when options are patch and a stat

From
Stephen Boyd <bebarino@gmail.com>
Date
Nov 3, 2009, 21:24 UTC
Message-ID
<1257283456-7007-1-git-send-email-bebarino@gmail.com>

Previously, the three dash marker (---) would only be added if the diff output format was a patch and diffstat (usually -p and --stat). Now that patches are always generated by format-patch regardless of the stat format being used (--stat, --raw, --numstat, etc.), always add the three dash marker when a patch is being generated and a stat option is used.

This allows users to choose the stat format they want and unifies the format of patches with stats. It also make patches easier to apply when generated by format-patch with non-standard stat options as the stat is no longer considered part of the commit message.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

It seems that after looking at this series it would be better if the marker is always displayed even when a user has used a non-standard stat option with format-patch.

I'm not sure this is wanted though and I guess this could break people's scripts. Are people actually using --numstat or --raw to put the stat into the commit message?

 log-tree.c                                         |    5 +++--
 ...f-tree_--pretty_--root_--patch-with-raw_initial |    2 +-
 t/t4013/diff.show_--patch-with-raw_side            |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 1618f3c..1871c6c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -461,8 +461,9 @@ int log_tree_diff_flush(struct rev_info *opt)
 		if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
 		    opt->verbose_header &&
 		    opt->commit_format != CMIT_FMT_ONELINE) {
-			int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
-			if ((pch & opt->diffopt.output_format) == pch)
+			int pch = DIFF_FORMAT_PATCH;
+			int fmt = opt->diffopt.output_format;
+			if (pch & fmt && pch ^ fmt)
 				printf("---");
 			putchar('\n');
 		}
diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial
index a3203bd..2f4fec9 100644
--- a/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial
+++ b/t/t4013/diff.diff-tree_--pretty_--root_--patch-with-raw_initial
@@ -4,7 +4,7 @@ Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:00:00 2006 +0000
 
     Initial
-
+---
 :000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A	dir/sub
 :000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A	file0
 :000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A	file2
diff --git a/t/t4013/diff.show_--patch-with-raw_side b/t/t4013/diff.show_--patch-with-raw_side
index 221b46a..b7566be 100644
--- a/t/t4013/diff.show_--patch-with-raw_side
+++ b/t/t4013/diff.show_--patch-with-raw_side
@@ -4,7 +4,7 @@ Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:03:00 2006 +0000
 
     Side
-
+---
 :100644 100644 35d242b... 7289e35... M	dir/sub
 :100644 100644 01e79c3... f4615da... M	file0
 :000000 100644 0000000... 7289e35... A	file3
-- 
1.6.5.2.181.gd6f41
Next: Junio C Hamano
Message 1 of 12 in “log-tree: always add --- marker when options are patch and a stat”
  1. log-tree: always add --- marker when options are patch and a statStephen Boyd, Nov 3, 2009
  2. Junio C HamanoNov 4, 2009
  3. Jeff KingNov 4, 2009
  4. Jeff KingNov 4, 2009
  5. Jeff KingNov 4, 2009
  6. Stephen BoydNov 4, 2009
  7. Jeff KingNov 4, 2009
  8. Junio C HamanoNov 4, 2009
  9. Björn GustavssonNov 4, 2009
  10. Junio C HamanoNov 4, 2009
  11. Björn GustavssonNov 4, 2009
  12. Junio C HamanoNov 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.