diff options
author | Joey Hess <joey@kitenet.net> | 2014-06-12 22:00:02 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-06-12 22:00:02 -0400 |
commit | 923c253078e6e82aeaf6226a19cace6a53701d94 (patch) | |
tree | c53f5d4fc73f3d20ad37fec0c830e75199a6fa60 | |
parent | fd2b8cf2a99170b15b35c9895710983f5481ba46 (diff) |
work around a bug in git
http://marc.info/?l=git&m=140262402204212&w=2
This git bug manifested on FAT and Windows as the test suite failing in 3
places. All involved merge conflict resolution. It turned out that the
associated file mappings were getting messed up, and that happened because
this git bug lost track of what files were supposed to be symlinks.
This commit was sponsored by Eric Kidd.
-rw-r--r-- | Annex/Direct.hs | 23 | ||||
-rw-r--r-- | doc/bugs/direct_mode_merge_interrupt.mdwn | 12 |
2 files changed, 29 insertions, 6 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 5442113af..6e14c6b9b 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -1,6 +1,6 @@ {- git-annex direct mode - - - Copyright 2012, 2013 Joey Hess <joey@kitenet.net> + - Copyright 2012-2014 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} @@ -168,7 +168,7 @@ mergeDirect startbranch oldref branch resolvemerge = do createDirectoryIfMissing True d withIndexFile tmpi $ do - merged <- inRepo (mergein d) + merged <- stageMerge d branch r <- if merged then return True else resolvemerge @@ -176,8 +176,23 @@ mergeDirect startbranch oldref branch resolvemerge = do mergeDirectCommit merged startbranch branch liftIO $ rename tmpi reali return r - where - mergein d g = Git.Merge.stageMerge branch $ + +{- Stage a merge into the index, avoiding changing HEAD or the current + - branch. -} +stageMerge :: FilePath -> Git.Branch -> Annex Bool +stageMerge d branch = do + -- XXX A bug in git makes stageMerge unsafe to use if the git repo + -- is configured with core.symlinks=false + -- Using mergeNonInteractive is not ideal though, since it will + -- update the current branch immediately, before the work tree + -- has been updated, which would leave things in an inconsistent + -- state if mergeDirectCleanup is interrupted. + -- <http://marc.info/?l=git&m=140262402204212&w=2> + merger <- ifM (coreSymlinks <$> Annex.getGitConfig) + ( return Git.Merge.stageMerge + , return Git.Merge.mergeNonInteractive + ) + inRepo $ \g -> merger branch $ g { location = Local { gitdir = Git.localGitDir g, worktree = Just d } } {- Commits after a direct mode merge is complete, and after the work diff --git a/doc/bugs/direct_mode_merge_interrupt.mdwn b/doc/bugs/direct_mode_merge_interrupt.mdwn index e64848140..7cbb44208 100644 --- a/doc/bugs/direct_mode_merge_interrupt.mdwn +++ b/doc/bugs/direct_mode_merge_interrupt.mdwn @@ -32,8 +32,16 @@ merge. (I assume this is how `git merge` normally works.) --[[Joey]] > Seems that a direct mode > merge also needs to use a different index file to stage its changes? > (Ugh) -> > [[done]] --[[Joey]] -> +> > done --[[Joey]] + +> > > I had to revert the fix on FAT/Windows due to +> > > a git bug: <http://marc.info/?l=git&m=140262402204212&w=2> +> > > Once that bug's fixed, I can revisit this. --[[Joey]] + +[[!meta title="direct mode merge interrupt (fixed for all except FAT, Windows)"]] + +## other options + > Or could perhaps use `git-merge-tree` > and avoid staging the merge in the index until the work-tree is updated. > |