aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-17 14:40:53 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-17 14:42:06 -0400
commit49ac40c1e90a2a32a2728e36f02a0f3baa854c8b (patch)
treed094e3d761dd06b065c94f9265bc99afcce23dcc
parent323e3665c2526c6560f71efb013543dd068eb612 (diff)
unify handling of unusual GIT_INDEX_FILE relative path
This is probably a git bug that stuck in its interface.
-rw-r--r--Annex/GitOverlay.hs5
-rw-r--r--Git/Index.hs18
-rw-r--r--debian/changelog2
-rw-r--r--git-union-merge.hs2
4 files changed, 17 insertions, 10 deletions
diff --git a/Annex/GitOverlay.hs b/Annex/GitOverlay.hs
index 4796898b9..2eae5e7fe 100644
--- a/Annex/GitOverlay.hs
+++ b/Annex/GitOverlay.hs
@@ -19,10 +19,9 @@ import qualified Annex
{- Runs an action using a different git index file. -}
withIndexFile :: FilePath -> Annex a -> Annex a
withIndexFile f a = do
- -- Workaround http://thread.gmane.org/gmane.comp.version-control.git/294880
- absf <- liftIO $ absPath f
+ f' <- inRepo $ indexEnvVal f
withAltRepo
- (\g -> addGitEnv g indexEnv absf)
+ (\g -> addGitEnv g indexEnv f')
(\g g' -> g' { gitEnv = gitEnv g })
a
diff --git a/Git/Index.hs b/Git/Index.hs
index a8b1df396..8c1049e7c 100644
--- a/Git/Index.hs
+++ b/Git/Index.hs
@@ -9,11 +9,20 @@ module Git.Index where
import Common
import Git
+import Git.FilePath
import Utility.Env
indexEnv :: String
indexEnv = "GIT_INDEX_FILE"
+{- When relative, GIT_INDEX_FILE is interpreted by git as being
+ - relative to the top of the work tree of the git repository,
+ - not to the CWD. -}
+indexEnvVal :: FilePath -> Repo -> IO String
+indexEnvVal index r
+ | isAbsolute index = return index
+ | otherwise = getTopFilePath <$> toTopFilePath index r
+
{- Forces git to use the specified index file.
-
- Returns an action that will reset back to the default
@@ -21,12 +30,11 @@ indexEnv = "GIT_INDEX_FILE"
-
- Warning: Not thread safe.
-}
-override :: FilePath -> IO (IO ())
-override index = do
+override :: FilePath -> Repo -> IO (IO ())
+override index r = do
res <- getEnv var
- -- Workaround http://thread.gmane.org/gmane.comp.version-control.git/294880
- absindex <- absPath index
- setEnv var absindex True
+ val <- indexEnvVal index r
+ setEnv var val True
return $ reset res
where
var = "GIT_INDEX_FILE"
diff --git a/debian/changelog b/debian/changelog
index 1b9e27dfa..15d03b088 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,7 +15,7 @@ git-annex (6.20160512) UNRELEASED; urgency=medium
thing)
* adjust: Add --fix adjustment, which is useful when the git directory
is in a nonstandard place.
- * Work around git bug in handling of relative path to GIT_INDEX_FILE
+ * Work around git weirdness in handling of relative path to GIT_INDEX_FILE
when in a subdirectory of the repository. This affected git annex view.
* Fix crash when entering/changing view in a subdirectory of a repo that
has a dotfile in its root.
diff --git a/git-union-merge.hs b/git-union-merge.hs
index 693064045..3bf628c75 100644
--- a/git-union-merge.hs
+++ b/git-union-merge.hs
@@ -41,7 +41,7 @@ main :: IO ()
main = do
[aref, bref, newref] <- map Git.Ref <$> parseArgs
g <- Git.Config.read =<< Git.CurrentRepo.get
- _ <- Git.Index.override $ tmpIndex g
+ _ <- Git.Index.override (tmpIndex g) g
setup g
Git.UnionMerge.merge aref bref g
_ <- Git.Branch.commit Git.Branch.ManualCommit False "union merge" newref [aref, bref] g