diff --git a/CHANGELOG b/CHANGELOG index 104285efcf..4a0c58b277 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,9 @@ git-annex (8.20211029) UNRELEASED; urgency=medium there are a lot of unlocked annexed files or non-annexed files, but that also makes git add of large annexed files slower. Use it by running: git config filter.annex.process 'git-annex filter-process' + * uninit: Avoid error message when no commits have been made to the + repository yet. + * uninit: Avoid error message when there is no git-annex branch. -- Joey Hess Mon, 01 Nov 2021 13:19:46 -0400 diff --git a/Command/Uninit.hs b/Command/Uninit.hs index 473040c2c4..3da4de4f9c 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010 Joey Hess + - Copyright 2010-2021 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -11,6 +11,7 @@ import Command import qualified Annex import qualified Git import qualified Git.Command +import qualified Git.Ref import qualified Command.Unannex import qualified Annex.Branch import qualified Annex.Queue @@ -30,14 +31,18 @@ cmd = addCheck check $ check :: Annex () check = do b <- current_branch - when (b == Annex.Branch.name) $ giveup $ - "cannot uninit when the " ++ Git.fromRef b ++ " branch is checked out" + when (b == Just Annex.Branch.name) $ giveup $ + "cannot uninit when the " ++ Git.fromRef Annex.Branch.name ++ " branch is checked out" top <- fromRepo Git.repoPath currdir <- liftIO R.getCurrentDirectory whenM ((/=) <$> liftIO (absPath top) <*> liftIO (absPath currdir)) $ giveup "can only run uninit from the top of the git repository" where - current_branch = Git.Ref . encodeBS . Prelude.head . lines . decodeBS <$> revhead + current_branch = + ifM (inRepo Git.Ref.headExists) + ( Just . Git.Ref . encodeBS . Prelude.head . lines . decodeBS <$> revhead + , return Nothing + ) revhead = inRepo $ Git.Command.pipeReadStrict [Param "rev-parse", Param "--abbrev-ref", Param "HEAD"] @@ -93,8 +98,9 @@ finish = do uninitialize -- avoid normal shutdown saveState False - inRepo $ Git.Command.run - [Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name] + whenM (inRepo $ Git.Ref.exists Annex.Branch.fullname) $ + inRepo $ Git.Command.run + [Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name] liftIO exitSuccess {- Turn on write bits in all remaining files in the annex directory, in diff --git a/doc/bugs/uninit_errors_out_on_repo_without_commits.mdwn b/doc/bugs/uninit_errors_out_on_repo_without_commits.mdwn index da2e78eb9f..f6296c2bce 100644 --- a/doc/bugs/uninit_errors_out_on_repo_without_commits.mdwn +++ b/doc/bugs/uninit_errors_out_on_repo_without_commits.mdwn @@ -31,3 +31,6 @@ operating system: linux x86_64 supported repository versions: 8 upgrade supported from repository versions: 0 1 2 3 4 5 6 7 ``` + +> Fixed both problems, although I don't know how a git-annex branch could +> not exist. [[done]] --[[Joey]]