Avoid cross-directory renames and linking on object creation
commit5723fe7e3cbbefae78bfb79c46b7716eef76fe52
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Jun 2008 17:50:12 +0000 (14 10:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 14 Jun 2008 21:39:22 +0000 (14 14:39 -0700)
tree1d3eb8d8bbba8e7ce9a800c4820dee0e4e9e45b4
parent9adefee5b5811c57c30cf81804127b59b235538a
Avoid cross-directory renames and linking on object creation

Instead of creating new temporary objects in the top-level git object
directory, create them in the same directory they will finally end up in
anyway.  This avoids making the final atomic "rename to stable name"
operation be a cross-directory event, which makes it a lot easier for
various filesystems.

Several filesystems do things like change the inode number when moving
files across directories (or refuse to do it entirely).

In particular, it can also cause problems for NFS implementations that
change the filehandle of a file when it moves to a different directory,
like the old user-space NFS server did, and like the Linux knfsd still
does if you don't export your filesystems with 'no_subtree_check' or if
you export a filesystem that doesn't have stable inode numbers across
renames).

This change also obviously implies creating the object fan-out
subdirectory at tempfile creation time, rather than at the final
move_temp_to_file() time.  Which actually accounts for most of the size
of the patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c