Merge pull request #4289 from bk2204/graceful-pointer-failures

pull: gracefully handle merge conflicts
This commit is contained in:
brian m. carlson 2020-10-26 08:06:12 -07:00 committed by GitHub
commit d303bf5b76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

@ -67,7 +67,7 @@ func (c *singleCheckout) Run(p *lfs.WrappedPointer) {
// Check the content - either missing or still this pointer (not exist is ok) // Check the content - either missing or still this pointer (not exist is ok)
filepointer, err := lfs.DecodePointerFromFile(cwdfilepath) filepointer, err := lfs.DecodePointerFromFile(cwdfilepath)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
if errors.IsNotAPointerError(err) { if errors.IsNotAPointerError(err) || errors.IsBadPointerKeyError(err) {
// File has non-pointer content, leave it alone // File has non-pointer content, leave it alone
return return
} }

@ -284,6 +284,36 @@ begin_test "pull with invalid insteadof"
) )
end_test end_test
begin_test "pull with merge conflict"
(
set -e
git init pull-merge-conflict
cd pull-merge-conflict
git lfs track "*.bin"
git add .
git commit -m 'gitattributes'
printf abc > abc.bin
git add .
git commit -m 'abc'
git checkout -b def
printf def > abc.bin
git add .
git commit -m 'def'
git checkout main
printf ghi > abc.bin
git add .
git commit -m 'ghi'
# This will exit nonzero because of the merge conflict.
GIT_LFS_SKIP_SMUDGE=1 git merge def || true
git lfs pull > pull.log 2>&1
[ ! -s pull.log ]
)
end_test
begin_test "pull: with missing object" begin_test "pull: with missing object"
( (
set -e set -e