Work around bug in git 2.13.0 involving GIT_COMMON_DIR that broke merging changes into adjusted branches.

Might want to remove this when it gets fixed, in case adjusted branches are
used in a repo with a great many refs, which would become unnecessarily
slow.

This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
Joey Hess 2017-05-16 14:35:37 -04:00
parent e858c959f7
commit 9bcaef1ec4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 17 additions and 0 deletions

View file

@ -51,6 +51,7 @@ import Annex.Content
import Annex.Perms
import Annex.GitOverlay
import Utility.Tmp
import Utility.CopyFile
import qualified Database.Keys
import Config
@ -355,9 +356,23 @@ updateAdjustedBranch tomerge (origbranch, adj) mergeconfig commitmode = catchBoo
misctmpdir <- fromRepo gitAnnexTmpMiscDir
void $ createAnnexDirectory misctmpdir
tmpwt <- fromRepo gitAnnexMergeDir
git_dir <- fromRepo Git.localGitDir
withTmpDirIn misctmpdir "git" $ \tmpgit -> withWorkTreeRelated tmpgit $
withemptydir tmpwt $ withWorkTree tmpwt $ do
liftIO $ writeFile (tmpgit </> "HEAD") (fromRef updatedorig)
-- Copy in refs and packed-refs, to work
-- around bug in git 2.13.0, which
-- causes it not to look in GIT_DIR for refs.
refs <- liftIO $ dirContentsRecursive $
git_dir </> "refs"
let refs' = (git_dir </> "packed-refs") : refs
liftIO $ forM_ refs' $ \src ->
whenM (doesFileExist src) $ do
dest <- relPathDirToFile git_dir src
print (src, dest)
let dest' = tmpgit </> dest
createDirectoryIfMissing True (takeDirectory dest')
void $ createLinkOrCopy src dest'
-- This reset makes git merge not care
-- that the work tree is empty; otherwise
-- it will think that all the files have