Re: Git does not handle changing inode numbers well
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 8, 2012, 17:53 UTC
- Message-ID
- <7vboiltglr.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20120808152230.GQ21274@login.drsnuggles.stderr.nl>
Matthijs Kooijman <matthijs@stdin.nl> writes:
Show 7 quoted lines
> So, it seems that git just doesn't cope well with changing inode numbers > because it checks the content in a first pass in refresh_index, but only > checks the stat info in the second pass in run_diff_files. The reason it > does work for regular files is EC_UPTODATE optimization introduced in > eadb5831: Avoid running lstat(2) on the same cache entry. > > So, let's see if I can fix my filesystem now ;-)
True. We have knobs to cope with filesystems whose st_dev or st_ctime are not stable, but there is no such knob to tweak for st_ino. Shouldn't be too hard to add such, though. One approach is to do something like the attached patch, and declare, define, initialize, and set trust_inum in a way similar to how we handle trust_ctime in the existing code.
read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c index 2f8159f..6da99af 100644 --- a/read-cache.c +++ b/read-cache.c @@ -210,7 +210,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) if (ce->ce_uid != (unsigned int) st->st_uid || ce->ce_gid != (unsigned int) st->st_gid) changed |= OWNER_CHANGED; - if (ce->ce_ino != (unsigned int) st->st_ino) + if (trust_inum && ce->ce_ino != (unsigned int) st->st_ino) changed |= INODE_CHANGED; #ifdef USE_STDEV