diff: deprecate -q option to diff-files

This reimplements the ancient "-q" option to "git diff-files" that was inherited from "show-diff -q" in terms of "--diff-filter=d". We will be deprecating the "-q" option, so let's issue a warning when we do so. Incidentally this also tentatively fixes "git diff --no-index" to honor "-q" and hide deletions; the use will get the same warning. We should remove the support for "-q" in a future version but it is not that urgent. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 17, 2013 at 17:18 UTC 95a7c546b02a962b9e458f7fd2d0ed9b657c0ca6
4 files changed +18 -7
diff-lib.c
+3 -5
@@ -86,10 +86,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
86 {
87 int entries, i;
88 int diff_unmerged_stage = revs->max_count;
89 - int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
89 unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
90 ? CE_MATCH_RACY_IS_DIRTY : 0);
91
92 + if (option & DIFF_SILENT_ON_REMOVED)
93 + handle_deprecated_show_diff_q(&revs->diffopt);
94 +
95 diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
96
97 if (diff_unmerged_stage < 0)
@@ -136,8 +138,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
138 perror(ce->name);
139 continue;
140 }
139 - if (silent_on_removed)
140 - continue;
141 wt_mode = 0;
142 }
143 dpath->mode = wt_mode;
@@ -203,8 +203,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
203 perror(ce->name);
204 continue;
205 }
206 - if (silent_on_removed)
207 - continue;
206 diff_addremove(&revs->diffopt, '-', ce->ce_mode,
207 ce->sha1, !is_null_sha1(ce->sha1),
208 ce->name, 0);
diff-no-index.c
+5 -2
@@ -187,7 +187,7 @@ void diff_no_index(struct rev_info *revs,
187 {
188 int i, prefixlen;
189 int no_index = 0;
190 - unsigned options = 0;
190 + unsigned deprecated_show_diff_q_option_used = 0;
191 const char *paths[2];
192
193 /* Were we asked to do --no-index explicitly? */
@@ -225,7 +225,7 @@ void diff_no_index(struct rev_info *revs,
225 if (!strcmp(argv[i], "--no-index"))
226 i++;
227 else if (!strcmp(argv[i], "-q")) {
228 - options |= DIFF_SILENT_ON_REMOVED;
228 + deprecated_show_diff_q_option_used = 1;
229 i++;
230 }
231 else if (!strcmp(argv[i], "--"))
@@ -260,6 +260,9 @@ void diff_no_index(struct rev_info *revs,
260 revs->max_count = -2;
261 diff_setup_done(&revs->diffopt);
262
263 + if (deprecated_show_diff_q_option_used)
264 + handle_deprecated_show_diff_q(&revs->diffopt);
265 +
266 setup_diff_pager(&revs->diffopt);
267 DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
268
diff.c
+8
@@ -3570,6 +3570,14 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
3570 return 0;
3571 }
3572
3573 +/* Used only by "diff-files" and "diff --no-index" */
3574 +void handle_deprecated_show_diff_q(struct diff_options *opt)
3575 +{
3576 + warning("'diff -q' and 'diff-files -q' are deprecated.");
3577 + warning("Use 'diff --diff-filter=d' instead to ignore deleted filepairs.");
3578 + parse_diff_filter_opt("d", opt);
3579 +}
3580 +
3581 int diff_opt_parse(struct diff_options *options, const char **av, int ac)
3582 {
3583 const char *arg = av[0];
diff.h
+2
@@ -341,6 +341,8 @@ extern int parse_rename_score(const char **cp_p);
341
342 extern long parse_algorithm_value(const char *value);
343
344 +extern void handle_deprecated_show_diff_q(struct diff_options *);
345 +
346 extern int print_stat_summary(FILE *fp, int files,
347 int insertions, int deletions);
348 extern void setup_diff_pager(struct diff_options *);