From: Harald Nordgren via GitGitGadget Date: Fri, 30 Oct 2026 10:52:30 GMT Subject: [PATCH v13 6/6] remote: resolve @{push} through remote..fetchRefmap Message-ID: <25eec8d9676d4adf82570616ca88a2b38d20afa4.1793357550.git.gitgitgadget@gmail.com> In-Reply-To: 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". 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); 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} + ) +' + test_done -- gitgitgadget