From: Junio C Hamano <gitster@pobox.com>
To: Usman Akinyemi <usmanakinyemi202@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com,
me@ttaylorr.com, phillip.wood123@gmail.com, ps@pks.im
Subject: Re: [RFC PATCH 2/2] push: support pushing to a remote group
Date: Fri, 06 Mar 2026 18:12:50 -0800 [thread overview]
Message-ID: <xmqq4imsv13x.fsf@gitster.g> (raw)
In-Reply-To: <20260305223248.170785-3-usmanakinyemi202@gmail.com> (Usman Akinyemi's message of "Fri, 6 Mar 2026 04:02:48 +0530")
Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
> - remote = pushremote_get(repo);
> - if (!remote) {
> - if (repo)
> - die(_("bad repository '%s'"), repo);
> - die(_("No configured push destination.\n"
> - "Either specify the URL from the command-line or configure a remote repository using\n"
> - "\n"
> - " git remote add <name> <url>\n"
> - "\n"
> - "and then push using the remote name\n"
> - "\n"
> - " git push <name>\n"));
> + if (repo) {
> + if (!add_remote_or_group(repo, &remote_group))
> + die(_("no such remote or remote group: %s"), repo);
> + } else {
> + remote = pushremote_get(NULL);
> + if (!remote)
> + die(_("No configured push destination.\n"
> + "Either specify the URL from the command-line or configure a remote repository using\n"
> + "\n"
> + " git remote add <name> <url>\n"
> + "\n"
> + "and then push using the remote name\n"
> + "\n"
> + " git push <name>\n"));
> }
The basic idea to use "remote" (the default remote cannot be multiple)
vs "remote_group" (the command line gave which remotes to talk with)
sounds good.
But I started wondering what happens when the command line gave a
single remote to talk with. Probably we want a code that does
if (remote_group has only one remote)
remote = take the sole remote from the remote_group;
here before we continue. Or the other way around and we handle the
"default remote cannot be multiple" case as a special case, e.g.
if (remote) {
create remote_group with a single member "remote";
remote = NULL;
}
and then we do not have to do ...
> + /*
> + * set_refspecs and mirror detection must not use `remote`
> + * when it may be NULL (group path). For the single-remote case,
> + * handle them here. For the group case they are handled
> + * per-remote inside the loop below.
> + */
... "handle them here because single-remote is special" at all, no?
I would prefer to avoid "X must be done for each remote in the
remote-group, but Y can be done only once", as future developers
will get it wrong when they add their own Z and consider which side
Z falls into. The code structure that removes special case would
help by making sure that a singleton case is special only because
the loop over remote_group runs once, and otherwise there is nothing
special goes on.
Thanks.
next prev parent reply other threads:[~2026-03-07 2:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 22:32 [RFC PATCH 0/2] push: add support for pushing to remote groups Usman Akinyemi
2026-03-05 22:32 ` [RFC PATCH 1/2] remote: move remote group resolution to remote.c Usman Akinyemi
2026-03-06 18:12 ` Junio C Hamano
2026-03-09 0:43 ` Usman Akinyemi
2026-03-05 22:32 ` [RFC PATCH 2/2] push: support pushing to a remote group Usman Akinyemi
2026-03-07 2:12 ` Junio C Hamano [this message]
2026-03-09 0:56 ` Usman Akinyemi
2026-03-09 13:38 ` Junio C Hamano
2026-03-18 20:40 ` [RFC PATCH v2 0/2] push: add support for pushing to remote groups Usman Akinyemi
2026-03-18 20:40 ` [RFC PATCH v2 1/2] remote: move remote group resolution to remote.c Usman Akinyemi
2026-03-18 20:40 ` [RFC PATCH v2 2/2] push: support pushing to a remote group Usman Akinyemi
2026-03-18 20:57 ` Junio C Hamano
2026-03-18 21:58 ` Junio C Hamano
2026-03-18 22:25 ` Junio C Hamano
2026-03-19 17:02 ` Junio C Hamano
2026-03-25 18:42 ` Usman Akinyemi
2026-03-18 21:57 ` [RFC PATCH v2 0/2] push: add support for pushing to remote groups Junio C Hamano
2026-03-18 23:13 ` Usman Akinyemi
2026-03-25 19:09 ` [RFC PATCH v3 " Usman Akinyemi
2026-03-25 19:09 ` [RFC PATCH v3 1/2] remote: move remote group resolution to remote.c Usman Akinyemi
2026-03-25 19:09 ` [RFC PATCH v3 2/2] push: support pushing to a remote group Usman Akinyemi
2026-03-25 19:47 ` Junio C Hamano
2026-03-27 22:18 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4imsv13x.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
--cc=usmanakinyemi202@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox