From: Junio C Hamano <gitster@pobox.com>
To: Brian Gernhardt <benji@silverinsanity.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH] Create USE_ST_TIMESPEC and turn it on for Darwin
Date: Sun, 08 Mar 2009 13:51:33 -0700 [thread overview]
Message-ID: <7vhc23kaay.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1236542668-83333-1-git-send-email-benji@silverinsanity.com> (Brian Gernhardt's message of "Sun, 8 Mar 2009 16:04:28 -0400")
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?
> 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
next prev parent reply other threads:[~2009-03-08 20:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 20:04 [PATCH] Create USE_ST_TIMESPEC and turn it on for Darwin Brian Gernhardt
2009-03-08 20:51 ` Junio C Hamano [this message]
2009-03-08 21:21 ` Brian Gernhardt
2009-03-08 21:22 ` [PATCH] Makefile: Set compiler switch for USE_NSEC Brian Gernhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vhc23kaay.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=benji@silverinsanity.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.