summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-28 07:42:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-03-28 07:42:31 (GMT)
commitaa72a14a7f648ae47749281002e94cfcf36f39e2 (patch)
treea63743757a78f2585f13550faec0ed474cca36cd /diff.c
parent48bcfbd1342f69a523c4214804682458e1121bd9 (diff)
parent150115aded2e1e0a83db7366f59e4b5bf1aa8135 (diff)
downloadgit-aa72a14a7f648ae47749281002e94cfcf36f39e2.zip
git-aa72a14a7f648ae47749281002e94cfcf36f39e2.tar.gz
git-aa72a14a7f648ae47749281002e94cfcf36f39e2.tar.bz2
Merge branch 'jc/maint-1.6.0-diff-borrow-carefully'
* jc/maint-1.6.0-diff-borrow-carefully: diff --cached: do not borrow from a work tree when a path is marked as assume-unchanged
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 699ae6a..e0fa78c 100644
--- a/diff.c
+++ b/diff.c
@@ -1757,7 +1757,8 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
struct stat st;
int pos, len;
- /* We do not read the cache ourselves here, because the
+ /*
+ * We do not read the cache ourselves here, because the
* benchmark with my previous version that always reads cache
* shows that it makes things worse for diff-tree comparing
* two linux-2.6 kernel trees in an already checked out work
@@ -1798,6 +1799,13 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
return 0;
/*
+ * If ce is marked as "assume unchanged", there is no
+ * guarantee that work tree matches what we are looking for.
+ */
+ if (ce->ce_flags & CE_VALID)
+ return 0;
+
+ /*
* If ce matches the file in the work tree, we can reuse it.
*/
if (ce_uptodate(ce) ||