From: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
Harald Nordgren <haraldnordgren@gmail.com>
Subject: [PATCH v2 0/2] remote: resolve "simple" @{push} when pushing to another remote
Date: Sat, 31 Oct 2026 08:03:59 +0000 [thread overview]
Message-ID: <pull.2466.v2.git.git.1793433841.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2466.git.git.1793105039624.gitgitgadget@gmail.com>
With push.default=simple and remote.pushDefault pointing at a fork, git push
pushes the branch to the fork, but @{push} fails with "cannot resolve
'simple' push to a single destination".
So git status cannot compare the branch with where it was pushed. Make
@{push} resolve to where git push goes.
Changes in v2:
* Moved the "simple" @{push} code out of branch_get_push_1() into its own
function in a new preparatory commit.
Harald Nordgren (2):
remote: move "simple" @{push} resolution into a helper
remote: resolve "simple" @{push} when pushing to another remote
remote.c | 43 +++++++++++++++++++++++----------------
t/for-each-ref-tests.sh | 4 +++-
t/t1514-rev-parse-push.sh | 13 +++++++++++-
3 files changed, 41 insertions(+), 19 deletions(-)
base-commit: b9e5cff1803ab24582201ef059516eb16014b9d9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2466%2FHaraldNordgren%2Fat-push-simple-triangular-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2466/HaraldNordgren/at-push-simple-triangular-v2
Pull-Request: https://github.com/git/git/pull/2466
Range-diff vs v1:
-: ---------- > 1: 151fef69b9 remote: move "simple" @{push} resolution into a helper
1: d2b1a00d23 ! 2: c58afcc4b1 remote: resolve "simple" @{push} when pushing to another remote
@@ Commit message
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
## remote.c ##
-@@ remote.c: static char *branch_get_push_1(struct repository *repo,
- const char *up;
- char *cur;
+@@ remote.c: static char *branch_get_push_simple(struct repository *repo,
+ struct branch *branch,
+ struct strbuf *err)
+ {
+- const char *up;
++ const char *up = NULL;
+ char *cur;
-+ if (strcmp(remote->name,
-+ remotes_remote_for_branch(remote_state, branch, NULL)))
-+ return tracking_for_push_dest(repo, remote, branch->refname, err);
-+
- up = branch_get_upstream(branch, err);
- if (!up)
- return NULL;
+- up = branch_get_upstream(branch, err);
+- if (!up)
+- return NULL;
++ if (!strcmp(remote->name,
++ remotes_remote_for_branch(repo->remote_state, branch, NULL))) {
++ up = branch_get_upstream(branch, err);
++ if (!up)
++ return NULL;
++ }
+ cur = tracking_for_push_dest(repo, remote, branch->refname, err);
+ if (!cur)
+ return NULL;
+- if (strcmp(cur, up)) {
++ if (up && strcmp(cur, up)) {
+ free(cur);
+ return error_buf(err,
+ _("cannot resolve 'simple' push to a single destination"));
## t/for-each-ref-tests.sh ##
@@ t/for-each-ref-tests.sh: test_expect_success ':remotename and :remoteref' '
@@ t/for-each-ref-tests.sh: test_expect_success ':remotename and :remoteref' '
test_cmp expect actual
## t/t1514-rev-parse-push.sh ##
+@@ t/t1514-rev-parse-push.sh: test_expect_success '@{push} with default=simple' '
+ resolve main@{pUSh} refs/remotes/origin/main
+ '
+
+-test_expect_success 'triangular @{push} fails with default=simple' '
++test_expect_success '@{push} with default=simple fails when upstream has a different name' '
+ test_config push.default simple &&
+ test_must_fail git rev-parse topic@{push}
+ '
@@ t/t1514-rev-parse-push.sh: test_expect_success '@{push} with pushremote defined' '
resolve topic@{push} refs/remotes/other/topic
'
--
gitgitgadget
next prev parent reply other threads:[~2026-10-31 8:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 12:43 [PATCH] remote: resolve "simple" @{push} when pushing to another remote Harald Nordgren via GitGitGadget
2026-10-28 22:24 ` D. Ben Knoble
2026-10-29 10:34 ` Harald Nordgren
2026-10-29 17:48 ` Junio C Hamano
2026-10-29 22:15 ` Harald Nordgren
2026-10-31 8:03 ` Harald Nordgren via GitGitGadget [this message]
2026-10-31 8:04 ` [PATCH v2 1/2] remote: move "simple" @{push} resolution into a helper Harald Nordgren via GitGitGadget
2026-10-31 8:04 ` [PATCH v2 2/2] remote: resolve "simple" @{push} when pushing to another remote Harald Nordgren via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2466.v2.git.git.1793433841.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=haraldnordgren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox