@matheusbsbs / matheus-bagliano / commits / ff72af00f8
Fork 0

Support a merge with conflicting gitlink change

merge-recursive did not support merging trees that have conflicting changes in submodules they contain, and died. Support it exactly the same way as how it handles conflicting symbolic link changes --- mark it as a conflict, take the tentative result from the current side, and letting the caller resolve the conflict, without dying in merge_file() function. Also reword the error message issued when merge_file() has to die because it sees a tree entry of type it does not support yet. [jc: fixed up initial draft by Finn Arne Gangstad] Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 10, 2007 at 11:22 UTC ff72af00f86cbbaaab57c886c70f9799715ca02f
2 files changed +10 -4
git-merge-one-file.sh
+4
@@ -80,6 +80,10 @@ case "${1:-.}${2:-.}${3:-.}" in
80 echo "ERROR: $4: Not merging symbolic link changes."
81 exit 1
82 ;;
83 + *,160000,*)
84 + echo "ERROR: $4: Not merging conflicting submodule changes."
85 + exit 1
86 + ;;
87 esac
88
89 src2=`git-unpack-file $3`
merge-recursive.c
+6 -4
@@ -1046,14 +1046,16 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
1046
1047 free(result_buf.ptr);
1048 result.clean = (merge_status == 0);
1049 - } else {
1050 - if (!(S_ISLNK(a->mode) || S_ISLNK(b->mode)))
1051 - die("cannot merge modes?");
1052 -
1049 + } else if (S_ISGITLINK(a->mode)) {
1050 + result.clean = 0;
1051 + hashcpy(result.sha, a->sha1);
1052 + } else if (S_ISLNK(a->mode)) {
1053 hashcpy(result.sha, a->sha1);
1054
1055 if (!sha_eq(a->sha1, b->sha1))
1056 result.clean = 0;
1057 + } else {
1058 + die("unsupported object type in the tree");
1059 }
1060 }
1061