* [PATCH] Break down no-lstat() condition checks in verify_uptodate()
@ 2011-07-30 3:55 Nguyễn Thái Ngọc Duy
2011-07-30 16:22 ` Clemens Buchacher
0 siblings, 1 reply; 2+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-07-30 3:55 UTC (permalink / raw)
To: git, Junio C Hamano; +Cc: Nguyễn Thái Ngọc Duy
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>
---
unpack-trees.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 3a61d82..d8c7eb9 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -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;
/*
--
1.7.4.74.g639db
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Break down no-lstat() condition checks in verify_uptodate()
2011-07-30 3:55 [PATCH] Break down no-lstat() condition checks in verify_uptodate() Nguyễn Thái Ngọc Duy
@ 2011-07-30 16:22 ` Clemens Buchacher
0 siblings, 0 replies; 2+ messages in thread
From: Clemens Buchacher @ 2011-07-30 16:22 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
On Sat, Jul 30, 2011 at 10:55:05AM +0700, Nguyễn Thái Ngọc Duy wrote:
>
> + /*
> + * 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
> + 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 <drizzd@aon.at>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-30 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-30 3:55 [PATCH] Break down no-lstat() condition checks in verify_uptodate() Nguyễn Thái Ngọc Duy
2011-07-30 16:22 ` Clemens Buchacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).