include subdir when checking export branch is checked out

sync: Fix a reversion that prevented sending files to exporttree=yes
remotes when annex-tracking-branch was configured to branch:subdir
(Introduced in version 10.20230214)

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2023-03-10 11:41:52 -04:00
parent 89c68f9a60
commit ff141c093e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 19 additions and 7 deletions

View file

@ -2,6 +2,9 @@ git-annex (10.20230228) UNRELEASED; urgency=medium
* Using git-annex view in an adjusted branch, or git-annex adjust in a
view branch, will enter an adjusted view branch.
* sync: Fix a reversion that prevented sending files to exporttree=yes
remotes when annex-tracking-branch was configured to branch:subdir
(Introduced in version 10.20230214)
* status: This command is deprecated because it was only needed in direct
mode; git status --short is very similar.
* Windows: Support long filenames in more (possibly all) of the code.

View file

@ -521,12 +521,8 @@ importRemote importcontent o remote currbranch
| not (pullOption o) || not wantpull = noop
| otherwise = case remoteAnnexTrackingBranch (Remote.gitconfig remote) of
Nothing -> noop
Just tb -> do
let (b, p) = separate' (== (fromIntegral (ord ':'))) (Git.fromRef' tb)
let branch = Git.Ref b
let subdir = if S.null p
then Nothing
else Just (asTopFilePath p)
Just b -> do
let (branch, subdir) = splitRemoteAnnexTrackingBranchSubdir b
if canImportKeys remote importcontent
then do
Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True)
@ -926,8 +922,12 @@ seekExportContent o rs (currbranch, _) = or <$> forM rs go
Nothing -> cannotupdateexport r db Nothing True
Just b -> do
mtree <- inRepo $ Git.Ref.tree b
let addsubdir = case snd (splitRemoteAnnexTrackingBranchSubdir b) of
Just subdir -> \cb -> Git.Ref $
Git.fromRef' cb <> ":" <> getTopFilePath subdir
Nothing -> id
mcurrtree <- maybe (pure Nothing)
(inRepo . Git.Ref.tree)
(inRepo . Git.Ref.tree . addsubdir)
currbranch
mtbcommitsha <- Command.Export.getExportCommit r b
case (mtree, mcurrtree, mtbcommitsha) of
@ -1029,3 +1029,12 @@ isImport = importTree . Remote.config
isThirdPartyPopulated :: Remote -> Bool
isThirdPartyPopulated = Remote.thirdPartyPopulated . Remote.remotetype
splitRemoteAnnexTrackingBranchSubdir :: Git.Ref -> (Git.Ref, Maybe TopFilePath)
splitRemoteAnnexTrackingBranchSubdir tb = (branch, subdir)
where
(b, p) = separate' (== (fromIntegral (ord ':'))) (Git.fromRef' tb)
branch = Git.Ref b
subdir = if S.null p
then Nothing
else Just (asTopFilePath p)