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

Re: [PATCH] Create USE_ST_TIMESPEC and turn it on for Darwin

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2009, 20:51 UTC
Message-ID
<7vhc23kaay.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1236542668-83333-1-git-send-email-benji@silverinsanity.com>
Brian Gernhardt <benji@silverinsanity.com> writes:
> This also turns it on by default for OS X (Darwin) machines.  Likely
> this is a sane default for other BSD kernels as well, but I don't have
> any to test that assumption on.
Yeah, that was my initial reaction.  Any BSDers?
Show 16 quoted lines
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 83d8389..1906253 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -393,8 +393,13 @@ void git_qsort(void *base, size_t nmemb, size_t size,
>  #define ST_CTIME_NSEC(st) 0
>  #define ST_MTIME_NSEC(st) 0
>  #else
> +#ifdef USE_ST_TIMESPEC
> +#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctimespec.tv_nsec))
> +#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtimespec.tv_nsec))
> +#else
>  #define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctim.tv_nsec))
>  #define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtim.tv_nsec))
>  #endif
> +#endif
Thanks.

I think this patch moves things in the right direction, but there are other uses of "st_[cm]tim.tv_nsec" that do not use the ST_[CM]TIME_NSEC macro.

$ git grep -n -e 'st_[cm]tim\.' --cached -- '*.[ch]' builtin-fetch-pack.c:810: || st.st_mtim.tv_nsec != mtime.nsec git-compat-util.h:396:#define ST_CTIME_NSEC(st) ((unsigned int)((st).st_ctim.tv_nsec)) git-compat-util.h:397:#define ST_MTIME_NSEC(st) ((unsigned int)((st).st_mtim.tv_nsec)) read-cache.c:207: if (ce->ce_mtime.nsec != (unsigned int)st->st_mtim.tv_nsec) read-cache.c:209: if (trust_ctime && ce->ce_ctime.nsec != (unsigned int)st->st_ctim.tv_nsec)

Probably we should apply the following patch as a fix, and then apply your enhancement to support st_[cm]timespec systems?

 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 59b0b0a..1d7e023 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -807,7 +807,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.st_mtim.tv_nsec != mtime.nsec
+				|| ST_CTIME_NSEC(st) != mtime.nsec
 #endif
 			  )
 			die("shallow file was changed during fetch");
diff --git a/read-cache.c b/read-cache.c
index b819abb..7f74c8d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -204,9 +204,9 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 		changed |= CTIME_CHANGED;
 
 #ifdef USE_NSEC
-	if (ce->ce_mtime.nsec != (unsigned int)st->st_mtim.tv_nsec)
+	if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && ce->ce_ctime.nsec != (unsigned int)st->st_ctim.tv_nsec)
+	if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
 		changed |= CTIME_CHANGED;
 #endif
 
Previous: Brian GernhardtNext: Brian Gernhardt
Message 2 of 4 in “Create USE_ST_TIMESPEC and turn it on for Darwin”
  1. Create USE_ST_TIMESPEC and turn it on for DarwinBrian Gernhardt, Mar 8, 2009
  2. Junio C HamanoMar 8, 2009
  3. Brian GernhardtMar 8, 2009
  4. Makefile: Set compiler switch for USE_NSECBrian Gernhardt, Mar 8, 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.