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!
This commit is contained in:
parent
66e3d57149
commit
f353f13c9d
5 changed files with 60 additions and 30 deletions
26
Test.hs
26
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue