summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-22 17:06:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-22 17:28:53 -0400
commit75760de1adfd5772d2b4d9dc744798ed31f727f9 (patch)
treec06b9fe0539ccf74e79b16911ab43f7d71b824c4 /Test.hs
parent0f3462afc04dbbb575e36434c8dd5733061fd6fd (diff)
Support unannex and uninit in direct mode.
In direct mode, it's best to whenever possible not move direct mode files out of the way, and so I made unannex avoid touching the direct mode file at all. That actually turns out to be easy, because in direct mode, unlike indirect mode, the pre-commit hook won't get confused if the unannexed file later gets added back by git add. So there's no need to commit the unannex right away; it can be staged for the user to commit later. This also means that unannex in direct mode is a lot faster than in indirect mode! Another subtle bit is the bookkeeping that is done when unannexing a direct mode file. The inode cache needs to be removed so that when uninit runs getKeysPresent, it doesn't see the cache and think the key is still present and crash when it's not. This commit is sponsored by Douglas Butts. Thanks!
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs26
1 files changed, 14 insertions, 12 deletions
diff --git a/Test.hs b/Test.hs
index eab81cc0a..c45b0d360 100644
--- a/Test.hs
+++ b/Test.hs
@@ -243,11 +243,11 @@ test_reinject env = "git-annex reinject/fromkey" ~: TestCase $ intmpclonerepoInD
test_unannex :: TestEnv -> Test
test_unannex env = "git-annex unannex" ~: TestList [nocopy, withcopy]
where
- nocopy = "no content" ~: intmpclonerepoInDirect env $ do
+ nocopy = "no content" ~: intmpclonerepo env $ do
annexed_notpresent annexedfile
git_annex env "unannex" [annexedfile] @? "unannex failed with no copy"
annexed_notpresent annexedfile
- withcopy = "with content" ~: intmpclonerepoInDirect env $ do
+ withcopy = "with content" ~: intmpclonerepo env $ do
git_annex env "get" [annexedfile] @? "get failed"
annexed_present annexedfile
git_annex env "unannex" [annexedfile, sha1annexedfile] @? "unannex failed"
@@ -734,16 +734,18 @@ test_map env = "git-annex map" ~: intmpclonerepo env $ do
git_annex env "map" ["--fast"] @? "map failed"
test_uninit :: TestEnv -> Test
-test_uninit env = "git-annex uninit" ~: intmpclonerepoInDirect env $ do
- git_annex env "get" [] @? "get failed"
- annexed_present annexedfile
- boolSystem "git" [Params "checkout git-annex"] @? "git checkout git-annex"
- not <$> git_annex env "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
- boolSystem "git" [Params "checkout master"] @? "git checkout master"
- _ <- git_annex env "uninit" [] -- exit status not checked; does abnormal exit
- checkregularfile annexedfile
- doesDirectoryExist ".git" @? ".git vanished in uninit"
- not <$> doesDirectoryExist ".git/annex" @? ".git/annex still present after uninit"
+test_uninit env = "git-annex uninit" ~: TestList [inbranch, normal]
+ where
+ inbranch = "in branch" ~: intmpclonerepoInDirect env $ do
+ boolSystem "git" [Params "checkout git-annex"] @? "git checkout git-annex"
+ not <$> git_annex env "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
+ normal = "normal" ~: intmpclonerepo env $ do
+ git_annex env "get" [] @? "get failed"
+ annexed_present annexedfile
+ _ <- git_annex env "uninit" [] -- exit status not checked; does abnormal exit
+ checkregularfile annexedfile
+ doesDirectoryExist ".git" @? ".git vanished in uninit"
+ not <$> doesDirectoryExist ".git/annex" @? ".git/annex still present after uninit"
test_upgrade :: TestEnv -> Test
test_upgrade env = "git-annex upgrade" ~: intmpclonerepo env $ do