From: Damien Robert <damien.olivier.robert@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/1] remote.c: fix handling of push:remote_ref
Date: Tue, 3 Mar 2020 17:25:14 +0100 [thread overview]
Message-ID: <20200303162514.dkmulpq5fw3t6hpt@feanor> (raw)
In-Reply-To: <20200302134842.GB1176622@coredump.intra.peff.net>
From Jeff King, Mon 02 Mar 2020 at 08:48:42 (-0500) :
> And I think all of this may be duplicated with git-push itself (which
> would also be nice to get rid of, but last time I looked into it was
> hard to refactor it to do so).
I had a quick look at git-push but the duplication does not seems too bad.
> > In the 'upstream' case, the auxiliary function would return
> > branch->merge_name[0]. So the question is: can
> > tracking_for_push_dest(branch->merge_name[0]) be different from
> > branch->merge[0]->dst?
> Those will both return tracking refs. I think you just want
> merge[0]->src for the upstream case.
> And yes, the two can be different. It's the same case as when the
> upstream branch has a different name than the current branch.
I meant, now that we have branch_get_push_remoteref, can we replace
the body of branch_get_push_1 by
remote = remote_get(pushremote_for_branch(branch, NULL));
ret = tracking_for_push_dest(remote, branch_get_push_remoteref(branch), err);
(we would need to add error handling in branch_get_push_remoteref but that
is easy)
Currently that is 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 (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]),
&oid, &ref) == 1)
ret->merge[i]->dst = ref;
So my question was: can dwim_ref(branch->merge[0]->src) be different from
tracking_for_push_dest(branch->merge[0]->src)?
> Yeah, I think that's going to be the easiest. It would be nice to avoid
> repeating that switch(), but frankly I think the boilerplate you'll end
> up with trying to handle the two cases may be worse than just repeating
> it.
That's what I went with. We can always refactorise branch_get_push_1 to use
branch_get_push_remoteref afterwards.
> It may be worth adding a comment to each function to mention the
> other, and that any changes need to match.
I tried to add a comment, but I don't know if it is helpful enough.
prev parent reply other threads:[~2020-03-03 16:25 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
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 [this message]
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=20200303162514.dkmulpq5fw3t6hpt@feanor \
--to=damien.olivier.robert@gmail.com \
--cc=git@vger.kernel.org \
--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).