{"thread":{"id":"27960","subject":"[PATCH] Break down no-lstat() condition checks in verify_uptodate()","startedAt":"2011-07-30T03:55:05Z","lastAt":"2011-07-30T16:22:59Z","messageCount":2,"participants":["Nguyễn Thái Ngọc Duy","Clemens Buchacher"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"172368","messageId":"1311998105-6267-1-git-send-email-pclouds@gmail.com","threadId":"27960","inReplyTo":null,"subject":"[PATCH] Break down no-lstat() condition checks in verify_uptodate()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-07-30T03:55:05Z","receivedAt":"2011-07-30T03:55:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Make it easier to grok under what conditions we can skip lstat().\n\nWhile at there, shorten ie_match_stat() line for the sake of my eyes.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n unpack-trees.c |   15 +++++++++++++--\n 1 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 3a61d82..d8c7eb9 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1168,11 +1168,22 @@ static int verify_uptodate_1(struct cache_entry *ce,\n {\n \tstruct stat st;\n \n-\tif (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))\n+\tif (o->index_only)\n+\t\treturn 0;\n+\n+\t/*\n+\t * CE_VALID and CE_SKIP_WORKTREE cheat, we better check again\n+\t * if this entry is truely uptodate because this file may be\n+\t * overwritten.\n+\t */\n+\tif ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce))\n+\t\t; /* keep checking */\n+\telse if (o->reset || ce_uptodate(ce))\n \t\treturn 0;\n \n \tif (!lstat(ce->name, &st)) {\n-\t\tunsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);\n+\t\tint flags = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE;\n+\t\tunsigned changed = ie_match_stat(o->src_index, ce, &st, flags);\n \t\tif (!changed)\n \t\t\treturn 0;\n \t\t/*\n-- \n1.7.4.74.g639db\n"},{"id":"172403","messageId":"20110730162258.GC7545@toss.lan","threadId":"27960","inReplyTo":"1311998105-6267-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] Break down no-lstat() condition checks in verify_uptodate()","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2011-07-30T16:22:59Z","receivedAt":"2011-07-30T16:22:59Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Sat, Jul 30, 2011 at 10:55:05AM +0700, Nguyễn Thái Ngọc Duy wrote:\n>\n> +\t/*\n> +\t * CE_VALID and CE_SKIP_WORKTREE cheat, we better check again\n> +\t * if this entry is truely uptodate because this file may be\n> +\t * overwritten.\n> +\t */\n\ns/truely/truly\n\n> +\tif ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce))\n> +\t\t; /* keep checking */\n> +\telse if (o->reset || ce_uptodate(ce))\n>  \t\treturn 0;\n\nNice! Acked-by: Clemens Buchacher <drizzd@aon.at>\n"}]}