Unix executables changed to regular files upon clone in Windows #373
Description
A Windows clone of a repository that contains Unix executables results in executable file permission change in the change set to regular directly upon clone. I guess the reason lies somewhere in func (w *Worktree) checkoutChangeRegularFile(...) error
due to the fact that filemode.NewFromOSFileMode(fi.Mode())
in func (w *Worktree) addIndexFromFile(name string, h plumbing.Hash, idx *index.Index) error
delivers on Windows regular
for anything that is actually executable on Unix.
Version used: master
Here is the behaviour that I observed. First, here is a clone with the default git client. The clone causes no file permission change:
D:\Downloads>git.exe clone git@gitserver:xentis/java std-client
Cloning into 'std-client'...
remote: Counting objects: 36, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 36 (delta 8), reused 0 (delta 0)
Receiving objects: 100% (36/36), 64.00 KiB | 0 bytes/s, done.
Resolving deltas: 100% (8/8), done.
D:\Downloads>cd std-client
D:\Downloads\std-client>git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Next, the same clone with the following go-git code:
repo, err := git.PlainClone(dir, false, &git.CloneOptions{
RemoteName: remote,
URL: url,
Auth: auth,
})
Triggers permission change upon clone:
D:\Downloads>gitc.exe clone git@gitserver:xentis/java go-git-client
�[K⠸ cloning...
And checking the status with the default git client:
D:\Downloads>cd go-git-client
D:\Downloads\go-git-client>git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: gradlew
modified: populate.sh
Now checking what are the differences:
D:\Downloads\go-git-client>git reset HEAD .
Unstaged changes after reset:
M gradlew
M populate.sh
D:\Downloads\go-git-client>git diff
diff --git a/gradlew b/gradlew
old mode 100755
new mode 100644
diff --git a/populate.sh b/populate.sh
old mode 100755
new mode 100644