Skip to content

Commit

Permalink
checkout bugfix: use stat.mtime instead of stat.ctime in two places
Browse files Browse the repository at this point in the history
Commit e1afca4 "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 110c46a "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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Kjetil Barvik authored and Junio C Hamano committed Mar 15, 2009
1 parent d7371a2 commit 5bcf109
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion builtin-fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_CTIME_NSEC(st) != mtime.nsec
|| ST_MTIME_NSEC(st) != mtime.nsec
#endif
)
die("shallow file was changed during fetch");
Expand Down
4 changes: 2 additions & 2 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5bcf109

Please sign in to comment.