diff options
author | Joey Hess <joey@kitenet.net> | 2014-11-12 15:41:15 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-11-12 15:51:46 -0400 |
commit | bb7571aeb4d4cd4920a7fe4b2538ce5a412f7603 (patch) | |
tree | 3a9f998c60fd1a4fc5bad999b11aa1d4e2c4df3b /Annex/Direct.hs | |
parent | 708944448479a4c8a1d47ba6db96def92960ad36 (diff) |
proxy: for all your direct mode repository munging needs
This allows bypassing the direct mode guard in a safe way to do all sorts
of things including git revert, git mv, git checkout ...
This commit was sponsored by the WikiMedia Foundation.
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 9489b74f2..e4015dd16 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -225,9 +225,17 @@ mergeDirectCommit allowff old branch commitmode = do where canff = maybe (return False) (\o -> inRepo $ Git.Branch.fastForwardable o branch) old -{- Cleans up after a direct mode merge. The merge must have been staged - - in the index. Uses diff-index to compare the staged changes with - - the tree before the merge, and applies those changes to the work tree. +mergeDirectCleanup :: FilePath -> Git.Ref -> Annex () +mergeDirectCleanup d oldref = do + updateWorkTree d oldref + liftIO $ removeDirectoryRecursive d + +{- Updates the direct mode work tree to reflect the changes staged in the + - index by a git command, that was run in a temporary work tree. + - + - Uses diff-index to compare the staged changes with provided ref + - which should be the tree before the merge, and applies those + - changes to the work tree. - - There are really only two types of changes: An old item can be deleted, - or a new item added. Two passes are made, first deleting and then @@ -236,8 +244,8 @@ mergeDirectCommit allowff old branch commitmode = do - order, but we cannot add the directory until the file with the - same name is removed.) -} -mergeDirectCleanup :: FilePath -> Git.Ref -> Annex () -mergeDirectCleanup d oldref = do +updateWorkTree :: FilePath -> Git.Ref -> Annex () +updateWorkTree d oldref = do (items, cleanup) <- inRepo $ DiffTree.diffIndex oldref makeabs <- flip fromTopFilePath <$> gitRepo let fsitems = zip (map (makeabs . DiffTree.file) items) items @@ -246,7 +254,6 @@ mergeDirectCleanup d oldref = do forM_ fsitems $ go makeabs DiffTree.dstsha DiffTree.dstmode movein movein_raw void $ liftIO cleanup - liftIO $ removeDirectoryRecursive d where go makeabs getsha getmode a araw (f, item) | getsha item == nullSha = noop |