Break down no-lstat() condition checks in verify_uptodate()
PATCH 1/1 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 <[email protected]>
--- unpack-trees.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
unpack-trees.c +13 -2
@@ -1168,11 +1168,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 truely uptodate 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 ;/*
Signature · 1 line
1.7.4.74.g639db
unpack-trees.c static int verify_uptodate_1(struct cache_entry *ce, · line 1178
Quoted 6 lines · Nguyễn Thái Ngọc Duy
unpack-trees.c +5
-0+/* +* CE_VALID and CE_SKIP_WORKTREE cheat, we better check again +* if this entry is truely uptodate because this file may be +* overwritten. +*/
s/truely/truly
unpack-trees.c static int verify_uptodate_1(struct cache_entry *ce, · line 1182
Quoted 4 lines
unpack-trees.c +3
-0+if ((ce->ce_flags &CE_VALID ) ||ce_skip_worktree (ce)) + ;/* keep checking */ +else if (o->reset ||ce_uptodate (ce))return 0 ;
Nice! Acked-by: Clemens Buchacher <[email protected]>