diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-26 00:32:19 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-26 00:32:19 -0800 |
commit | 8807d321af394ffb2180d085669337bcd5018c50 (patch) | |
tree | 2956464a49a82a210612a2ea030a6affc12a67aa /combine-diff.c | |
parent | 5569dad48e22e7b373ce3ffcc32758163bbd7b42 (diff) | |
parent | 0d9b9ab1284ce125fd49cf7dbf4d28e0540cf035 (diff) | |
download | git-8807d321af394ffb2180d085669337bcd5018c50.tar.gz |
Merge branch 'maint'
* maint:
GIT 1.5.0.2
git-remote: support remotes with a dot in the name
Documentation: describe "-f/-t/-m" options to "git-remote add"
diff --cc: fix display of symlink conflicts during a merge.
Diffstat (limited to 'combine-diff.c')
-rw-r--r-- | combine-diff.c | 25 |
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); } |