From: Jeff King <peff@peff.net>
To: Damien Robert <damien.olivier.robert@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 1/1] remote.c: fix handling of %(push:remoteref)
Date: Mon, 6 Apr 2020 17:46:07 -0400 [thread overview]
Message-ID: <20200406214607.GA1251506@coredump.intra.peff.net> (raw)
In-Reply-To: <20200406160439.gg5uu6kepnyxpvuc@feanor>
On Mon, Apr 06, 2020 at 06:04:39PM +0200, Damien Robert wrote:
> Heres what happen with such a triangular workflow when we do a `git push`:
> - with push.default=simple, we have
> case PUSH_DEFAULT_SIMPLE:
> if (triangular)
> setup_push_current(remote, branch);
> else
> setup_push_upstream(remote, branch, triangular, 1);
> break;
> so the current branch is always pushed.
Yeah, otherwise every push to a remote other than origin would require a
refspec. I think with respect to for-each-ref, this "triangular" case
would only kick in if you define remote.pushDefault (since you can't
specify a remote on the command-line).
Though hmm. I guess maybe it could kick in if the upstream of the branch
is on a non-default remote? For push, that would work because
remote_get() will look at the current branch. But of course in
for-each-ref, we're asking speculatively about other branches.
So I think if we want to support this triangular logic in for-each-ref,
we need to have a more careful definition than what's in push.c's
is_workflow_triangular(). I.e., it would probably make sense to consider
it from the position of "if we were on this branch, what would it push".
And ditto for @{push}, I guess.
> - with push.default=upstream, we have
> case PUSH_DEFAULT_UPSTREAM:
> setup_push_upstream(remote, branch, triangular, 0);
> break;
> which then gives
> if (triangular)
> die(_("You are pushing to remote '%s', which is not the upstream of\n"
> "your current branch '%s', without telling me what to push\n"
> "to update which remote branch."),
>
> By the way this matches what the documentation says.
Yeah. I think in the triangular case (at least as defined in push.c)
we'd always be pushing to the non-upstream, so this die() makes sense.
In for-each-ref, I guess we'd hit this case with remote.pushDefault
again. Without that, we'd always be pushing to the upstream anyway.
> However here is the result of
> git -c push.default=$value for-each-ref --format="%(push:remotename),%(push:remoteref),%(push)" refs/heads/master
> for $value=
> - simple: to,,
> - upstream: to,refs/heads/other,refs/remotes/from/other
>
> Note that without my patch the %(push:remoteref) values would always be empty,
> but my patch does not touch %(push).
>
> So in both branch_get_push_1 and branch_get_push_remoteref I should first
> detect if we have a triangular workflow, and update the logic of the code
> accordingly.
Yes, I agree this could be improved. I'm OK leaving that as a separate
fix to your current remoteref work, though.
-Peff
next prev parent reply other threads:[~2020-04-06 21:46 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 17:24 [PATCH 1/1] remote.c: fix handling of push:remote_ref Damien Robert
2020-02-28 18:23 ` Jeff King
2020-03-01 22:05 ` Damien Robert
2020-03-02 13:32 ` Jeff King
2020-03-03 16:12 ` [PATCH v2 0/2] Damien Robert
2020-03-03 16:12 ` [PATCH v2 1/2] remote: drop "explicit" parameter from remote_ref_for_branch() Damien Robert
2020-03-03 17:51 ` Junio C Hamano
2020-03-03 21:11 ` Jeff King
2020-03-03 22:22 ` Junio C Hamano
2020-03-03 16:12 ` [PATCH v2 2/2] remote.c: fix handling of %(push:remoteref) Damien Robert
2020-03-03 16:29 ` Damien Robert
2020-03-03 18:29 ` Junio C Hamano
2020-03-03 18:21 ` Junio C Hamano
2020-03-03 22:24 ` Damien Robert
2020-03-03 22:48 ` Junio C Hamano
2020-03-12 16:45 ` [PATCH v3 1/1] " Damien Robert
2020-03-25 22:16 ` Damien Robert
2020-03-27 22:08 ` Junio C Hamano
2020-03-28 22:25 ` Damien Robert
2020-03-28 13:15 ` Jeff King
2020-03-28 13:31 ` Jeff King
2020-04-16 15:12 ` Damien Robert
2020-04-06 16:04 ` Damien Robert
2020-04-06 21:46 ` Jeff King [this message]
2020-04-06 17:56 ` [RFC PATCH v4 0/2] %(push) and %(push:remoteref) bug fixes Damien Robert
2020-04-06 17:56 ` [PATCH v6 1/2] remote.c: fix %(push) for triangular workflows Damien Robert
2020-04-06 17:56 ` [PATCH v6 2/2] remote.c: fix handling of %(push:remoteref) Damien Robert
2020-04-16 15:03 ` [PATCH v8 1/1] " Damien Robert
2020-04-16 15:21 ` Damien Robert
2020-09-03 22:01 ` Junio C Hamano
2020-09-11 21:43 ` Damien Robert
2020-09-14 22:21 ` Junio C Hamano
2020-03-03 16:16 ` [PATCH 1/1] remote.c: fix handling of push:remote_ref Damien Robert
2020-03-02 13:48 ` Jeff King
2020-03-03 16:25 ` Damien Robert
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200406214607.GA1251506@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=damien.olivier.robert@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).