aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-22 14:12:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-22 14:12:16 -0400
commit5b941980aa47ced29f702e2cc84346d517b78391 (patch)
treed5131bd216b24d15a3e0ad865d558baed8aa515d
parentf81c1f10e6ce452636eb06209c3702d2da05c49f (diff)
Closer emulation of git's behavior when told to use "foo/.git" as a git repository instead of just "foo". Closes: #627563
-rw-r--r--GitRepo.hs20
-rw-r--r--debian/changelog7
-rw-r--r--doc/bugs/weird_local_clone_confuses.mdwn2
3 files changed, 26 insertions, 3 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index f489dfe35..24bc9b5c2 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index cf1c9baf9..76495c901 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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.
diff --git a/doc/bugs/weird_local_clone_confuses.mdwn b/doc/bugs/weird_local_clone_confuses.mdwn
index 371f6d9a5..aa838f167 100644
--- a/doc/bugs/weird_local_clone_confuses.mdwn
+++ b/doc/bugs/weird_local_clone_confuses.mdwn
@@ -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]]