diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-03-22 15:26:07 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-22 15:26:07 -0700 |
commit | 150115aded2e1e0a83db7366f59e4b5bf1aa8135 (patch) | |
tree | f573f9b2222062c312d49af8cbe59a62d5af7ed6 /diff.c | |
parent | ea02eef096d4bfcbb83e76cfab0fcb42dbcad35e (diff) | |
download | git-150115aded2e1e0a83db7366f59e4b5bf1aa8135.tar.gz git-150115aded2e1e0a83db7366f59e4b5bf1aa8135.tar.xz |
diff --cached: do not borrow from a work tree when a path is marked as assume-unchanged
When the index says that the file in the work tree that corresponds to the
blob object that is used for comparison is known to be unchanged, "diff"
reads from the file and applies convert_to_git(), instead of inflating the
object, to feed the internal diff engine with, because an earlier
benchnark found that it tends to be faster to use this optimization.
However, the index can lie when the path is marked as assume-unchanged.
Disable the optimization for such paths.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1687,7 +1687,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 @@ -1728,6 +1729,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) || |