diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-02-25 13:59:23 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-02-25 13:59:23 -0400 |
commit | c3c08a8dde43060ed1ab0078009835f89726d5bd (patch) | |
tree | 85c037cde4a6833d80d2dccaaa3fe81da5b2bc96 /Command | |
parent | 05ba1ecbf5064a3e55590ae00a11cd71350a99f3 (diff) |
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.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Unannex.hs | 13 |
1 files changed, 8 insertions, 5 deletions
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 |