@@ -89,11 +89,11 @@ runGit args def useIdx = do
89 ExitFailure _ -> return def
89 ExitFailure _ -> return def
90 else return def
90 else return def
92−-- | Determine where our git directory is, in case we're in a
92+-- | Determine where our @.git@ directory is, in case we're in a
93-- submodule.
93-- submodule.
94−getGitDirectory :: IO FilePath
94+getDotGit :: IO FilePath
95−getGitDirectory = do
95+getDotGit = do
96− pwd <- getCurrentDirectory
96+ pwd <- getGitRoot
97 let dotGit = pwd </> ".git"
97 let dotGit = pwd </> ".git"
98 oops = return dotGit -- it's gonna fail, that's fine
98 oops = return dotGit -- it's gonna fail, that's fine
99 isDir <- doesDirectoryExist dotGit
99 isDir <- doesDirectoryExist dotGit
@@ -109,6 +109,16 @@ getGitDirectory = do
109 else oops
109 else oops
110 _ -> oops
110 _ -> oops
112+-- | Get the root directory of the Git repo.
113+getGitRoot :: IO FilePath
115+ pwd <- getCurrentDirectory
117+ readProcessWithExitCode "git" ["rev-parse", "--show-toplevel"] ""
119+ ExitSuccess -> return $ takeWhile (/= '\n') out
120+ ExitFailure _ -> return pwd -- later steps will fail, that's fine
112-- | Type to flag if the git index is used or not in a call to runGit
122-- | Type to flag if the git index is used or not in a call to runGit
113data IndexUsed = IdxUsed -- ^ The git index is used
123data IndexUsed = IdxUsed -- ^ The git index is used
114 | IdxNotUsed -- ^ The git index is /not/ used
124 | IdxNotUsed -- ^ The git index is /not/ used