Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-05-30 11:07:39 +0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-30 21:35:49 +0400
commit9d429ff6ff2832d6e63933e6d33b8380be703017 (patch)
tree6d154648564180b6a18e0b40edc99160e812f868 /diff.c
parent01c4e70f637c0617e24d9a7abb7239e25de9a51d (diff)
[PATCH] diff: further cleanup.
When preparing data to feed the external diff, we should give the mode we obtained from the caller, even when we are dealing with a file with 0{40} SHA1 (i.e. the caller said "look at the filesystem"), since the mode passed by the caller via diff_addremove() or diff_change() is always trustworthy. This is _not_ a bugfix --- the existing code stat() on the file ifself and does the same computation on st.st_mode to compute the mode the same way the caller did to give the original mode. We cannot remove the stat() call from here, but the extra computation to create the mode value is unnecessary. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index ac78782271..919280d2df 100644
--- a/diff.c
+++ b/diff.c
@@ -421,8 +421,13 @@ static void prepare_temp_file(const char *name,
strcpy(temp->hex, sha1_to_hex(null_sha1));
else
strcpy(temp->hex, sha1_to_hex(one->sha1));
- sprintf(temp->mode, "%06o",
- S_IFREG |ce_permissions(st.st_mode));
+ /* Even though we may sometimes borrow the
+ * contents from the work tree, we always want
+ * one->mode. mode is trustworthy even when
+ * !(one->sha1_valid), as long as
+ * DIFF_FILE_VALID(one).
+ */
+ sprintf(temp->mode, "%06o", one->mode);
}
return;
}