summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-08 14:24:00 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-08 14:24:00 -0400
commitfdfd56c647d685ad5618917341db0b7c97e1b63a (patch)
treea287e49f51af48f27a23711abb346134c218977d
parent6f4b9f2df58684d4b8e2099be59283be97f1318e (diff)
avoid withWorkTreeRelated affecting annex symlink calculation
-rw-r--r--Annex/GitOverlay.hs12
-rw-r--r--Git/Command.hs6
-rw-r--r--Git/Construct.hs1
-rw-r--r--Git/Types.hs1
-rw-r--r--doc/design/adjusted_branches.mdwn2
5 files changed, 13 insertions, 9 deletions
diff --git a/Annex/GitOverlay.hs b/Annex/GitOverlay.hs
index 4230ed4a4..7e18d225b 100644
--- a/Annex/GitOverlay.hs
+++ b/Annex/GitOverlay.hs
@@ -45,11 +45,13 @@ withWorkTreeRelated :: FilePath -> Annex a -> Annex a
withWorkTreeRelated d = withAltRepo modrepo unmodrepo
where
modrepo g = do
- let g' = g { location = modlocation (location g) }
- addGitEnv g' "GIT_COMMON_DIR" =<< absPath (localGitDir g)
- unmodrepo g g' = g' { gitEnv = gitEnv g, location = location g }
- modlocation l@(Local {}) = l { gitdir = d }
- modlocation _ = error "withWorkTreeRelated of non-local git repo"
+ g' <- addGitEnv g "GIT_COMMON_DIR" =<< absPath (localGitDir g)
+ g'' <- addGitEnv g' "GIT_DIR" d
+ return (g'' { gitEnvOverridesGitDir = True })
+ unmodrepo g g' = g'
+ { gitEnv = gitEnv g
+ , gitEnvOverridesGitDir = gitEnvOverridesGitDir g
+ }
withAltRepo
:: (Repo -> IO Repo)
diff --git a/Git/Command.hs b/Git/Command.hs
index 02e3e5a34..206056368 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -17,9 +17,11 @@ import qualified Utility.CoProcess as CoProcess
{- Constructs a git command line operating on the specified repo. -}
gitCommandLine :: [CommandParam] -> Repo -> [CommandParam]
gitCommandLine params r@(Repo { location = l@(Local { } ) }) =
- setdir : settree ++ gitGlobalOpts r ++ params
+ setdir ++ settree ++ gitGlobalOpts r ++ params
where
- setdir = Param $ "--git-dir=" ++ gitdir l
+ setdir
+ | gitEnvOverridesGitDir r = []
+ | otherwise = [Param $ "--git-dir=" ++ gitdir l]
settree = case worktree l of
Nothing -> []
Just t -> [Param $ "--work-tree=" ++ t]
diff --git a/Git/Construct.hs b/Git/Construct.hs
index 03dd29f41..765562212 100644
--- a/Git/Construct.hs
+++ b/Git/Construct.hs
@@ -236,6 +236,7 @@ newFrom l = Repo
, remotes = []
, remoteName = Nothing
, gitEnv = Nothing
+ , gitEnvOverridesGitDir = False
, gitGlobalOpts = []
}
diff --git a/Git/Types.hs b/Git/Types.hs
index 44135738d..327c1d722 100644
--- a/Git/Types.hs
+++ b/Git/Types.hs
@@ -39,6 +39,7 @@ data Repo = Repo
, remoteName :: Maybe RemoteName
-- alternate environment to use when running git commands
, gitEnv :: Maybe [(String, String)]
+ , gitEnvOverridesGitDir :: Bool
-- global options to pass to git when running git commands
, gitGlobalOpts :: [CommandParam]
} deriving (Show, Eq, Ord)
diff --git a/doc/design/adjusted_branches.mdwn b/doc/design/adjusted_branches.mdwn
index 2b2e37a27..e94439d66 100644
--- a/doc/design/adjusted_branches.mdwn
+++ b/doc/design/adjusted_branches.mdwn
@@ -286,5 +286,3 @@ into adjusted view worktrees.]
have already been handled by updateAdjustedBranch. But, if another remote
pushed a new master at just the right time, the adjusted branch could be
rebased on top of a master that it doesn't incorporate, which is wrong.
-* Annex symlinks generated in merging into an adjusted branch are badly
- formed to point to the temp git dir's annex object dir.