git-commit: Implement racy-safe save_index() with ln instead of cp -p.
commita64e23954fc617019354a929dcefaa6049c2f744
authorJohannes Sixt <johannes.sixt@telecom.at>
Fri, 21 Sep 2007 19:31:51 +0000 (21 21:31 +0200)
committerJohannes Sixt <johannes.sixt@telecom.at>
Fri, 21 Sep 2007 19:36:16 +0000 (21 21:36 +0200)
tree24a99cd24d51c60c1a6b706a0aa58ea110420686
parentb49fa05b92a7a369beca1de67fded5a6da500f9c
git-commit: Implement racy-safe save_index() with ln instead of cp -p.

git-commit must allocate a copy of the current index if only a subset of
files is to be commited in save_index(). It uses 'cp -p' because the index
may contain racily-clean entries, which will be detected only if the
timestamp of the index remains unaltered.

In general, it is safe to create a hardlink instead of copying the index
because all writers use the lock_file infrastructure that writes a new
file and moves it into the destination, breaking the hardlink.

On Windows, in particular, 'cp -p' suffers from a mysterious inability to
accurately preserve the timestamp under some circumstances. (This was
detected by the test suite, where some racily clean files were not
recognized.) 'ln' does create a hardlink on Windows on NTFS, and makes
a copy with the correctly preserved timestamp on FAT.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
git-commit.sh