From 9e4314de76d5bcd5d226ac31188d0d6b69e6783d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Jan 2025 11:31:18 -0400 Subject: [PATCH] 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. --- CHANGELOG | 2 ++ Command/Export.hs | 16 +++++++++++----- ...n__39__t_export_synced__47___branches.mdwn | 2 ++ ..._19ef18864eef6d08dae48df6ddb7152d._comment | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 doc/bugs/Can__39__t_export_synced__47___branches/comment_1_19ef18864eef6d08dae48df6ddb7152d._comment diff --git a/CHANGELOG b/CHANGELOG index 15833a80c1..fa11259b2b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ git-annex (10.20250116) UNRELEASED; urgency=medium * Support help.autocorrect settings "prompt", "never", and "immediate". + * Allow setting remote.foo.annex-tracking-branch to a branch name + that contains "/", as long as it's not a remote tracking branch. -- Joey Hess Mon, 20 Jan 2025 10:24:51 -0400 diff --git a/Command/Export.hs b/Command/Export.hs index ebbcb51ea8..4e87323bf3 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -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. diff --git a/doc/bugs/Can__39__t_export_synced__47___branches.mdwn b/doc/bugs/Can__39__t_export_synced__47___branches.mdwn index 19085dbe88..20385272b1 100644 --- a/doc/bugs/Can__39__t_export_synced__47___branches.mdwn +++ b/doc/bugs/Can__39__t_export_synced__47___branches.mdwn @@ -66,3 +66,5 @@ export myexport bla ok ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) git-annex is amazing, thank you! 🤩 + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/Can__39__t_export_synced__47___branches/comment_1_19ef18864eef6d08dae48df6ddb7152d._comment b/doc/bugs/Can__39__t_export_synced__47___branches/comment_1_19ef18864eef6d08dae48df6ddb7152d._comment new file mode 100644 index 0000000000..19f60bc6a4 --- /dev/null +++ b/doc/bugs/Can__39__t_export_synced__47___branches/comment_1_19ef18864eef6d08dae48df6ddb7152d._comment @@ -0,0 +1,19 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2025-01-20T15:13:05Z" + content=""" +The difficulty here is that it needs to come up with the name of a +corresponding remote tracking branch to update. It could use +"myexport/synced/main" for that. But, setting `annex-tracking-branch` to +a remote ref like "origin/main" is not supported, and it would not be good +if it allowed it and used a tracking branch with a name like +"myexport/origin/main". + +And well, we know that "synced/main" is not a remote ref, but "$foo/main" +generally may or may not be one. + +So, I think to support this, it would have only allow using "$foo/main" +when the ref "refs/remotes/$foo/main" does not exist. I've implemented +that. +"""]]