src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.91k stars 541 forks source link

Make first commit on repository that contain unreadable files lead to "Premission denied" error #1212

Open Nolaireon opened 4 years ago

Nolaireon commented 4 years ago

1) I have a repository that may contain an unreadable files. 2) User that perform go-git commit do not have write permission on that repository(git directory should be created outside of worktree).

First of all I have removed createDotGitFile from setWorktreeAndStoragePaths which is the part of Init action of repository.go file. That is how I have avoided error that occure when user don't have write permission in worktree.

Since I know that repository may contain unreadable files, before committing I walk recursivelly through worktree and collect all unreadables and large files or symlinks to avoid adding them.

Once all accessible files were added i call Commit function and got error "open /path/to/unreadable/file: permission denied". I have added some debug to determine where exactly error appear.

image

image

Nolaireon commented 4 years ago

22 days have passed and not a single answer, please explain, is this behavior correct in terms of compatibility with git? PS. I can always add file through "git add" even if there are unreadable files in the working directory