提交 c20f5926 编写于 作者: J Junio C Hamano

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: NJunio C Hamano <gitster@pobox.com>
上级 f174a258
...@@ -173,6 +173,7 @@ void diff_no_index(struct rev_info *revs, ...@@ -173,6 +173,7 @@ void diff_no_index(struct rev_info *revs,
int i; int i;
int no_index = 0; int no_index = 0;
unsigned options = 0; unsigned options = 0;
const char *paths[2];
/* Were we asked to do --no-index explicitly? */ /* Were we asked to do --no-index explicitly? */
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
...@@ -231,8 +232,6 @@ void diff_no_index(struct rev_info *revs, ...@@ -231,8 +232,6 @@ void diff_no_index(struct rev_info *revs,
if (prefix) { if (prefix) {
int len = strlen(prefix); int len = strlen(prefix);
const char *paths[3];
memset(paths, 0, sizeof(paths));
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i]; const char *p = argv[argc - 2 + i];
...@@ -245,10 +244,10 @@ void diff_no_index(struct rev_info *revs, ...@@ -245,10 +244,10 @@ void diff_no_index(struct rev_info *revs,
: p); : p);
paths[i] = p; paths[i] = p;
} }
diff_tree_setup_paths(paths, &revs->diffopt); } else {
for (i = 0; i < 2; i++)
paths[i] = argv[argc - 2 + i];
} }
else
diff_tree_setup_paths(argv + argc - 2, &revs->diffopt);
revs->diffopt.skip_stat_unmatch = 1; revs->diffopt.skip_stat_unmatch = 1;
if (!revs->diffopt.output_format) if (!revs->diffopt.output_format)
revs->diffopt.output_format = DIFF_FORMAT_PATCH; revs->diffopt.output_format = DIFF_FORMAT_PATCH;
...@@ -260,8 +259,7 @@ void diff_no_index(struct rev_info *revs, ...@@ -260,8 +259,7 @@ void diff_no_index(struct rev_info *revs,
if (diff_setup_done(&revs->diffopt) < 0) if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed"); die("diff_setup_done failed");
if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0], if (queue_diff(&revs->diffopt, paths[0], paths[1]))
revs->diffopt.pathspec.raw[1]))
exit(1); exit(1);
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/"); diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
diffcore_std(&revs->diffopt); diffcore_std(&revs->diffopt);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册