From 0214e0fb175a608a49b812d81b4632c081f63027 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 16 Jan 2013 21:31:06 -0400 Subject: [PATCH] union merge bugfix Union merges involving two or more repositories could sometimes result in data from one repository getting lost. This could result in the location log data becoming wrong, and fsck being needed to fix it. NB: I audited for any other occurrences of this problem. There are other places than union merge where multiple changes are fed into update-index in a stream, but they all involve working copy files being staged, or their deletion being staged, and in this case it's fine for the later changes to override the earlier ones. --- Git/UnionMerge.hs | 12 +++++++++--- debian/changelog | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Git/UnionMerge.hs b/Git/UnionMerge.hs index 05d512df3b..464200af4f 100644 --- a/Git/UnionMerge.hs +++ b/Git/UnionMerge.hs @@ -38,10 +38,16 @@ merge x y repo = do catFileStop h {- Merges a list of branches into the index. Previously staged changes in - - the index are preserved (and participate in the merge). -} + - the index are preserved (and participate in the merge). + - + - update-index is run once per ref in turn, so that each ref is merged on + - top of the merge for the previous ref. It would be more efficient, but + - harder to calculate a single union merge involving all the refs, as well + - as the index. + -} mergeIndex :: CatFileHandle -> Repo -> [Ref] -> IO () -mergeIndex h repo bs = - streamUpdateIndex repo $ map (\b -> mergeTreeIndex b h repo) bs +mergeIndex h repo bs = forM_ bs $ \b -> + streamUpdateIndex repo [mergeTreeIndex b h repo] {- For merging two trees. -} mergeTrees :: Ref -> Ref -> CatFileHandle -> Repo -> Streamer diff --git a/debian/changelog b/debian/changelog index 3595eb81bc..24fbdc223d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,9 @@ git-annex (3.20130115) UNRELEASED; urgency=low in it that is not a git repository. * Deal with incompatability in gpg2, which caused prompts for encryption passphrases rather than using the supplied --passphrase-fd. + * bugfix: Union merges involving two or more repositories could sometimes + result in data from one repository getting lost. This could result + in the location log data becoming wrong, and fsck being needed to fix it. -- Joey Hess Mon, 14 Jan 2013 18:35:01 -0400