Merge branch 'jc/diff-merge-base-multi'

* jc/diff-merge-base-multi:
  diff A...B: give one possible diff when there are more than one merge-base
This commit is contained in:
Junio C Hamano 2010-07-15 12:08:25 -07:00
Родитель a8b7fcffdd c008c0ff20
Коммит 4cd1b99c32
1 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -407,17 +407,32 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
result = builtin_diff_index(&rev, argc, argv); result = builtin_diff_index(&rev, argc, argv);
else if (ents == 2) else if (ents == 2)
result = builtin_diff_tree(&rev, argc, argv, ent); result = builtin_diff_tree(&rev, argc, argv, ent);
else if ((ents == 3) && (ent[0].item->flags & UNINTERESTING)) { else if (ent[0].item->flags & UNINTERESTING) {
/* diff A...B where there is one sane merge base between /*
* A and B. We have ent[0] == merge-base, ent[1] == A, * Perhaps the user gave us A...B, which expands
* and ent[2] == B. Show diff between the base and B. * to a list of negative merge bases followed by
* A (symmetric-left) and B? Let's make sure...
*/ */
ent[1] = ent[2]; for (i = 1; i < ents; i++)
if (!(ent[i].item->flags & UNINTERESTING))
break;
if (ents != i + 2 ||
(ent[i+1].item->flags & UNINTERESTING) ||
(!(ent[i].item->flags & SYMMETRIC_LEFT)) ||
(ent[i+1].item->flags & SYMMETRIC_LEFT))
die("what do you mean by that?");
/*
* diff A...B where there is at least one merge base
* between A and B. We have ent[0] == merge-base,
* ent[ents-2] == A, and ent[ents-1] == B. Show diff
* between the base and B. Note that we pick one
* merge base at random if there are more than one.
*/
ent[1] = ent[ents-1];
result = builtin_diff_tree(&rev, argc, argv, ent); result = builtin_diff_tree(&rev, argc, argv, ent);
} } else
else
result = builtin_diff_combined(&rev, argc, argv, result = builtin_diff_combined(&rev, argc, argv,
ent, ents); ent, ents);
result = diff_result_code(&rev.diffopt, result); result = diff_result_code(&rev.diffopt, result);
if (1 < rev.diffopt.skip_stat_unmatch) if (1 < rev.diffopt.skip_stat_unmatch)
refresh_index_quietly(); refresh_index_quietly();