git-remote-annex: Fix error display on clone
cleanupInitialization gets run when an exception is thrown, so needs to avoid throwing exceptions itself, as that would hide the error message that the user needs to see.
This commit is contained in:
parent
a766475d14
commit
0975e792ea
2 changed files with 15 additions and 11 deletions
|
@ -1078,14 +1078,25 @@ specialRemoteFromUrl sab a = withTmpDir "journal" $ \tmpdir -> do
|
|||
-- hooks, have to work around that by not initializing, and
|
||||
-- delete the git bundle objects.
|
||||
cleanupInitialization :: StartAnnexBranch -> Annex ()
|
||||
cleanupInitialization sab = do
|
||||
cleanupInitialization sab = void $ tryNonAsync $ do
|
||||
case sab of
|
||||
AnnexBranchExistedAlready _ -> noop
|
||||
AnnexBranchCreatedEmpty r ->
|
||||
AnnexBranchCreatedEmpty r ->
|
||||
whenM ((r ==) <$> Annex.Branch.getBranch) $ do
|
||||
inRepo $ Git.Branch.delete Annex.Branch.fullname
|
||||
indexfile <- fromRepo gitAnnexIndex
|
||||
liftIO $ removeWhenExistsWith R.removeLink indexfile
|
||||
-- When cloning failed and this is being
|
||||
-- run as an exception is thrown, HEAD will
|
||||
-- not be set to a valid value, which will
|
||||
-- prevent deleting the git-annex branch.
|
||||
-- But that's ok, git will delete the
|
||||
-- repository it failed to clone into.
|
||||
-- So skip deleting to avoid an ugly
|
||||
-- message.
|
||||
inRepo Git.Branch.currentUnsafe >>= \case
|
||||
Nothing -> return ()
|
||||
Just _ -> void $ tryNonAsync $
|
||||
inRepo $ Git.Branch.delete Annex.Branch.fullname
|
||||
ifM (Annex.Branch.hasSibling <&&> nonbuggygitversion)
|
||||
( do
|
||||
autoInitialize' (pure True) remoteList
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue