git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC v2 3/3] verify_uptodate(): add ce_uptodate(ce) test

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Feb 19, 2009, 20:08 UTC
Message-ID
<e00cfda6e7d884680f0d20ad714465672bb9a232.1235071656.git.barvik@broadpark.no>
In-Reply-To
<cover.1235071656.git.barvik@broadpark.no>

If we inside verify_uptodate() can already tell from the ce entry that it is already uptodate by testing it with ce_uptodate(ce), there is no need to call lstat(2) and ie_match_stat() afterwards.

And, reading from the commit log message from:
    commit eadb5831342bb2e756fa05c03642c4aa1929d4f5
    Author: Junio C Hamano <gitster@pobox.com>
    Date:   Fri Jan 18 23:45:24 2008 -0800
    Avoid running lstat(2) on the same cache entry.

this also seems to be correct usage of the ce_uptodate() macro introduced by that patch.

This will avoid lots of lstat(2) calls in some cases, for example by running the 'git checkout' command.

Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
 unpack-trees.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 44714cc..1687aee 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -450,7 +450,7 @@ static int verify_uptodate(struct cache_entry *ce,
 {
 	struct stat st;
 
-	if (o->index_only || o->reset)
+	if (o->index_only || o->reset || ce_uptodate(ce))
 		return 0;
 
 	if (!lstat(ce->name, &st)) {
-- 
1.6.1.349.g99fa5
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “git checkout optimisation - part 3”
  1. 0/3 git checkout optimisation - part 3Kjetil Barvik, Feb 19, 2009
  2. 1/3 fix compile error when USE_NSEC is definedKjetil Barvik, Feb 19, 2009
  3. 2/3 make USE_NSEC work as expectedKjetil Barvik, Feb 19, 2009
  4. Junio C HamanoFeb 20, 2009
  5. Kjetil BarvikFeb 20, 2009
  6. Junio C HamanoFeb 21, 2009
  7. 3/3 verify_uptodate(): add ce_uptodate(ce) testKjetil Barvik, Feb 19, 2009
  8. Junio C HamanoFeb 20, 2009
  9. Kjetil BarvikFeb 20, 2009
  10. Sverre RabbelierFeb 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.