An important user, wt-status, does not want no-index. So add a parameter to run_diff_files() which says if it is allowed or not. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- > How about adding "int always_use_index" to the signature of > run_diff_files()? I called the parameter "allow_no_index", since it is a little friendlier. I have been accused of being not friendly enough. builtin-diff-files.c | 2 +- builtin-diff.c | 2 +- diff-lib.c | 5 +++-- diff.h | 2 +- wt-status.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 8d78dfa..05a81b1 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -26,5 +26,5 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) argc = setup_revisions(argc, argv, &rev, NULL); if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; - return run_diff_files(&rev, argc, argv); + return run_diff_files(&rev, argc, argv, 1); } diff --git a/builtin-diff.c b/builtin-diff.c index 9334589..7f1ad60 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -282,7 +282,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (!ents) { switch (blobs) { case 0: - return run_diff_files(&rev, argc, argv); + return run_diff_files(&rev, argc, argv, 1); break; case 1: if (paths != 1) diff --git a/diff-lib.c b/diff-lib.c index 83d6682..7877f5c 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -200,7 +200,8 @@ static int handle_diff_files_args(struct rev_info *revs, return 0; } -int run_diff_files(struct rev_info *revs, int argc, const char **argv) +int run_diff_files(struct rev_info *revs, int argc, const char **argv, + int allow_no_index) { int entries, i; int diff_unmerged_stage; @@ -211,7 +212,7 @@ int run_diff_files(struct rev_info *revs, int argc, const char **argv) diff_unmerged_stage = revs->max_count; - if (revs->max_count == -2) { + if (allow_no_index && revs->max_count == -2) { if (revs->diffopt.nr_paths != 2) return error("need two files/directories with --no-index"); queue_diff(&revs->diffopt, revs->diffopt.paths[0], diff --git a/diff.h b/diff.h index cc28418..bf2d3c9 100644 --- a/diff.h +++ b/diff.h @@ -218,7 +218,7 @@ extern void diff_flush(struct diff_options*); extern const char *diff_unique_abbrev(const unsigned char *, int); -extern int run_diff_files(struct rev_info *revs, int argc, const char **argv); +extern int run_diff_files(struct rev_info *revs, int argc, const char **argv, int allow_no_index); extern int run_diff_index(struct rev_info *revs, int cached); diff --git a/wt-status.c b/wt-status.c index b68eea3..4e8904d 100644 --- a/wt-status.c +++ b/wt-status.c @@ -231,7 +231,7 @@ static void wt_status_print_changed(struct wt_status *s) rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_print_changed_cb; rev.diffopt.format_callback_data = s; - run_diff_files(&rev, 0, NULL); + run_diff_files(&rev, 0, NULL, 0); } static void wt_status_print_untracked(struct wt_status *s) -- 1.5.0.51.ge5582-dirty - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html