git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Damien Robert <damien.olivier.robert@gmail.com>
To: Jeff King <peff@peff.net>
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: Thu, 16 Apr 2020 17:12:13 +0200	[thread overview]
Message-ID: <20200416151213.xbo5x6jt477ezwvo@feanor> (raw)
In-Reply-To: <20200328133134.GA1196665@coredump.intra.peff.net>

From Jeff King, Sat 28 Mar 2020 at 09:31:34 (-0400) :
> > > I am still a bit annoyed that I cannot call branch_get_push_remoteref from
> > > branch_get_push1 because of the PUSH_DEFAULT_UPSTREAM case, but this can
> > > wait and we will need to work with the code duplication meanwhile.

> > I looked into this, too, and have a working patch. It does get a little
> > awkward, though, and I'm happy to just take your patch for now as the
> > practical thing.

Hi Jeff,

I looked up at your patch again, because the code duplication gets more
annoying the more new corner cases I have to handle to get the push ref
correct in all cases (cf my cover letter to v6).

This implements what I was suggesting in
https://public-inbox.org/git/20200301220531.iuokzzdb5gruslrn@doriath/

Essentially in branch_get_push you call:

        remote = remote_get(pushremote_for_branch(branch, NULL));
        tracking_for_push_dest(remote, branch_get_push_remoteref(branch),

And as I pointed out, this is currently exactly what branch_get_push_1
does, except in the
PUSH_DEFAULT_UPSTREAM where it returns branch->merge[0]->dst.

But branch->merge is set up in `set_merge`, where we have:

                ret->merge[i]->src = xstrdup(ret->merge_name[i]);
                if (!remote_find_tracking(remote, ret->merge[i]) ||
                    strcmp(ret->remote_name, "."))
                continue;
                if (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]),
                             &oid, &ref) == 1)
                        ret->merge[i]->dst = ref;

So in particular, when the remote is local, the current code path calls
dwim_ref. (I have no idea who set up ret->merge[i]->dst if the remote is
not local...)

So my question was: can dwim_ref(branch->merge[0]->src) be different from
tracking_for_push_dest(branch->merge[0]->src)?

So I admit I don't understand everything dwim_ref does, but there is at
least one case where the answer is yes: if we have a dangling symref,
dwim_ref which calls expand_ref in refs.c will detect it. So in the current
code, %(push) would show nothing, while with your patch it would show the
dangling symref.

Obviously we cannot allow a regression for this very common case ;)

  reply	other threads:[~2020-04-16 15:14 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 [this message]
2020-04-06 16:04               ` Damien Robert
2020-04-06 21:46                 ` Jeff King
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=20200416151213.xbo5x6jt477ezwvo@feanor \
    --to=damien.olivier.robert@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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).