From 7f70767bfb2ada474274c1dfad0e1a6d60955402 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Jun 2012 10:33:58 -0400 Subject: uninit: Refuse to run in a subdirectory. Closes: #677076 --- Command/Uninit.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Command') diff --git a/Command/Uninit.hs b/Command/Uninit.hs index d6283a77d..5724bffd0 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -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 -- cgit v1.2.3