From c3c08a8dde43060ed1ab0078009835f89726d5bd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 25 Feb 2015 13:59:23 -0400 Subject: unannex: Refuse to unannex when repo is too new to have a HEAD In this case there must be staged changes in the index (if there is anything to unannex), and the unannex code path needs to run with a clean index. --- Command/Unannex.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Command') diff --git a/Command/Unannex.hs b/Command/Unannex.hs index 3fe4cf69c..4b803401e 100644 --- a/Command/Unannex.hs +++ b/Command/Unannex.hs @@ -53,11 +53,14 @@ wrapUnannex a = ifM isDirect , Param "--no-verify" , Param "-m", Param "content removed from git annex" ] - cleanindex = do - (diff, cleanup) <- inRepo $ DiffTree.diffIndex Git.Ref.headRef - if null diff - then void (liftIO cleanup) >> return True - else void (liftIO cleanup) >> return False + cleanindex = ifM (inRepo Git.Ref.headExists) + ( do + (diff, cleanup) <- inRepo $ DiffTree.diffIndex Git.Ref.headRef + if null diff + then void (liftIO cleanup) >> return True + else void (liftIO cleanup) >> return False + , return False + ) start :: FilePath -> Key -> CommandStart start file key = stopUnless (inAnnex key) $ do -- cgit v1.2.3