git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/2] remote: resolve "simple" @{push} when pushing to another remote

From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 31, 2026, 08:03 UTC
Message-ID
<pull.2466.v2.git.git.1793433841.gitgitgadget@gmail.com>
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
Previous: Harald NordgrenNext: Harald Nordgren via GitGitGadget
Message 6 of 8 in “remote: resolve "simple" @{push} when pushing to another remote”
  1. remote: resolve "simple" @{push} when pushing to another remoteHarald Nordgren via GitGitGadget, Oct 27, 2026
  2. D. Ben KnobleOct 28, 2026
  3. Harald NordgrenOct 29, 2026
  4. Junio C HamanoOct 29, 2026
  5. Harald NordgrenOct 29, 2026
  6. 0/2 remote: resolve "simple" @{push} when pushing to another remoteHarald Nordgren via GitGitGadget, Oct 31, 2026
  7. 1/2 remote: move "simple" @{push} resolution into a helperHarald Nordgren via GitGitGadget, Oct 31, 2026
  8. 2/2 remote: resolve "simple" @{push} when pushing to another remoteHarald Nordgren via GitGitGadget, Oct 31, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.