Skip to content

Commit c20f592

Browse files
committed
diff-index.c: do not pretend paths are pathspecs
"git diff --no-index" takes exactly two paths, not pathspecs, and has its own way queue_diff() to populate the diff_queue. Do not call diff_tree_setup_paths(), pretending as it takes pathspecs. Signed-off-by: Junio C Hamano <[email protected]>
1 parent f174a25 commit c20f592

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

diff-no-index.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ void diff_no_index(struct rev_info *revs,
173173
int i;
174174
int no_index = 0;
175175
unsigned options = 0;
176+
const char *paths[2];
176177

177178
/* Were we asked to do --no-index explicitly? */
178179
for (i = 1; i < argc; i++) {
@@ -231,8 +232,6 @@ void diff_no_index(struct rev_info *revs,
231232

232233
if (prefix) {
233234
int len = strlen(prefix);
234-
const char *paths[3];
235-
memset(paths, 0, sizeof(paths));
236235

237236
for (i = 0; i < 2; i++) {
238237
const char *p = argv[argc - 2 + i];
@@ -245,10 +244,10 @@ void diff_no_index(struct rev_info *revs,
245244
: p);
246245
paths[i] = p;
247246
}
248-
diff_tree_setup_paths(paths, &revs->diffopt);
247+
} else {
248+
for (i = 0; i < 2; i++)
249+
paths[i] = argv[argc - 2 + i];
249250
}
250-
else
251-
diff_tree_setup_paths(argv + argc - 2, &revs->diffopt);
252251
revs->diffopt.skip_stat_unmatch = 1;
253252
if (!revs->diffopt.output_format)
254253
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -260,8 +259,7 @@ void diff_no_index(struct rev_info *revs,
260259
if (diff_setup_done(&revs->diffopt) < 0)
261260
die("diff_setup_done failed");
262261

263-
if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0],
264-
revs->diffopt.pathspec.raw[1]))
262+
if (queue_diff(&revs->diffopt, paths[0], paths[1]))
265263
exit(1);
266264
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
267265
diffcore_std(&revs->diffopt);

0 commit comments

Comments
 (0)