uninit edge cases
* 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. Sponsored-by: Svenne Krap on Patreon
This commit is contained in:
parent
9cb02ca29e
commit
9d3ce224e3
3 changed files with 18 additions and 6 deletions
|
@ -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 <id@joeyh.name> Mon, 01 Nov 2021 13:19:46 -0400
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2010 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- 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,6 +98,7 @@ finish = do
|
|||
uninitialize
|
||||
-- avoid normal shutdown
|
||||
saveState False
|
||||
whenM (inRepo $ Git.Ref.exists Annex.Branch.fullname) $
|
||||
inRepo $ Git.Command.run
|
||||
[Param "branch", Param "-D", Param $ Git.fromRef Annex.Branch.name]
|
||||
liftIO exitSuccess
|
||||
|
|
|
@ -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]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue