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.
This commit is contained in:
parent
7a9daefea2
commit
7206dcb376
1 changed files with 6 additions and 3 deletions
|
@ -16,6 +16,7 @@ import qualified Git.Ref
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import Annex.Content.Direct
|
import Annex.Content.Direct
|
||||||
import Git.Sha
|
import Git.Sha
|
||||||
|
import Git.FilePath
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [command "pre-commit" paramPaths seek SectionPlumbing
|
def = [command "pre-commit" paramPaths seek SectionPlumbing
|
||||||
|
@ -40,10 +41,11 @@ startIndirect file = next $ do
|
||||||
startDirect :: [String] -> CommandStart
|
startDirect :: [String] -> CommandStart
|
||||||
startDirect _ = next $ do
|
startDirect _ = next $ do
|
||||||
(diffs, clean) <- inRepo $ Git.DiffTree.diffIndex Git.Ref.headRef
|
(diffs, clean) <- inRepo $ Git.DiffTree.diffIndex Git.Ref.headRef
|
||||||
forM_ diffs go
|
makeabs <- flip fromTopFilePath <$> gitRepo
|
||||||
|
forM_ diffs (go makeabs)
|
||||||
next $ liftIO clean
|
next $ liftIO clean
|
||||||
where
|
where
|
||||||
go diff = do
|
go makeabs diff = do
|
||||||
withkey (Git.DiffTree.srcsha diff) (Git.DiffTree.srcmode diff) removeAssociatedFile
|
withkey (Git.DiffTree.srcsha diff) (Git.DiffTree.srcmode diff) removeAssociatedFile
|
||||||
withkey (Git.DiffTree.dstsha diff) (Git.DiffTree.dstmode diff) addAssociatedFile
|
withkey (Git.DiffTree.dstsha diff) (Git.DiffTree.dstmode diff) addAssociatedFile
|
||||||
where
|
where
|
||||||
|
@ -51,4 +53,5 @@ startDirect _ = next $ do
|
||||||
k <- catKey sha mode
|
k <- catKey sha mode
|
||||||
case k of
|
case k of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just key -> void $ a key (Git.DiffTree.file diff)
|
Just key -> void $ a key $
|
||||||
|
makeabs $ Git.DiffTree.file diff
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue