git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Support diff.autorefreshindex=true in `git-diff --quiet'
@ 2008-09-01  8:29 Karl Chen
  2008-09-01 10:31 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Karl Chen @ 2008-09-01  8:29 UTC (permalink / raw)
  To: Git mailing list


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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-02 20:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01  8:29 [PATCH] Support diff.autorefreshindex=true in `git-diff --quiet' Karl Chen
2008-09-01 10:31 ` Junio C Hamano
2008-09-01 10:50   ` Karl Chen
2008-09-02  6:20     ` Re* " Junio C Hamano
2008-09-02 17:39       ` Karl Chen
2008-09-02 17:47         ` Junio C Hamano
2008-09-02 17:59           ` Karl Chen
2008-09-02 20:19             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).