Skip to content

Commit

Permalink
locking: remove write permission for ignored files
Browse files Browse the repository at this point in the history
When a file exists in a user's working copy that has been previously
marked as lockable and has since become ignored, the file's write
permission would no longer be managed by Git LFS.

Since 'git lfs lock' corresponds to pathname only (and thus is not
affected by Git-specific concepts such as .gitignore), let's continue to
manage those files' write permissions by using tools.FastWalkGitRepoAll
instead of tools.FastWalkGitRepo.
  • Loading branch information
ttaylorr committed Aug 20, 2018
1 parent 6da0c45 commit a727fea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion locking/lockable.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (c *Client) fixFileWriteFlags(absPath, workingDir string, lockable, unlocka
errs = append(errs, err)
}

tools.FastWalkGitRepo(absPath, func(parentDir string, fi os.FileInfo, err error) {
tools.FastWalkGitRepoAll(absPath, func(parentDir string, fi os.FileInfo, err error) {
if err != nil {
addErr(err)
return
Expand Down
24 changes: 24 additions & 0 deletions t/t-lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,27 @@ begin_test "creating a lock (symlinked working directory)"
popd > /dev/null
)
end_test

begin_test "lock with .gitignore"
(
set -e

reponame="lock-with-gitignore"
setup_remote_repo_with_file "$reponame" "a.txt"
clone_repo "$reponame" "$reponame"

echo "*.txt filter=lfs diff=lfs merge=lfs -text lockable" > .gitattributes

git add .gitattributes
git commit -m ".gitattributes: mark 'a.txt' as lockable"

rm -f a.txt && git checkout a.txt
refute_file_writeable a.txt

echo "*.txt" > .gitignore
git add .gitignore
git commit -m ".gitignore: ignore 'a.txt'"
rm -f a.txt && git checkout a.txt
refute_file_writeable a.txt
)
end_test

0 comments on commit a727fea

Please sign in to comment.