remote: resolve "simple" @{push} when pushing to another remote
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 1 replyIn review
- v11 patch 4 repliesSuperseded
Changes in v2 from the cover letter
* Moved the "simple" @{push} code out of branch_get_push_1() into its own function in a new preparatory commit.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | remote: move "simple" @{push} resolution into a helperremote.c | +23 | 0 replies | |
| 2/2 | remote: resolve "simple" @{push} when pushing to another remoteremote.c t/ t/ | +23 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] remote: resolve "simple" @{push} when pushing to another remote
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
## 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
'
Signature · 1 line
gitgitgadget