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

[PATCH 1/2] checkout bugfix: use stat.mtime instead of stat.ctime in two places

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Mar 15, 2009, 11:38 UTC
Message-ID
<58b7f6028d593d66e4e181b60f85c8c8dd860aac.1237115791.git.barvik@broadpark.no>
In-Reply-To
<cover.1237115791.git.barvik@broadpark.no>

Commit e1afca4fd "write_index(): update index_state->timestamp after flushing to disk" on 2009-02-23 used stat.ctime to record the timestamp of the index-file. This is wrong, so fix this and use the correct stat.mtime timestamp instead.

Commit 110c46a909 "Not all systems use st_[cm]tim field for ns resolution file timestamp" on 2009-03-08, has a similar bug for the builtin-fetch-pack.c file.

Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
 builtin-fetch-pack.c |    2 +-
 read-cache.c         |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 0b1a356..d571253 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -806,7 +806,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
 				die("shallow file was removed during fetch");
 		} else if (st.st_mtime != mtime.sec
 #ifdef USE_NSEC
-				|| ST_CTIME_NSEC(st) != mtime.nsec
+				|| ST_MTIME_NSEC(st) != mtime.nsec
 #endif
 			  )
 			die("shallow file was changed during fetch");
diff --git a/read-cache.c b/read-cache.c
index 7f74c8d..3f58711 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1563,8 +1563,8 @@ int write_index(struct index_state *istate, int newfd)
 
 	if (ce_flush(&c, newfd) || fstat(newfd, &st))
 		return -1;
-	istate->timestamp.sec = (unsigned int)st.st_ctime;
-	istate->timestamp.nsec = ST_CTIME_NSEC(st);
+	istate->timestamp.sec = (unsigned int)st.st_mtime;
+	istate->timestamp.nsec = ST_MTIME_NSEC(st);
 	return 0;
 }
 
-- 
1.6.2.GIT
Previous: Kjetil BarvikNext: Kjetil Barvik
Message 2 of 13 in “git checkout: one bugfix and one cosmetic change”
  1. 0/2 git checkout: one bugfix and one cosmetic changeKjetil Barvik, Mar 15, 2009
  2. 1/2 checkout bugfix: use stat.mtime instead of stat.ctime in two placesKjetil Barvik, Mar 15, 2009
  3. 2/2 make the ST_{C,M}TIME_NSEC macros more function likeKjetil Barvik, Mar 15, 2009
  4. Junio C HamanoMar 15, 2009
  5. Kjetil BarvikMar 15, 2009
  6. Junio C HamanoMar 16, 2009
  7. Kjetil BarvikMar 17, 2009
  8. Junio C HamanoMar 15, 2009
  9. Junio C HamanoMar 15, 2009
  10. Michael J GruberMar 16, 2009
  11. Kris ShannonMar 17, 2009
  12. Jeff KingMar 17, 2009
  13. Michael J GruberMar 17, 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.