git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 2/2] push: support pushing to a remote group

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2026, 02:12 UTC
Message-ID
<xmqq4imsv13x.fsf@gitster.g>
In-Reply-To
<20260305223248.170785-3-usmanakinyemi202@gmail.com>
Usman Akinyemi <usmanakinyemi202@gmail.com> writes:
Show 27 quoted lines
> -	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 ...
Show 6 quoted lines
> +	/*
> +	 * 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.
Previous: Usman AkinyemiNext: Usman Akinyemi
Message 6 of 39 in “push: add support for pushing to remote groups”
  1. 0/2 push: add support for pushing to remote groupsUsman Akinyemi, Mar 5, 2026
  2. 1/2 remote: move remote group resolution to remote.cUsman Akinyemi, Mar 5, 2026
  3. Junio C HamanoMar 6, 2026
  4. Usman AkinyemiMar 9, 2026
  5. 2/2 push: support pushing to a remote groupUsman Akinyemi, Mar 5, 2026
  6. Junio C HamanoMar 7, 2026
  7. Usman AkinyemiMar 9, 2026
  8. Junio C HamanoMar 9, 2026
  9. 0/2 push: add support for pushing to remote groupsUsman Akinyemi, Mar 18, 2026
  10. 1/2 remote: move remote group resolution to remote.cUsman Akinyemi, Mar 18, 2026
  11. 2/2 push: support pushing to a remote groupUsman Akinyemi, Mar 18, 2026
  12. Junio C HamanoMar 18, 2026
  13. Junio C HamanoMar 18, 2026
  14. Junio C HamanoMar 18, 2026
  15. Junio C HamanoMar 19, 2026
  16. Usman AkinyemiMar 25, 2026
  17. Junio C HamanoMar 18, 2026
  18. Usman AkinyemiMar 18, 2026
  19. 0/2 push: add support for pushing to remote groupsUsman Akinyemi, Mar 25, 2026
  20. 1/2 remote: move remote group resolution to remote.cUsman Akinyemi, Mar 25, 2026
  21. 2/2 push: support pushing to a remote groupUsman Akinyemi, Mar 25, 2026
  22. Junio C HamanoMar 25, 2026
  23. Usman AkinyemiMar 31, 2026
  24. Usman AkinyemiMar 31, 2026
  25. Junio C HamanoApr 1, 2026
  26. Junio C HamanoMar 27, 2026
  27. 0/2 push: add support for pushing to remote groupsUsman Akinyemi, Apr 27, 2026
  28. 1/2 remote: move remote group resolution to remote.cUsman Akinyemi, Apr 27, 2026
  29. 2/2 push: support pushing to a remote groupUsman Akinyemi, Apr 27, 2026
  30. Junio C HamanoApr 28, 2026
  31. 0/3 push: add support for pushing to remote groupsUsman Akinyemi, May 3, 2026
  32. 1/3 remote: fix sign-compare warnings in push_cas_optionUsman Akinyemi, May 3, 2026
  33. 2/3 remote: move remote group resolution to remote.cUsman Akinyemi, May 3, 2026
  34. 3/3 push: support pushing to a remote groupUsman Akinyemi, May 3, 2026
  35. Kristoffer HaugsbakkMay 12, 2026
  36. 0/3 push: add support for pushing to remote groupsUsman Akinyemi, May 18, 2026
  37. 1/3 remote: fix sign-compare warnings in push_cas_optionUsman Akinyemi, May 18, 2026
  38. 2/3 remote: move remote group resolution to remote.cUsman Akinyemi, May 18, 2026
  39. 3/3 push: support pushing to a remote groupUsman Akinyemi, May 18, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.