summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-11-10 15:36:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-11-10 15:36:24 -0400
commitf00d0f9917cd605f27e29ab5d4cfcfc08bdcb3c2 (patch)
treee6d77b4cf8e5059c2ce01fa17ce70f2fa7d6a990 /Test.hs
parentbf19671a7448479811eb441cdb8a526bbe2b6625 (diff)
pre-commit: Block partial commit of unlocked annexed file, since that left a typechange staged in index
I had hoped that the git devs could change git's handling of partial commits to not use a false index file, but seems not. So, this relies on some git internals to detect that case. The test suite has a test case added to catch it if changes to git break it. This commit was sponsored by Paul Tagliamonte.
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Test.hs b/Test.hs
index a0c56a3ab..dd7a45f47 100644
--- a/Test.hs
+++ b/Test.hs
@@ -194,6 +194,7 @@ unitTests note gettestenv = testGroup ("Unit Tests " ++ note)
, check "lock" test_lock
, check "edit (no pre-commit)" test_edit
, check "edit (pre-commit)" test_edit_precommit
+ , check "partial commit" test_partial_commit
, check "fix" test_fix
, check "trust" test_trust
, check "fsck (basics)" test_fsck_basic
@@ -502,6 +503,14 @@ test_edit' precommit testenv = intmpclonerepoInDirect testenv $ do
assertEqual "content of modified file" c (changedcontent annexedfile)
not <$> git_annex testenv "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of modified file"
+test_partial_commit :: TestEnv -> Assertion
+test_partial_commit testenv = intmpclonerepoInDirect testenv $ do
+ git_annex testenv "get" [annexedfile] @? "get of file failed"
+ annexed_present annexedfile
+ git_annex testenv "unlock" [annexedfile] @? "unlock failed"
+ not <$> boolSystem "git" [Params "commit -q -m test", File annexedfile]
+ @? "partial commit of unlocked file not blocked by pre-commit hook"
+
test_fix :: TestEnv -> Assertion
test_fix testenv = intmpclonerepoInDirect testenv $ do
annexed_notpresent annexedfile