diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-05 15:54:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-05 15:54:52 -0400 |
commit | 9aa10480680cfe57e9d53bf488ba1b7d8e199a2a (patch) | |
tree | b4c285c579cf746585477952a0e2e1e326a4f2e8 /Git/CheckAttr.hs | |
parent | c1e01a5ccce06745d1344b3013b91331058f4b52 (diff) |
Check git version at runtime, rather than assuming it will be the same as the git version used at build time when running git-checkattr and git-branch remove.
It's ok to probe every time for git-branch remove because that's
run quite rarely. For git-checkattr, it's run only once, when
starting the --batch mode, and so again the overhead is pretty minimal.
This leaves 2 places where the build version is still used.
git merge might be interactive or fail if one skews, and --no-gpg-sign
might not be pased, or might be passed to a git that doesn't understand it
if the other skews. It seems a little expensive to check the git version
each time these are used.
This doesn't seem likely to cause many problems, at least compared with
check-attr hanging on skew.
Diffstat (limited to 'Git/CheckAttr.hs')
-rw-r--r-- | Git/CheckAttr.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Git/CheckAttr.hs b/Git/CheckAttr.hs index 6b5e3bf62..bf46b938f 100644 --- a/Git/CheckAttr.hs +++ b/Git/CheckAttr.hs @@ -10,12 +10,12 @@ module Git.CheckAttr where import Common import Git import Git.Command -import qualified Git.BuildVersion +import qualified Git.Version import qualified Utility.CoProcess as CoProcess import System.IO.Error -type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], String) +type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], Bool, String) type Attr = String @@ -25,7 +25,8 @@ checkAttrStart :: [Attr] -> Repo -> IO CheckAttrHandle checkAttrStart attrs repo = do currdir <- getCurrentDirectory h <- CoProcess.rawMode =<< gitCoProcessStart True params repo - return (h, attrs, currdir) + oldgit <- Git.Version.older "1.7.7" + return (h, attrs, oldgit, currdir) where params = [ Param "check-attr" @@ -34,11 +35,11 @@ checkAttrStart attrs repo = do [ Param "--" ] checkAttrStop :: CheckAttrHandle -> IO () -checkAttrStop (h, _, _) = CoProcess.stop h +checkAttrStop (h, _, _, _) = CoProcess.stop h {- Gets an attribute of a file. -} checkAttr :: CheckAttrHandle -> Attr -> FilePath -> IO String -checkAttr (h, attrs, currdir) want file = do +checkAttr (h, attrs, oldgit, currdir) want file = do pairs <- CoProcess.query h send (receive "") let vals = map snd $ filter (\(attr, _) -> attr == want) pairs case vals of @@ -81,7 +82,6 @@ checkAttr (h, attrs, currdir) want file = do - With newer git, git check-attr chokes on some absolute - filenames, and the bugs that necessitated them were fixed, - so use relative filenames. -} - oldgit = Git.BuildVersion.older "1.7.7" file' | oldgit = absPathFrom currdir file | otherwise = relPathDirToFile currdir $ absPathFrom currdir file |