diff options
author | Junio C Hamano <junkio@cox.net> | 2006-01-28 02:09:08 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-01-28 02:26:18 -0800 |
commit | 939aabbf7d108b5d6830bf5cd89abc910cc9ff27 (patch) | |
tree | a8844082231917ae1010fea74f6d31fc370a59fb /diff-files.c | |
parent | addafaf92eeb86033da91323d0d3ad7a496dae83 (diff) | |
download | git-939aabbf7d108b5d6830bf5cd89abc910cc9ff27.tar.gz git-939aabbf7d108b5d6830bf5cd89abc910cc9ff27.tar.xz |
diff-files -c/--cc: combine only when both ours and theirs exist.
The previous round forgot to make sure there actually are two
versions to compare against the working tree version. Otherwise
using -c/--cc would not make much sense.
Also plug a small memory leak.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff-files.c')
-rw-r--r-- | diff-files.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/diff-files.c b/diff-files.c index 4a30c56f8..4cafd3ea2 100644 --- a/diff-files.c +++ b/diff-files.c @@ -121,6 +121,7 @@ int main(int argc, const char **argv) struct combine_diff_path p; unsigned char fill[4][20]; } combine; + int num_compare_stages = 0; combine.p.next = NULL; combine.p.len = ce_namelen(ce); @@ -140,9 +141,11 @@ int main(int argc, const char **argv) * stage #3 (theirs) is the second. */ stage = ce_stage(nce); - if (2 <= stage) + if (2 <= stage) { + num_compare_stages++; memcpy(combine.p.parent_sha1[stage-2], nce->sha1, 20); + } /* diff against the proper unmerged stage */ if (stage == diff_unmerged_stage) @@ -154,12 +157,14 @@ int main(int argc, const char **argv) */ i--; - if (combine_merges) { + if (combine_merges && num_compare_stages == 2) { show_combined_diff(&combine.p, 2, dense_combined_merges, NULL, 0); + free(combine.p.path); continue; } + free(combine.p.path); /* * Show the diff for the 'ce' if we found the one |