Catch up with current git behavior when both repo and repo.git exist; it seems it now prefers repo in this case, although historically it may have preferred repo.git.

This commit is contained in:
Joey Hess 2015-10-26 15:35:55 -04:00
parent 6e7eddb5d6
commit ef5496b8de
Failed to extract signature
2 changed files with 14 additions and 6 deletions

View file

@ -58,24 +58,29 @@ fromPath dir = fromAbsPath =<< absPath dir
- specified. -} - specified. -}
fromAbsPath :: FilePath -> IO Repo fromAbsPath :: FilePath -> IO Repo
fromAbsPath dir fromAbsPath dir
| absoluteGitPath dir = ifM (doesDirectoryExist dir') ( ret dir' , hunt ) | absoluteGitPath dir = hunt
| otherwise = | otherwise =
error $ "internal error, " ++ dir ++ " is not absolute" error $ "internal error, " ++ dir ++ " is not absolute"
where where
ret = pure . newFrom . LocalUnknown ret = pure . newFrom . LocalUnknown
{- Git always looks for "dir.git" in preference to
- to "dir", even if dir ends in a "/". -}
canondir = dropTrailingPathSeparator dir canondir = dropTrailingPathSeparator dir
dir' = canondir ++ ".git"
{- When dir == "foo/.git", git looks for "foo/.git/.git", {- When dir == "foo/.git", git looks for "foo/.git/.git",
- and failing that, uses "foo" as the repository. -} - and failing that, uses "foo" as the repository. -}
hunt hunt
| (pathSeparator:".git") `isSuffixOf` canondir = | (pathSeparator:".git") `isSuffixOf` canondir =
ifM (doesDirectoryExist $ dir </> ".git") ifM (doesDirectoryExist $ dir </> ".git")
( ret dir ( ret dir
, ret $ takeDirectory canondir , ret (takeDirectory canondir)
) )
| otherwise = ret dir | otherwise = ifM (doesDirectoryExist dir)
( ret dir
-- git falls back to dir.git when dir doesn't
-- exist, as long as dir didn't end with a
-- path separator
, if dir == canondir
then ret (dir ++ ".git")
else ret dir
)
{- Remote Repo constructor. Throws exception on invalid url. {- Remote Repo constructor. Throws exception on invalid url.
- -

3
debian/changelog vendored
View file

@ -6,6 +6,9 @@ git-annex (5.20151020) UNRELEASED; urgency=medium
* enableremote: List uuids and descriptions of remotes that can be * enableremote: List uuids and descriptions of remotes that can be
enabled, and accept either the uuid or the description in leu if the enabled, and accept either the uuid or the description in leu if the
name. name.
* Catch up with current git behavior when both repo and repo.git exist;
it seems it now prefers repo in this case, although historically it may
have preferred repo.git.
-- Joey Hess <id@joeyh.name> Mon, 19 Oct 2015 17:00:21 -0400 -- Joey Hess <id@joeyh.name> Mon, 19 Oct 2015 17:00:21 -0400