summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-06 16:01:52 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-06 16:01:52 -0400
commitbf0069b0df73eb9e9c8c508c45eaf7d6f90b5deb (patch)
tree965e24c8e687629a9fc8295ef4356e9f174b7ee1
parent82a27da0157ce3fc78ab917b6d9d26486ed7bb8c (diff)
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.
-rw-r--r--Command/Lock.hs2
-rw-r--r--Test.hs6
2 files changed, 5 insertions, 3 deletions
diff --git a/Command/Lock.hs b/Command/Lock.hs
index 8b36e1cee..4e42a8d76 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -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)
diff --git a/Test.hs b/Test.hs
index fdb1404cb..5646f14e1 100644
--- a/Test.hs
+++ b/Test.hs
@@ -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