Skip to content

Commit 95a7c54

Browse files
committed
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>
1 parent 7f2ea5f commit 95a7c54

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

diff-lib.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
8686
{
8787
int entries, i;
8888
int diff_unmerged_stage = revs->max_count;
89-
int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
9089
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
9190
? CE_MATCH_RACY_IS_DIRTY : 0);
9291

92+
if (option & DIFF_SILENT_ON_REMOVED)
93+
handle_deprecated_show_diff_q(&revs->diffopt);
94+
9395
diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
9496

9597
if (diff_unmerged_stage < 0)
@@ -136,8 +138,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
136138
perror(ce->name);
137139
continue;
138140
}
139-
if (silent_on_removed)
140-
continue;
141141
wt_mode = 0;
142142
}
143143
dpath->mode = wt_mode;
@@ -203,8 +203,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
203203
perror(ce->name);
204204
continue;
205205
}
206-
if (silent_on_removed)
207-
continue;
208206
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
209207
ce->sha1, !is_null_sha1(ce->sha1),
210208
ce->name, 0);

diff-no-index.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void diff_no_index(struct rev_info *revs,
187187
{
188188
int i, prefixlen;
189189
int no_index = 0;
190-
unsigned options = 0;
190+
unsigned deprecated_show_diff_q_option_used = 0;
191191
const char *paths[2];
192192

193193
/* Were we asked to do --no-index explicitly? */
@@ -225,7 +225,7 @@ void diff_no_index(struct rev_info *revs,
225225
if (!strcmp(argv[i], "--no-index"))
226226
i++;
227227
else if (!strcmp(argv[i], "-q")) {
228-
options |= DIFF_SILENT_ON_REMOVED;
228+
deprecated_show_diff_q_option_used = 1;
229229
i++;
230230
}
231231
else if (!strcmp(argv[i], "--"))
@@ -260,6 +260,9 @@ void diff_no_index(struct rev_info *revs,
260260
revs->max_count = -2;
261261
diff_setup_done(&revs->diffopt);
262262

263+
if (deprecated_show_diff_q_option_used)
264+
handle_deprecated_show_diff_q(&revs->diffopt);
265+
263266
setup_diff_pager(&revs->diffopt);
264267
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
265268

diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,6 +3570,14 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
35703570
return 0;
35713571
}
35723572

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+
35733581
int diff_opt_parse(struct diff_options *options, const char **av, int ac)
35743582
{
35753583
const char *arg = av[0];

diff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ extern int parse_rename_score(const char **cp_p);
341341

342342
extern long parse_algorithm_value(const char *value);
343343

344+
extern void handle_deprecated_show_diff_q(struct diff_options *);
345+
344346
extern int print_stat_summary(FILE *fp, int files,
345347
int insertions, int deletions);
346348
extern void setup_diff_pager(struct diff_options *);

0 commit comments

Comments
 (0)