summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-25 22:24:47 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-25 22:25:30 -0800
commit4fc970c43884e6215c13d6944a2def1eb2134ed5 (patch)
tree19de8184265822e1c47a62847bdecd7eedc61372 /combine-diff.c
parent0b1f6475570b915c56f380f2bd790ff94e606ef4 (diff)
downloadgit-4fc970c43884e6215c13d6944a2def1eb2134ed5.tar.gz
diff --cc: fix display of symlink conflicts during a merge.
"git-diff-files --cc" to show conflicts during merge did not pass the correct mode information for the working tree down, and showed bogus combined diff. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/combine-diff.c b/combine-diff.c
index a5f2c8dd4a..6b7c6be959 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -678,9 +678,25 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
else {
/* Used by diff-tree to read from the working tree */
struct stat st;
- int fd;
- if (0 <= (fd = open(elem->path, O_RDONLY)) &&
- !fstat(fd, &st)) {
+ int fd = -1;
+
+ if (lstat(elem->path, &st) < 0)
+ goto deleted_file;
+
+ if (S_ISLNK(st.st_mode)) {
+ int len = st.st_size;
+ result_size = len;
+ result = xmalloc(len + 1);
+ if (result_size != readlink(elem->path, result, len)) {
+ error("readlink(%s): %s", elem->path,
+ strerror(errno));
+ return;
+ }
+ result[len] = 0;
+ elem->mode = canon_mode(st.st_mode);
+ }
+ else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
+ !fstat(fd, &st)) {
int len = st.st_size;
int sz = 0;
@@ -698,11 +714,12 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
result[len] = 0;
}
else {
- /* deleted file */
+ deleted_file:
result_size = 0;
elem->mode = 0;
result = xcalloc(1, 1);
}
+
if (0 <= fd)
close(fd);
}