Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff --cc: fix display of symlink conflicts during a merge.
author
Junio C Hamano
<junkio@cox.net>
Mon, 26 Feb 2007 06:24:47 +0000
(22:24 -0800)
committer
Junio C Hamano
<junkio@cox.net>
Mon, 26 Feb 2007 06:25:30 +0000
(22:25 -0800)
"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>
combine-diff.c
patch
|
blob
|
history
diff-lib.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
0b1f647
)
diff --git
a/combine-diff.c
b/combine-diff.c
index a5f2c8dd4a414e513d0421f9a499d06c73ecaf5a..6b7c6be9590a41c1edd11ad68b0bc01ddd6209a4 100644
(file)
--- 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;
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;
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 {
result[len] = 0;
}
else {
- /* deleted file */
+ deleted_file:
result_size = 0;
elem->mode = 0;
result = xcalloc(1, 1);
}
result_size = 0;
elem->mode = 0;
result = xcalloc(1, 1);
}
+
if (0 <= fd)
close(fd);
}
if (0 <= fd)
close(fd);
}
diff --git
a/diff-lib.c
b/diff-lib.c
index 556d5345bfc74c720d35097d24322436ffdebe57..60c0fa6488eda7ae382500b70041aac4202a59c0 100644
(file)
--- a/
diff-lib.c
+++ b/
diff-lib.c
@@
-41,17
+41,27
@@
int run_diff_files(struct rev_info *revs, int silent_on_removed)
path_len = ce_namelen(ce);
path_len = ce_namelen(ce);
- dpath = xmalloc
(combine_diff_path_size
(5, path_len));
+ dpath = xmalloc
(combine_diff_path_size
(5, path_len));
dpath->path = (char *) &(dpath->parent[5]);
dpath->next = NULL;
dpath->len = path_len;
memcpy(dpath->path, ce->name, path_len);
dpath->path[path_len] = '\0';
dpath->path = (char *) &(dpath->parent[5]);
dpath->next = NULL;
dpath->len = path_len;
memcpy(dpath->path, ce->name, path_len);
dpath->path[path_len] = '\0';
- dpath->mode = 0;
hashclr(dpath->sha1);
memset(&(dpath->parent[0]), 0,
hashclr(dpath->sha1);
memset(&(dpath->parent[0]), 0,
- sizeof(struct combine_diff_parent)*5);
+ sizeof(struct combine_diff_parent)*5);
+
+ if (lstat(ce->name, &st) < 0) {
+ if (errno != ENOENT && errno != ENOTDIR) {
+ perror(ce->name);
+ continue;
+ }
+ if (silent_on_removed)
+ continue;
+ }
+ else
+ dpath->mode = canon_mode(st.st_mode);
while (i < entries) {
struct cache_entry *nce = active_cache[i];
while (i < entries) {
struct cache_entry *nce = active_cache[i];