Re: [PATCH/RFC v2 2/3] make USE_NSEC work as expected
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 20, 2009, 08:35 UTC
- Message-ID
- <7vab8hfqug.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <24cefa55a62e2c898f9bd75ff7a6fe8e70836cf0.1235071656.git.barvik@broadpark.no>
Kjetil Barvik <barvik@broadpark.no> writes:
Show 19 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index 940ec76..ca4bec2 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -67,8 +67,15 @@ void rename_index_entry_at(struct index_state *istate, int nr, const char *new_n
> */
> void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
> {
> - ce->ce_ctime = st->st_ctime;
> - ce->ce_mtime = st->st_mtime;
> + ce->ce_ctime.sec = (unsigned int)st->st_ctime;
> + ce->ce_mtime.sec = (unsigned int)st->st_mtime;
> +#ifdef USE_NSEC
> + ce->ce_ctime.nsec = (unsigned int)st->st_ctim.tv_nsec;
> + ce->ce_mtime.nsec = (unsigned int)st->st_mtim.tv_nsec;
> +#else
> + ce->ce_ctime.nsec = 0;
> + ce->ce_mtime.nsec = 0;
> +#endifHow does this affect a use case where the same index file used with two instances of git (one compiled with and another without USE_NSEC)?
Show 9 quoted lines
> @@ -232,8 +246,16 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
> static int is_racy_timestamp(const struct index_state *istate, struct cache_entry *ce)
> {
> return (!S_ISGITLINK(ce->ce_mode) &&
> - istate->timestamp &&
> - ((unsigned int)istate->timestamp) <= ce->ce_mtime);
> + istate->timestamp.sec &&
> +#ifdef USE_NSEC
> + /* nanosecond timestamped files can also be racy! */Amusing ;-)
Show 16 quoted lines
> diff --git a/unpack-trees.c b/unpack-trees.c
> index e547282..44714cc 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -380,8 +380,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
>
> memset(&o->result, 0, sizeof(o->result));
> o->result.initialized = 1;
> - if (o->src_index)
> - o->result.timestamp = o->src_index->timestamp;
> + if (o->src_index) {
> + o->result.timestamp.sec = o->src_index->timestamp.sec;
> +#ifdef USE_NSEC
> + o->result.timestamp.nsec = o->src_index->timestamp.nsec;
> +#endif
> + }Do we need this hunk?