From 7206dcb37646ab636145f776428bf96066c242f6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Oct 2013 14:52:12 -0400 Subject: [PATCH] update for DiffTree change This actually fixes a bug; if pre-commit was run in a subdir, it would pass relative files when updating the associated file maps, and so the maps wouldn't update. I don't think this bug happened in practice, due to the way pre-commit is called by the hook. It happened to chdir to the top of the work tree. --- Command/PreCommit.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs index 0943c0da7e..f10ac628eb 100644 --- a/Command/PreCommit.hs +++ b/Command/PreCommit.hs @@ -16,6 +16,7 @@ import qualified Git.Ref import Annex.CatFile import Annex.Content.Direct import Git.Sha +import Git.FilePath def :: [Command] def = [command "pre-commit" paramPaths seek SectionPlumbing @@ -40,10 +41,11 @@ startIndirect file = next $ do startDirect :: [String] -> CommandStart startDirect _ = next $ do (diffs, clean) <- inRepo $ Git.DiffTree.diffIndex Git.Ref.headRef - forM_ diffs go + makeabs <- flip fromTopFilePath <$> gitRepo + forM_ diffs (go makeabs) next $ liftIO clean where - go diff = do + go makeabs diff = do withkey (Git.DiffTree.srcsha diff) (Git.DiffTree.srcmode diff) removeAssociatedFile withkey (Git.DiffTree.dstsha diff) (Git.DiffTree.dstmode diff) addAssociatedFile where @@ -51,4 +53,5 @@ startDirect _ = next $ do k <- catKey sha mode case k of Nothing -> noop - Just key -> void $ a key (Git.DiffTree.file diff) + Just key -> void $ a key $ + makeabs $ Git.DiffTree.file diff