fix test failure locking an unlocked not present file

In v5, that was not possible, but it is in v6, and so the test was failing.

Investigating, it turns out that locking was copying the pointer file
content to the annex object despite the content not being present. So,
add a check to prevent that.
This commit is contained in:
Joey Hess 2016-01-06 16:01:52 -04:00
parent d667a68b7e
commit 0c1cc7789f
Failed to extract signature
2 changed files with 5 additions and 3 deletions

View file

@ -46,7 +46,7 @@ startNew file key = ifM (isJust <$> isAnnexLink file)
)
where
go (Just key')
| key' == key = cont False
| key' == key = error "content not present; cannot lock"
| otherwise = errorModified
go Nothing =
ifM (isUnmodified key file)

View file

@ -546,9 +546,11 @@ test_preferred_content = intmpclonerepo $ do
test_lock :: Assertion
test_lock = intmpclonerepoInDirect $ do
-- regression test: unlock of not present file should skip it
annexed_notpresent annexedfile
not <$> git_annex "unlock" [annexedfile] @? "unlock failed to fail with not present file"
ifM (unlockedFiles <$> getTestMode)
( not <$> git_annex "lock" [annexedfile] @? "lock failed to fail with not present file"
, not <$> git_annex "unlock" [annexedfile] @? "unlock failed to fail with not present file"
)
annexed_notpresent annexedfile
-- regression test: unlock of newly added, not committed file