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

[PATCH] Support diff.autorefreshindex=true in `git-diff --quiet'

From
KCKarl Chen <quarl@cs.berkeley.edu>
Date
Sep 1, 2008, 08:29 UTC
Message-ID
<quack.20080901T0129.lth8wuci80o@roar.cs.berkeley.edu>

When diff.autorefreshindex is true, if a file has merely been 'touched' (mtime changed, but contents unchanged), then `git-diff --quiet' will now return 0 (indicating no change) instead of 1, and also silently refresh the index.

Signed-off-by: Karl Chen <quarl@quarl.org>
---
In current git master:
   
  git init
  echo abc > file1
  git add file1
  git commit -m msg
   
  sleep 1; touch file1
   
  git diff --exit-code --quiet file1
  echo $?
      # 1 [I expected 0]
   
  git diff --exit-code file1
  echo $?
      # 0 [as expected]
   
  git diff --exit-code --quiet file1
  echo $?
      # 0 [the non-quiet diff refreshed the cache]

I think `git diff --quiet file1' should return 0 when file1 only differs by mtime. I got this to work by having diffcore_std() call diffcore_skip_stat_unmatch() even when --quiet is specified. (I'm not sure about interaction with the other options.)

 diff.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/diff.c b/diff.c
index 135dec4..986cec3 100644
--- a/diff.c
+++ b/diff.c
@@ -3386,22 +3386,24 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
 
 void diffcore_std(struct diff_options *options)
 {
-	if (DIFF_OPT_TST(options, QUIET))
-		return;
-
-	if (options->skip_stat_unmatch && !DIFF_OPT_TST(options, FIND_COPIES_HARDER))
-		diffcore_skip_stat_unmatch(options);
-	if (options->break_opt != -1)
-		diffcore_break(options->break_opt);
-	if (options->detect_rename)
-		diffcore_rename(options);
-	if (options->break_opt != -1)
-		diffcore_merge_broken();
-	if (options->pickaxe)
-		diffcore_pickaxe(options->pickaxe, options->pickaxe_opts);
-	if (options->orderfile)
-		diffcore_order(options->orderfile);
-	diff_resolve_rename_copy();
+	if (DIFF_OPT_TST(options, QUIET)) {
+		if (options->skip_stat_unmatch)
+			diffcore_skip_stat_unmatch(options);
+	} else {
+		if (options->skip_stat_unmatch && !DIFF_OPT_TST(options, FIND_COPIES_HARDER))
+			diffcore_skip_stat_unmatch(options);
+		if (options->break_opt != -1)
+			diffcore_break(options->break_opt);
+		if (options->detect_rename)
+			diffcore_rename(options);
+		if (options->break_opt != -1)
+			diffcore_merge_broken();
+		if (options->pickaxe)
+			diffcore_pickaxe(options->pickaxe, options->pickaxe_opts);
+		if (options->orderfile)
+			diffcore_order(options->orderfile);
+		diff_resolve_rename_copy();
+	}
 	diffcore_apply_filter(options->filter);
 
 	if (diff_queued_diff.nr)
-- 
1.5.6.3
Next: Junio C Hamano
Message 1 of 8 in “Support diff.autorefreshindex=true in `git-diff --quiet'”
  1. Support diff.autorefreshindex=true in `git-diff --quiet'Karl Chen, Sep 1, 2008
  2. Junio C HamanoSep 1, 2008
  3. Karl ChenSep 1, 2008
  4. Re* [PATCH] Support diff.autorefreshindex=true in `git-diff --quiet'Junio C Hamano, Sep 2, 2008
  5. Karl ChenSep 2, 2008
  6. Junio C HamanoSep 2, 2008
  7. Karl ChenSep 2, 2008
  8. Junio C HamanoSep 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.