Skip to content

Commit

Permalink
Break down no-lstat() condition checks in verify_uptodate()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 1, 2011
1 parent dd008b3 commit d5b6629
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/*
Expand Down

0 comments on commit d5b6629

Please sign in to comment.