Additional GIT_DIR support bugfixes. May actually work now.

Two fixes. First, and most importantly, relax the isLinkToAnnex check
to only look for /annex/objects/, not [^|/].git/annex/objects. If
GIT_DIR is used with a detached work tree, the git directory is
not necessarily named .git.

There are important caveats with doing that at all, since git-annex will
make symlinks that point at GIT_DIR, which means that the relative path
between GIT_DIR and GIT_WORK_TREE needs to remain stable across all clones
of the repository.

----

The other fix is just fixing crazy and wrong code that, when GIT_DIR is
set, expects to still find a git repository in the path below the work
tree, and uses some of its configuration, and some of GIT_DIR. What was I
thinking, and why can't I seem to get this code right?
This commit is contained in:
Joey Hess 2013-02-23 12:32:09 -04:00
parent acc3c8c157
commit 8d9c2afd89
4 changed files with 24 additions and 20 deletions

View file

@ -17,6 +17,7 @@ module Git.Construct (
fromRemotes,
fromRemoteLocation,
repoAbsPath,
newFrom,
) where
import System.Posix.User
@ -31,17 +32,16 @@ import Utility.UserInfo
{- Finds the git repository used for the cwd, which may be in a parent
- directory. -}
fromCwd :: IO Repo
fromCwd = getCurrentDirectory >>= seekUp checkForRepo
fromCwd :: IO (Maybe Repo)
fromCwd = getCurrentDirectory >>= seekUp
where
norepo = error "Not in a git repository."
seekUp check dir = do
r <- check dir
seekUp dir = do
r <- checkForRepo dir
case r of
Nothing -> case parentDir dir of
"" -> norepo
d -> seekUp check d
Just loc -> newFrom loc
"" -> return Nothing
d -> seekUp d
Just loc -> Just <$> newFrom loc
{- Local Repo constructor, accepts a relative or absolute path. -}
fromPath :: FilePath -> IO Repo