sync: Fix crash when there are submodules and an adjusted branch is checked out

Reverse adjusting the branch uses treeItemToTreeContent, which was missed
when adding submodule support earlier.
This commit is contained in:
Joey Hess 2019-10-23 11:52:56 -04:00
parent 70b306ec34
commit bbdeb1a1a8
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 9 additions and 3 deletions

View file

@ -3,6 +3,8 @@ git-annex (7.20191018) UNRELEASED; urgency=medium
* init: Fix a failure when used in a submodule on a crippled filesystem.
* enable-tor: Deal with pkexec changing to root's home directory
when running a command.
* sync: Fix crash when there are submodules and an adjusted branch is
checked out.
-- Joey Hess <id@joeyh.name> Mon, 21 Oct 2019 11:01:06 -0400

View file

@ -100,7 +100,7 @@ mkTree :: MkTreeHandle -> [TreeContent] -> IO Sha
mkTree (MkTreeHandle cp) l = CoProcess.query cp send receive
where
send h = do
forM_ l $ \i -> hPutStr h $ case i of
forM_ l $ \i -> hPutStr h $ case i of
TreeBlob f fm s -> mkTreeOutput fm BlobObject s f
RecordedSubTree f s _ -> mkTreeOutput treeMode TreeObject s f
NewSubTree _ _ -> error "recordSubTree internal error; unexpected NewSubTree"
@ -127,7 +127,9 @@ data TreeItem = TreeItem TopFilePath FileMode Sha
deriving (Show, Eq)
treeItemToTreeContent :: TreeItem -> TreeContent
treeItemToTreeContent (TreeItem f m s) = TreeBlob f m s
treeItemToTreeContent (TreeItem f m s) = case toTreeItemType m of
Just TreeSubmodule -> TreeCommit f m s
_ -> TreeBlob f m s
treeItemToLsTreeItem :: TreeItem -> LsTree.TreeItem
treeItemToLsTreeItem (TreeItem f mode sha) = LsTree.TreeItem
@ -235,7 +237,7 @@ adjustTree adjusttreeitem addtreeitems resolveaddconflict removefiles r repo =
let !modified' = modified || slmodified || wasmodified
go h modified' (subtree : c) depth intree is'
Just CommitObject -> do
let ti = TreeCommit (LsTree.file i) (LsTree.mode i) (LsTree.sha i)
let ti = TreeCommit (LsTree.file i) (LsTree.mode i) (LsTree.sha i)
go h wasmodified (ti:c) depth intree is
_ -> error ("unexpected object type \"" ++ LsTree.typeobj i ++ "\"")
| otherwise = return (c, wasmodified, i:is)

View file

@ -51,3 +51,5 @@ upgrade supported from repository
[[ben]]
[[!tag confirmed]]
> [[fixed|done]] --[[Joey]]