relax annex-tracking-branch to allow "/"

Allow setting remote.foo.annex-tracking-branch to a branch name that
contains "/", as long as it's not a remote tracking branch.
This commit is contained in:
Joey Hess 2025-01-20 11:31:18 -04:00
parent b1c9c9d6e7
commit 9e4314de76
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 34 additions and 5 deletions

View file

@ -120,15 +120,21 @@ seekExport r tree mtbcommitsha srcrs = do
-- branch.
getExportCommit :: Remote -> Git.Ref -> Annex (Maybe (RemoteTrackingBranch, Sha))
getExportCommit r treeish
| '/' `notElem` fromRef baseref = do
let tb = mkRemoteTrackingBranch r baseref
commitsha <- inRepo $ Git.Ref.sha $ Git.Ref.underBase refsheads baseref
return (fmap (tb, ) commitsha)
| otherwise = return Nothing
| '/' `notElem` fromRef baseref = go
| otherwise = ifM isremoteref
( return Nothing
, go
)
where
baseref = Ref $ S8.takeWhile (/= ':') $ fromRef' $
Git.Ref.removeBase refsheads treeish
refsheads = "refs/heads"
isremoteref = inRepo $ Git.Ref.exists $
Git.Ref.underBase "refs/remotes" baseref
go = do
let tb = mkRemoteTrackingBranch r baseref
commitsha <- inRepo $ Git.Ref.sha $ Git.Ref.underBase refsheads baseref
return (fmap (tb, ) commitsha)
-- | Changes what's exported to the remote. Does not upload any new
-- files, but does delete and rename files already exported to the remote.