uninit: Refuse to run in a subdirectory. Closes: #677076

This commit is contained in:
Joey Hess 2012-06-11 10:33:58 -04:00
parent 28242b3bf8
commit 7f70767bfb
2 changed files with 8 additions and 3 deletions

View file

@ -23,9 +23,13 @@ def = [addCheck check $ command "uninit" paramPaths seek
check :: Annex ()
check = do
b <- current_branch
b <- current_branch
when (b == Annex.Branch.name) $ error $
"cannot uninit when the " ++ show b ++ " branch is checked out"
top <- fromRepo Git.repoPath
cwd <- liftIO getCurrentDirectory
whenM ((/=) <$> liftIO (absPath top) <*> liftIO (absPath cwd)) $ error $
"can only run uninit from the top of the git repository"
where
current_branch = Git.Ref . Prelude.head . lines <$> revhead
revhead = inRepo $ Git.Command.pipeRead