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.
This commit is contained in:
parent
7e558371ab
commit
adc5ca70a8
6 changed files with 59 additions and 8 deletions
9
Test.hs
9
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue