summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-07-30 10:55:05 +0700
committerJunio C Hamano <gitster@pobox.com>2011-07-31 18:42:38 -0700
commitd5b66299040969706dd675c021f4336a26a6cc82 (patch)
tree71294a8f435b5df36e1f11dbfc6b6fb47c859375 /unpack-trees.c
parentdd008b3b11286804bc7880bac10c34a76355fe92 (diff)
downloadgit-d5b66299040969706dd675c021f4336a26a6cc82.tar.gz
Break down no-lstat() condition checks in verify_uptodate()
Make it easier to grok under what conditions we can skip lstat(). While at there, shorten ie_match_stat() line for the sake of my eyes. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 07f8364244..e22b9ec408 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1166,11 +1166,22 @@ static int verify_uptodate_1(struct cache_entry *ce,
{
struct stat st;
- if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))
+ if (o->index_only)
+ return 0;
+
+ /*
+ * CE_VALID and CE_SKIP_WORKTREE cheat, we better check again
+ * if this entry is truly up-to-date because this file may be
+ * overwritten.
+ */
+ if ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce))
+ ; /* keep checking */
+ else if (o->reset || ce_uptodate(ce))
return 0;
if (!lstat(ce->name, &st)) {
- unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+ int flags = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE;
+ unsigned changed = ie_match_stat(o->src_index, ce, &st, flags);
if (!changed)
return 0;
/*