link vs rename (unable to write sha1 filename .git/objects/...: Permission denied)

627 views
Skip to first unread message

Niels Möller

unread,
May 15, 2012, 4:14:55 AM5/15/12
to msy...@googlegroups.com
I've just installed git version 1.7.10.msysgit.1 on a windows XP
machine.

The following works fine on local disk (/c):

cd /c/tmp
mkdir git-test
cd git-test
git init
echo foo > foo
git add foo

But if I do the same thing in a directory mounted from a samba server (not sure which
version), the git add fails with

error:unable to write sha1 filename .git/objects/25/7cc...e99: Permission denied

Manually creating files in the related directories works fine. On the
server, permission bits are 0744 on files and 0755 on directories. So I
think I do have the needed permissions.

The discussions on
http://stackoverflow.com/questions/6551441/git-error-unable-to-write-sha1-filename-permission-denied
and
http://stackoverflow.com/questions/3829498/git-over-samba-unable-to-write-sha1-filename-permission-denied/6777323#6777323
seem related, but from that it's not clear to me if it's a git bug, a
samba bug, or some more fundamental incompatibility on how filesystems
are supposed to work.

After some reading of the source code, sha1_file.c:move_temp_to_file, I
tried setting

git config --global --add core.createobject link

and that seems to have solved the problem.

My best guess is that link(2) works fine with msys, windows and samba
(at least in this case, where src and destination are in the same
directory, as arranged by sha1_file:create_tmpfile), while rename(2) for
some reason doesn't work at all.

So I think it would make some sense to change the default behaviour. If
I interpret the comments in Makefile correctly, it claims that using
link is dangerous because it can trigger some data corruption bugs on
ntfs, is that still the case?

# Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
# when hardlinking a file to another name and unlinking the original file right
# away (some NTFS drivers seem to zero the contents in that scenario).

Regards,
/Niels

--
Niels M�ller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

Reply all
Reply to author
Forward
0 new messages