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

Re: [PATCH] Documentation/git-diff: remove -r from --name-status example

From
Jeff King <peff@peff.net>
Date
Jul 29, 2007, 12:19 UTC
Message-ID
<20070729121948.GA21983@coredump.intra.peff.net>
In-Reply-To
<Pine.LNX.4.64.0707291258410.14781@racer.site>
On Sun, Jul 29, 2007 at 01:04:13PM +0100, Johannes Schindelin wrote:
Show 8 quoted lines
> The idea is this: when "--quiet" was given, we do not output anything, and 
> therefore do not have to recurse into the directories, because we already 
> know that there are differences when a _tree_ is different.  I do not 
> remember all details of the "--quiet" implementation, but I think that it
> 
> - exits early (as you said)
> 
> - does not turn on "recursive" to avoid unnecessary work.

OK, looking through the code, this works _sometimes_. If I say "git-diff --quiet" then it will not recurse. If I say "git-diff -p --quiet" then it will (even though we never show the -p output).

Since --quiet supersedes all output formats, I think it probably should just clear the recursive option entirely. In which case rather than special-casing quiet to avoid recursion in git-diff, we can simply turn on recursion before parsing options (and it will get turned off correctly by any diff options that need to do so).

Something like:
diff --git a/builtin-diff.c b/builtin-diff.c
index 7f367b6..e6d10bd 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -229,6 +229,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		argc = setup_revisions(argc, argv, &rev, NULL);
 	if (!rev.diffopt.output_format) {
 		rev.diffopt.output_format = DIFF_FORMAT_PATCH;
+		rev.diffopt.recursive = 1;
 		if (diff_setup_done(&rev.diffopt) < 0)
 			die("diff_setup_done failed");
 	}
diff --git a/diff.c b/diff.c
index a5fc56b..aeae1a3 100644
--- a/diff.c
+++ b/diff.c
@@ -2182,6 +2182,7 @@ int diff_setup_done(struct diff_options *options)
 	if (options->quiet) {
 		options->output_format = DIFF_FORMAT_NO_OUTPUT;
 		options->exit_with_status = 1;
+		options->recursive = 0;
 	}
 
 	/*

But maybe that doesn't work because some of the options need recursion
turned on, even if --quiet is specified. I have to admit, there are a
lot of code paths here and I'm not sure how all of them interact with
the recursive option. So perhaps it is better to just special case
options->quiet as you suggested.

-Peff
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 14 of 18 in “Documentation/git-diff: remove -r from --name-status example”
  1. Documentation/git-diff: remove -r from --name-status exampleJeff King, Jul 29, 2007
  2. Linus TorvaldsJul 29, 2007
  3. Jeff KingJul 29, 2007
  4. Linus TorvaldsJul 29, 2007
  5. Junio C HamanoJul 29, 2007
  6. Jeff KingJul 29, 2007
  7. David KastrupJul 29, 2007
  8. Junio C HamanoJul 29, 2007
  9. Jeff KingJul 29, 2007
  10. Johannes SchindelinJul 29, 2007
  11. David KastrupJul 29, 2007
  12. Jeff KingJul 29, 2007
  13. Johannes SchindelinJul 29, 2007
  14. Jeff KingJul 29, 2007
  15. Johannes SchindelinJul 29, 2007
  16. Jeff KingJul 29, 2007
  17. Linus TorvaldsJul 29, 2007
  18. Jeff KingJul 29, 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.