From e1fdc8b374f103a201a543ebcdc7ac48049d962e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Mar 2019 13:44:23 -0400 Subject: [PATCH] record only subtree in export db and log after importing a subtree --- Annex/Import.hs | 16 +++++++++++++--- doc/todo/import_tree.mdwn | 8 -------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Annex/Import.hs b/Annex/Import.hs index 87d4fdf626..da84f3e8b0 100644 --- a/Annex/Import.hs +++ b/Annex/Import.hs @@ -107,9 +107,7 @@ buildImportCommit remote importtreeconfig importcommitconfig importable = mkcommits origtree basecommit imported >>= \case Nothing -> return Nothing Just finalcommit -> do - updateexportdb finaltree - oldexport <- updateexportlog finaltree - updatelocationlog oldexport finaltree + updatestate finaltree return (Just finalcommit) mkcommits origtree basecommit (History importedtree hs) = do @@ -126,6 +124,18 @@ buildImportCommit remote importtreeconfig importcommitconfig importable = commitparents importedtree return (Just commit) + + updatestate committedtree = do + importedtree <- case subdir of + Nothing -> pure committedtree + Just dir -> + let subtreeref = Ref $ + fromRef committedtree ++ ":" ++ getTopFilePath dir + in fromMaybe emptyTree + <$> inRepo (Git.Ref.tree subtreeref) + updateexportdb importedtree + oldexport <- updateexportlog importedtree + updatelocationlog oldexport importedtree updateexportdb importedtree = do db <- Export.openDb (Remote.uuid remote) diff --git a/doc/todo/import_tree.mdwn b/doc/todo/import_tree.mdwn index 3f3b9ed009..e76a30303b 100644 --- a/doc/todo/import_tree.mdwn +++ b/doc/todo/import_tree.mdwn @@ -10,14 +10,6 @@ this. ## implementation notes -* When doing `git annex export master:subdir` followed by - `git annex import master:subdir` which imports a new file, - followed by merging the import and re-export, it does unncessary - work deleting stuff not in the subdir from the remote. - - Why? Seems that the import recorded the exported tree wrong, using the - whole tree and not the sub-tree. - * Does sync --content with remote.name.annex-tracking-branch=master:subdir export the right tree and update the remote tracking branch right? Does it import correctly?