From 308efc10d890265a4c62a8b58f025aaf8a1f244d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Feb 2007 18:17:15 -0800 Subject: merge-index: fix longstanding bug in merging symlinks Ancient commit e2b6a9d0 added code to pass "file modes" from merge-index to merge-one-file, and then later commit 54dd99a1 wanted to make sure we do not end up creating a nonsense symlink that points at a path whose name contains conflict markers. However, nobody noticed that the code in merge-index added by e2b6a9d0 were stripping the S_IFMT bits and the code in 54dd99a1 was meaningless. This fixes it. Signed-off-by: Junio C Hamano diff --git a/merge-index.c b/merge-index.c index a9983dd..7027d78 100644 --- a/merge-index.c +++ b/merge-index.c @@ -60,7 +60,7 @@ static int merge_entry(int pos, const char *path) break; found++; strcpy(hexbuf[stage], sha1_to_hex(ce->sha1)); - sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode) & (~S_IFMT)); + sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode)); arguments[stage] = hexbuf[stage]; arguments[stage + 4] = ownbuf[stage]; } while (++pos < active_nr); -- cgit v0.10.2-6-g49f6 From 17cd29b25c0f480a3c6e1dd9617d9c6046e3c280 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 25 Feb 2007 18:42:07 -0800 Subject: merge-recursive: fix longstanding bug in merging symlinks Commit 3af244ca added unlink(2) before running symlink(2) to update the working tree with the merge result, but it was unlinking a wrong path. This resulted in loss of the path pointed by a symlink. Signed-off-by: Junio C Hamano diff --git a/merge-recursive.c b/merge-recursive.c index 5898942..397a7ad 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -589,7 +589,7 @@ static void update_file_flags(const unsigned char *sha, memcpy(lnk, buf, size); lnk[size] = '\0'; mkdir_p(path, 0777); - unlink(lnk); + unlink(path); symlink(lnk, path); } else die("do not know what to do with %06o %s '%s'", -- cgit v0.10.2-6-g49f6