summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff-lib.c8
-rw-r--r--diff.c3
-rw-r--r--diff.h1
3 files changed, 9 insertions, 3 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 92c0e39ad6..f5568c3b36 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 f884de77ac..97cc5bc085 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 de21f8ecd0..4546aad219 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;