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

Re: [PATCH 0/5] Builtin "git remote"

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 2, 2008, 15:15 UTC
Message-ID
<alpine.LSU.1.00.0803021511420.22527@racer.site>
In-Reply-To
<alpine.LSU.1.00.0802291118540.22527@racer.site>
[PATCH] format-patch: use the diff options for the cover letter, too

Earlier, when you called "git format-patch --cover-letter -M", the diffstat in the cover letter would not inherit the "-M". Now it does.

While at it, add a few "|| break" statements in the test's loops; otherwise, breakages inside the loops would not be caught.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Fri, 29 Feb 2008, Johannes Schindelin wrote:
	> On Thu, 28 Feb 2008, Daniel Barkalow wrote:
	> 
	> > On Thu, 28 Feb 2008, Junio C Hamano wrote:
	> > 
	> > > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
	> > > 
	> > > > It also demonstrates that format-patch --cover-letter 
	> > > > should default to -M for the diffstat (search for 
	> > > > "git-remote.perl"...).
	> > > 
	> > > It probably should inherit the settings for the primary 
	> > > part. You did generate the series with -M, especially [PATCH 
	> > > 4/5], didn't you?
	> > 
	> > Obviously not the output_format, but everything else, I 
	> > assume? Easy enough to pass the main diff options into 
	> > make_cover_letter() and use them to initialize the diff 
	> > options there.
	Voila.
	I thought that the changes in the for loops do not merit an own
	patch, but if you think otherwise, let me know, and I'll resend.
 builtin-log.c           |    2 +-
 t/t4014-format-patch.sh |   18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index bbadbc0..17e491b 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -694,7 +694,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	if (!origin)
 		return;
 
-	diff_setup(&opts);
+	memcpy(&opts, &rev->diffopt, sizeof(opts));
 	opts.output_format |= DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
 
 	diff_setup_done(&opts);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 16aa99d..6d86b7d 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -147,7 +147,7 @@ test_expect_success 'thread' '
 	for i in patches/0002-* patches/0003-*
 	do
 	  grep "References: $FIRST_MID" $i &&
-	  grep "In-Reply-To: $FIRST_MID" $i
+	  grep "In-Reply-To: $FIRST_MID" $i || break
 	done
 '
 
@@ -160,7 +160,7 @@ test_expect_success 'thread in-reply-to' '
 	for i in patches/*
 	do
 	  grep "References: $FIRST_MID" $i &&
-	  grep "In-Reply-To: $FIRST_MID" $i
+	  grep "In-Reply-To: $FIRST_MID" $i || break
 	done
 '
 
@@ -173,7 +173,7 @@ test_expect_success 'thread cover-letter' '
 	for i in patches/0001-* patches/0002-* patches/0003-* 
 	do
 	  grep "References: $FIRST_MID" $i &&
-	  grep "In-Reply-To: $FIRST_MID" $i
+	  grep "In-Reply-To: $FIRST_MID" $i || break
 	done
 '
 
@@ -186,7 +186,7 @@ test_expect_success 'thread cover-letter in-reply-to' '
 	for i in patches/*
 	do
 	  grep "References: $FIRST_MID" $i &&
-	  grep "In-Reply-To: $FIRST_MID" $i
+	  grep "In-Reply-To: $FIRST_MID" $i || break
 	done
 '
 
@@ -201,4 +201,14 @@ test_expect_success 'excessive subject' '
 	ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch
 '
 
+test_expect_success 'cover-letter inherits diff options' '
+
+	git mv file foo &&
+	git commit -m foo &&
+	git format-patch --cover-letter -1 &&
+	! grep "file => foo .* 0 *$" 0000-cover-letter.patch &&
+	git format-patch --cover-letter -1 -M &&
+	grep "file => foo .* 0 *$" 0000-cover-letter.patch
+
+'
 test_done
-- 
1.5.4.3.510.g7cdd
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 23 of 29 in “Builtin "git remote"”
  1. 0/5 Builtin "git remote"Johannes Schindelin, Feb 29, 2008
  2. 1/5 path-list: add functions to work with unsorted listsJohannes Schindelin, Feb 29, 2008
  3. Junio C HamanoFeb 29, 2008
  4. Johannes SchindelinFeb 29, 2008
  5. 0/6 Builtin remote, v2Johannes Schindelin, Mar 1, 2008
  6. 1/6 Rename path_list to string_listJohannes Schindelin, Mar 1, 2008
  7. David KågedalMar 11, 2008
  8. Johannes SchindelinMar 11, 2008
  9. David KågedalMar 11, 2008
  10. 2/6 string-list: add functions to work with unsorted listsJohannes Schindelin, Mar 1, 2008
  11. 3/6 parseopt: add flag to stop on first non optionJohannes Schindelin, Mar 1, 2008
  12. 4/6 Test "git remote show" and "git remote prune"Johannes Schindelin, Mar 1, 2008
  13. 5/6 Make git-remote a builtinJohannes Schindelin, Mar 1, 2008
  14. 6/6 builtin-remote: prune remotes correctly that were added with --mirrorJohannes Schindelin, Mar 1, 2008
  15. 2/5 parseopt: add flag to stop on first non optionJohannes Schindelin, Feb 29, 2008
  16. 3/5 Test "git remote show" and "git remote prune"Johannes Schindelin, Feb 29, 2008
  17. 4/5 Make git-remote a builtinJohannes Schindelin, Feb 29, 2008
  18. 5/5 builtin-remote: prune remotes correctly that were added with --mirrorJohannes Schindelin, Feb 29, 2008
  19. Junio C HamanoFeb 29, 2008
  20. Johannes SchindelinFeb 29, 2008
  21. Daniel BarkalowFeb 29, 2008
  22. Johannes SchindelinFeb 29, 2008
  23. Johannes SchindelinMar 2, 2008
  24. Johannes SchindelinMar 2, 2008
  25. 0/2 format-patch --cover-letter improvementsJohannes Schindelin, Mar 2, 2008
  26. 1/2 format-patch: use the diff options for the cover letter, tooJohannes Schindelin, Mar 2, 2008
  27. 2/2 format-patch: wrap cover-letter's shortlog sensiblyJohannes Schindelin, Mar 2, 2008
  28. Junio C HamanoMar 2, 2008
  29. Johannes SchindelinMar 2, 2008

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.