diff options
author | Joey Hess <joey@kitenet.net> | 2011-10-27 15:47:11 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-10-27 15:47:11 -0400 |
commit | 66194684acaf8dc5c72e5a163465b42050cf9212 (patch) | |
tree | a29e4f6a678036e34ff85117887301c9b4f79353 | |
parent | 83d11c03c44779c000759040eca8797e70e4765c (diff) |
uninit: Add guard against being run with the git-annex branch checked out.
-rw-r--r-- | Command/Uninit.hs | 17 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/bugs/uninit_should_not_run_when_branch_git-annex_is_checked_out.mdwn | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs index 7b3b4fe32..8214c4208 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -7,6 +7,8 @@ module Command.Uninit where +import qualified Data.ByteString.Lazy.Char8 as B + import Common.Annex import Command import qualified Git @@ -21,7 +23,20 @@ command = [repoCommand "uninit" paramPaths seek "de-initialize git-annex and clean out repository"] seek :: [CommandSeek] -seek = [withFilesInGit startUnannex, withNothing start] +seek = [withNothing startCheck, withFilesInGit startUnannex, withNothing start] + +startCheck :: CommandStart +startCheck = do + b <- current_branch + when (b == Annex.Branch.name) $ error $ + "cannot uninit when the " ++ b ++ " branch is checked out" + stop + where + current_branch = do + g <- gitRepo + b <- liftIO $ + Git.pipeRead g [Params "rev-parse --abbrev-ref HEAD"] + return $ head $ lines $ B.unpack b startUnannex :: FilePath -> CommandStart startUnannex file = do diff --git a/debian/changelog b/debian/changelog index e177298da..dd72fc296 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ git-annex (3.20111026) UNRELEASED; urgency=low * Sped up some operations on remotes that are on the same host. * copy --to: Fixed leak when copying many files to a remote on the same host. + * uninit: Add guard against being run with the git-annex branch checked out. -- Joey Hess <joeyh@debian.org> Thu, 27 Oct 2011 13:58:53 -0400 diff --git a/doc/bugs/uninit_should_not_run_when_branch_git-annex_is_checked_out.mdwn b/doc/bugs/uninit_should_not_run_when_branch_git-annex_is_checked_out.mdwn index d14021936..e4e407ec8 100644 --- a/doc/bugs/uninit_should_not_run_when_branch_git-annex_is_checked_out.mdwn +++ b/doc/bugs/uninit_should_not_run_when_branch_git-annex_is_checked_out.mdwn @@ -11,3 +11,5 @@ Both of which is logical. The best thing would be if git-annex refused to run un Richard + +> [[done]] --[[Joey]] |