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

Re: [PATCH 1/2] Fix "git diff" setup code

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2007, 18:19 UTC
Message-ID
<7v4phxaz3o.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.0.999.0709141014130.16478@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 5 quoted lines
> For some inexplicable reason, "git diff" would call "diff_setup_done()" 
> iff we hadn't given an explicit output format.
>
> That makes no sense, since much of what diff_setup_done() does is exactly 
> about checking the output format!

We did not even have _any_ setup_done() call in "git diff" itself in the original, because setup_revisions() has its own call to setup_done(), and it always called setup_revisions() before you reached that part of the code you have in your patch. Commit 047fbe906b375e8a3a7564ad0e4443f62dd528a2 ("builtin-diff: turn recursive on when defaulting to --patch format.") added the call to setup_done() only when we are defaulting to output format, to re-validate the consistency of output format options.

The screw-up was commit fcfa33ec905fcde1c16e7cbbe00d7147b89f1f01 (diff: make more cases implicit --no-index) that made the call to setup_revisions() conditional if setup_diff_no_index() decides to take over, but it forgot that setup_diff_no_index() does not call setup_done().

So I tend to think the attached is a better fix.
---
 diff-lib.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index f5568c3..da55713 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -298,6 +298,8 @@ int setup_diff_no_index(struct rev_info *revs,
 	revs->diffopt.nr_paths = 2;
 	revs->diffopt.no_index = 1;
 	revs->max_count = -2;
+	if (diff_setup_done(&revs->diffopt) < 0)
+		die("diff_setup_done failed");
 	return 0;
 }
 
Previous: Linus TorvaldsNext: Linus Torvalds
Message 9 of 13 in “git-commit: Disallow unchanged tree in non-merge mode”
  1. 1/2 git-commit: Disallow unchanged tree in non-merge modeDmitry V. Levin, Sep 5, 2007
  2. Shawn O. PearceSep 6, 2007
  3. Dmitry V. LevinSep 6, 2007
  4. Linus TorvaldsSep 14, 2007
  5. 1/2 Fix "git diff" setup codeLinus Torvalds, Sep 14, 2007
  6. 2/2 Fix the rename detection limit checkingLinus Torvalds, Sep 14, 2007
  7. Linus TorvaldsSep 14, 2007
  8. Linus TorvaldsSep 14, 2007
  9. Junio C HamanoSep 14, 2007
  10. Linus TorvaldsSep 14, 2007
  11. Junio C HamanoSep 14, 2007
  12. Linus TorvaldsSep 14, 2007
  13. Junio C HamanoSep 14, 2007

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.