From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] diff: squelch empty diffs even more
Date: Wed, 15 Aug 2007 00:41:00 +0200 [thread overview]
Message-ID: <46C22F7C.1000502@lsrfire.ath.cx> (raw)
In-Reply-To: <7v643hbyao.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano schrieb:
> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
>
>> When we compare two non-tracked files or explicitly specify
>> --no-index then the suggestion to run git-status is not helpful.
>
> That observation is correct but how does skip_stat_unmatch count
> up in such a case? Shouldn't diffcore_skip_stat_unmatch()
> function be taught about such a "fake" filepair that did not
> come from git, and ignore the stat differences?
Hmm. Like this?
The patch adds a new diff_options bitfield member, no_index, that
is used instead of the special value of -2 of the rev_info field
max_count to indicate that the index is not to be used. This makes
it possible to pass that flag down to diffcore_skip_stat_unmatch(),
which only has one diff_options parameter.
This could even become a cleanup if we removed all assignments of
max_count to a value of -2 (viz. replacement of a magic value with
a self-documenting field name) but I didn't dare to do that so late
in the rc game..
The no_index bit, if set, then tells diffcore_skip_stat_unmatch()
to not account for any skipped stat-mismatches, which avoids the
suggestion to run git-status.
René
---
diff-lib.c | 8 ++++++--
diff.c | 3 ++-
diff.h | 1 +
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index 92c0e39..f5568c3 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -189,6 +189,7 @@ static int handle_diff_files_args(struct rev_info *revs,
!strcmp(argv[1], "--no-index")) {
revs->max_count = -2;
revs->diffopt.exit_with_status = 1;
+ revs->diffopt.no_index = 1;
}
else if (!strcmp(argv[1], "-q"))
*silent = 1;
@@ -204,8 +205,10 @@ static int handle_diff_files_args(struct rev_info *revs,
*/
read_cache();
if (!is_in_index(revs->diffopt.paths[0]) ||
- !is_in_index(revs->diffopt.paths[1]))
+ !is_in_index(revs->diffopt.paths[1])) {
revs->max_count = -2;
+ revs->diffopt.no_index = 1;
+ }
}
/*
@@ -293,6 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
+ revs->diffopt.no_index = 1;
revs->max_count = -2;
return 0;
}
@@ -304,7 +308,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
if (handle_diff_files_args(revs, argc, argv, &silent_on_removed))
return -1;
- if (revs->max_count == -2) {
+ if (revs->diffopt.no_index) {
if (revs->diffopt.nr_paths != 2)
return error("need two files/directories with --no-index");
if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
diff --git a/diff.c b/diff.c
index f884de7..97cc5bc 100644
--- a/diff.c
+++ b/diff.c
@@ -3185,7 +3185,8 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
* to determine how many paths were dirty only
* due to stat info mismatch.
*/
- diffopt->skip_stat_unmatch++;
+ if (!diffopt->no_index)
+ diffopt->skip_stat_unmatch++;
diff_free_filepair(p);
}
}
diff --git a/diff.h b/diff.h
index de21f8e..4546aad 100644
--- a/diff.h
+++ b/diff.h
@@ -60,6 +60,7 @@ struct diff_options {
color_diff_words:1,
has_changes:1,
quiet:1,
+ no_index:1,
allow_external:1,
exit_with_status:1;
int context;
next prev parent reply other threads:[~2007-08-14 22:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-14 21:09 [PATCH] diff: squelch empty diffs even more René Scharfe
2007-08-14 21:29 ` Junio C Hamano
2007-08-14 22:41 ` René Scharfe [this message]
2007-08-14 23:52 ` Junio C Hamano
2007-08-15 14:47 ` Johannes Schindelin
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=46C22F7C.1000502@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.