Closer emulation of git's behavior when told to use "foo/.git" as a git repository instead of just "foo". Closes: #627563

This commit is contained in:
Joey Hess 2011-05-22 14:12:16 -04:00
parent f81c1f10e6
commit 5b941980aa
3 changed files with 26 additions and 3 deletions

View file

@ -77,7 +77,7 @@ import Data.Char
import Data.Word (Word8)
import Codec.Binary.UTF8.String (encode)
import Text.Printf
import Data.List (isInfixOf, isPrefixOf)
import Data.List (isInfixOf, isPrefixOf, isSuffixOf)
import System.Exit
import Utility
@ -111,10 +111,24 @@ repoFromAbsPath dir
| "/" `isPrefixOf` dir = do
-- Git always looks for "dir.git" in preference to
-- to "dir", even if dir ends in a "/".
let dir' = (dropTrailingPathSeparator dir) ++ ".git"
let canondir = dropTrailingPathSeparator dir
let dir' = canondir ++ ".git"
e <- doesDirectoryExist dir'
return $ newFrom $ Dir $ if e then dir' else dir
if e
then ret dir'
else if "/.git" `isSuffixOf` canondir
then do
-- When dir == "foo/.git", git looks
-- for "foo/.git/.git", and failing
-- that, uses "foo" as the repository.
e' <- doesDirectoryExist $ dir </> ".git"
if e'
then ret dir
else ret $ takeDirectory canondir
else ret dir
| otherwise = error $ "internal error, " ++ dir ++ " is not absolute"
where
ret = return . newFrom . Dir
{- Remote Repo constructor. Throws exception on invalid url. -}
repoFromUrl :: String -> IO Repo

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (0.20110522) UNRELEASED; urgency=low
* Closer emulation of git's behavior when told to use "foo/.git" as a
git repository instead of just "foo". Closes: #627563
-- Joey Hess <joeyh@debian.org> Sun, 22 May 2011 14:03:42 -0400
git-annex (0.20110521) unstable; urgency=low
* status: New subcommand to show info about an annex, including its size.

View file

@ -16,3 +16,5 @@ Just tested, and the new support for bare repositories didn't solve this.
I think this is not something git-annex should go out of its way to
support. [[done]]
--[[Joey]]
Later.. Fixed this after all. --[[Joey]]