diff --git a/Command/Export.hs b/Command/Export.hs index dec123442a..4e87f43b05 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -79,9 +79,10 @@ seek o = do setConfig (remoteConfig r "annex-tracking-branch") (fromRef $ exportTreeish o) - mtbcommitsha <- getExportCommit r (exportTreeish o) tree <- fromMaybe (giveup "unknown tree") <$> - inRepo (Git.Ref.tree (fromMaybe (exportTreeish o) (fmap snd mtbcommitsha))) + inRepo (Git.Ref.tree (exportTreeish o)) + + mtbcommitsha <- getExportCommit r (exportTreeish o) db <- openDb (uuid r) writeLockDbWhile db $ do @@ -93,6 +94,10 @@ seek o = do -- | When the treeish is a branch like master or refs/heads/master -- (but not refs/remotes/...), find the commit it points to -- and the corresponding remote tracking branch. +-- +-- The treeish may also be a subdir within a branch, like master:subdir, +-- that results in this returning the same thing it does for the master +-- branch. getExportCommit :: Remote -> Git.Ref -> Annex (Maybe (RemoteTrackingBranch, Sha)) getExportCommit r treeish | '/' `notElem` fromRef baseref = do @@ -101,7 +106,8 @@ getExportCommit r treeish return (fmap (tb, ) commitsha) | otherwise = return Nothing where - baseref = Git.Ref.removeBase refsheads treeish + baseref = Ref $ takeWhile (/= ':') $ fromRef $ + Git.Ref.removeBase refsheads treeish refsheads = "refs/heads" -- | Changes what's exported to the remote. Does not upload any new diff --git a/doc/todo/import_tree.mdwn b/doc/todo/import_tree.mdwn index 33e2d6c3b2..3f3b9ed009 100644 --- a/doc/todo/import_tree.mdwn +++ b/doc/todo/import_tree.mdwn @@ -10,7 +10,13 @@ this. ## implementation notes -* Does export of master:subdir update the remote tracking branch right? +* 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?