combine-diff: diff-files fix.
When showing a conflicted merge from index stages and working tree file, we did not fetch the mode from the working tree, and mistook that as a deleted file. Also if the manual resolution (or automated resolution by git rerere) ended up taking either parent's version, we did not show _anything_ for that path. Either was quite bad and confusing. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 13, 2006 at 23:07 UTC
713a11fceb662f275b5e1294acc6f38674834941
1 file changed
+5
-4
combine-diff.c
+5
-4
@@ -630,9 +630,10 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
630
int i, show_hunks, shown_header = 0;
631
char ourtmp_buf[TMPPATHLEN];
632
char *ourtmp = ourtmp_buf;
633
+ int working_tree_file = !memcmp(elem->sha1, null_sha1, 20);
634
635
/* Read the result of merge first */
635
- if (memcmp(elem->sha1, null_sha1, 20)) {
636
+ if (!working_tree_file) {
637
result = grab_blob(elem->sha1, &size);
638
write_to_temp_file(ourtmp, result, size);
639
}
@@ -646,6 +647,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
647
int len = st.st_size;
648
int cnt = 0;
649
650
+ elem->mode = DIFF_FILE_CANON_MODE(st.st_mode);
651
size = len;
652
result = xmalloc(len + 1);
653
while (cnt < len) {
@@ -661,6 +663,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
663
else {
664
/* deleted file */
665
size = 0;
666
+ elem->mode = 0;
667
result = xmalloc(1);
668
result[0] = 0;
669
ourtmp = "/dev/null";
@@ -716,7 +719,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
719
720
show_hunks = make_hunks(sline, cnt, num_parent, dense);
721
719
- if (show_hunks || mode_differs) {
722
+ if (show_hunks || mode_differs || working_tree_file) {
723
const char *abb;
724
725
if (header) {
@@ -731,8 +734,6 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
734
putchar('\n');
735
printf("index ");
736
for (i = 0; i < num_parent; i++) {
734
- if (elem->parent[i].mode != elem->mode)
735
- mode_differs = 1;
737
abb = find_unique_abbrev(elem->parent[i].sha1,
738
DEFAULT_ABBREV);
739
printf("%s%s", i ? "," : "", abb);