From: D. Ben Knoble Date: Wed, 11 Nov 2026 18:27:02 GMT Subject: Re: [PATCH v13 6/6] remote: resolve @{push} through remote..fetchRefmap Message-ID: In-Reply-To: <25eec8d9676d4adf82570616ca88a2b38d20afa4.1793357550.git.gitgitgadget@gmail.com> Hi Harald, On Fri, Oct 30, 2026 at 6:52 AM Harald Nordgren via GitGitGadget wrote: > > From: Harald Nordgren > > A branch pushed to a remote set up with "git remote add > --limited-fetch" has no remote..fetch entry to map it > through, so @{push} cannot tell where it landed and fails with > "has no local tracking branch". I don't have the rest of the series paged in right now (esp. patches 4 & 5 which deal with --limited-fetch), so forgive me if this comes from ignorance. Wouldn't the same problem happen if we applied the first 3 patches, then setup a repository's remote with a fetchRefmap and limited (or none) default fetch? If so, that almost makes this seem like a bugfix for an earlier patch, and perhaps it belongs together? It also would then be better justified in those terms, I think. Such a reorganization would maybe let the early part of the series be mostly about fetchRefmap (which I'm keen on) and let the end be about --limited-fetch, which seems nice but I don't have a strong motivation to review right now (personally---it's just limited time to spend!). > Give tracking_for_push_dest() the same fallback to > remote..fetchRefmap that get_ref_map() uses on the fetch > side, so a --limited-fetch remote supports @{push} resolution > the same way any other remote does. > > Signed-off-by: Harald Nordgren > --- > remote.c | 2 ++ > t/t1514-rev-parse-push.sh | 19 +++++++++++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/remote.c b/remote.c > index 15cd96aa8e..ecd104766c 100644 > --- a/remote.c > +++ b/remote.c > @@ -2018,6 +2018,8 @@ static char *tracking_for_push_dest(struct repository *repo, > > remote = repo_remote_for_push_tracking(repo, remote); > ret = apply_refspecs(&remote->fetch, refname); > + if (!ret) > + ret = apply_refspecs(&remote->refmap, refname); Ok, if we don't find the information in the fetch spec, we fallback to the refmap. That also means the former overrides the latter in case both are configured. Does that match what a fetch does if both are configured and overlap? (I'm not sure, as I can't recall what we decided the fetching behavior is!) > if (!ret) > return error_buf(err, > _("push destination '%s' on remote '%s' has no local tracking branch"), > diff --git a/t/t1514-rev-parse-push.sh b/t/t1514-rev-parse-push.sh > index 5a4f16867a..bcf00107f5 100755 > --- a/t/t1514-rev-parse-push.sh > +++ b/t/t1514-rev-parse-push.sh > @@ -80,4 +80,23 @@ test_expect_success 'resolving @{push} fails with a detached HEAD' ' > test_must_fail git rev-parse @{push} > ' > > +test_expect_success '@{push} resolves after pushing to a --limited-fetch remote' ' > + test_when_finished "rm -fr upstream fork downstream" && > + git init -b main upstream && > + test_commit -C upstream base && > + git init --bare fork && > + git clone --sparse upstream downstream && > + ( > + cd downstream && > + git remote add --limited-fetch fork ../fork && > + git config push.default current && > + git config remote.pushDefault fork && > + git checkout -b topic main && > + test_commit on-topic && > + git push && > + resolve topic@{push} refs/remotes/fork/topic && > + test_cmp_rev topic topic@{push} > + ) > +' > + If you take my suggestion to make this change with the early parts of the series, the test would probably need to be in terms of fetchRefmap instead of --limited-fetch, as well. That might be one reason to consider leaving it at the end, but… really the "problem" is the interaction of the earlier feature more than --limited-fetch, right? HTH, -- D. Ben Knoble