Re: Bug#569505: git-core: 'git add' corrupts repository if the working directory is modified as it runs
- From
- Zygo Blaxell <zblaxell@gibbs.hungrycats.org>
- Date
- Feb 12, 2010, 01:23 UTC
- Message-ID
- <20100212012314.GC24809@gibbs.hungrycats.org>
- In-Reply-To
- <20100212002741.GB9883@progeny.tock>
On Thu, Feb 11, 2010 at 06:27:41PM -0600, Jonathan Nieder wrote:
Show 9 quoted lines
> Zygo Blaxell reported through http://bugs.debian.org/569505 that ???git > update-index??? has some issues when the files it is adding change under > its feet: > > My thoughts: > > - Low-hanging fruit: it should be possible for update-index to check > the stat information to see if the file has changed between when it > first opens it and when it finishes.
I don't think this is a good idea. stat() is very coarse-grained, and provides accuracy of only a second on a lot of file systems where git working directories might be found. If you run the test script on an ext3 filesystem on a modern machine the stat() data won't change at all even though the file contents change completely many times.
What would be a good idea is to make sure that the code that copies a file into the index and calculates its hash does both in a single pass over the same input data. That might require replacing a simple mmap() of the input file with a read-hash-copy loop.