git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karl Chen <quarl@cs.berkeley.edu>
To: Git mailing list <git@vger.kernel.org>
Subject: [PATCH] Support diff.autorefreshindex=true in `git-diff --quiet'
Date: Mon, 01 Sep 2008 01:29:27 -0700	[thread overview]
Message-ID: <quack.20080901T0129.lth8wuci80o@roar.cs.berkeley.edu> (raw)


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

             reply	other threads:[~2008-09-01  8:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01  8:29 Karl Chen [this message]
2008-09-01 10:31 ` [PATCH] Support diff.autorefreshindex=true in `git-diff --quiet' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=quack.20080901T0129.lth8wuci80o@roar.cs.berkeley.edu \
    --to=quarl@cs.berkeley.edu \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).