All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix incorrect diff of a link -> file change if core.filemode = false.
@ 2007-02-16 23:09 Johannes Sixt
  2007-02-16 23:13 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2007-02-16 23:09 UTC (permalink / raw)
  To: git

After this sequence:

$ ln -s foo A
$ git add A
$ git commit -m link
$ rm A && echo bar > A

the working copy contains a regular file A but HEAD contains A as a link.

Normally, at this point 'git diff HEAD' displays this change as a removal
of the link followed by an addition of a new file. But in a repository where
core.filemode is false this is displayed as a modification of the link.
The reason is that the check when the cached mode is allowed to override the
file's actual mode is not strict enough.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 diff-lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 91cd877..5fc1910 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -171,7 +171,8 @@ static int get_stat_data(struct cache_entry *ce,
 		changed = ce_match_stat(ce, &st, 0);
 		if (changed) {
 			mode = create_ce_mode(st.st_mode);
-			if (!trust_executable_bit && S_ISREG(st.st_mode))
+			if (!trust_executable_bit &&
+			    S_ISREG(st.st_mode) && S_ISREG(ntohl(ce->ce_mode)))
 				mode = ce->ce_mode;
 			sha1 = no_sha1;
 		}
-- 
1.5.0.19.gddff

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-02-17 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-16 23:09 [PATCH] Fix incorrect diff of a link -> file change if core.filemode = false Johannes Sixt
2007-02-16 23:13 ` Junio C Hamano
2007-02-16 23:30   ` Johannes Sixt
2007-02-17  0:15     ` Junio C Hamano
2007-02-17  6:56       ` [PATCH] Do not take mode bits from index after type change Junio C Hamano
2007-02-17 10:31         ` Johannes Sixt
2007-02-17 17:49           ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.