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.
This commit is contained in:
Joey Hess 2015-02-25 13:59:23 -04:00
parent 80aa7e3571
commit 8a3e2b302a
4 changed files with 45 additions and 5 deletions

View file

@ -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