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

Re: git push default doesn't make sense

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 30, 2021, 16:32 UTC
Message-ID
<60b3be1476401_b937208e1@natae.notmuch>
In-Reply-To
<d9e212fa-4c6a-f6ce-eab0-8073a65e96fd@gmail.com>
Mathias Kunter wrote:
Show 40 quoted lines
> Am 28.05.21 um 23:12 schrieb Felipe Contreras:
> 
> > Cloning automatically sets up an upstream branch for "master", and
> > therore it passes the safety check of `push.default=simple`, and that is
> > much more dangerous than pushing any other branch.
> > 
> > Why do we barf with "fix-1", but not "master"? Doesn't make sense.
> > 
> > This is what we want:
> > 
> > 	if (centralized &&
> > 		(branch->merge_nr && branch->merge && branch->remote_name))
> > 	{
> > 		if (branch->merge_nr != 1)
> > 			die(_("The current branch %s has multiple upstream branches, "
> > 			    "refusing to push."), branch->name);
> > 
> > 		/* Additional safety */
> > 		if (strcmp(branch->refname, branch->merge[0]->src))
> > 			die_push_simple(branch, remote);
> > 	}
> > 	refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
> > 
> > 
> > In other words: `simple` should be the same as `current`, except when
> > there's an upstream branch configured *and* the destination branch has a
> > different name.
> 
> I guess so. In particular, as a simple git user, I'd expect the 
> following to work out of the box, without having to manually adjust the 
> configuration settings:
> 
>    git clone ssh://originUrl .
>    git checkout -b myBranch
>    git push           # expected push to origin/myBranch, but fails
>    git push origin    # expected push to origin/myBranch, but fails
>    git remote add myRemote ssh://myRemoteUrl
>    git push myRemote  # expected push to myRemote/myBranch - works
> 
> Will your provided patch fix these failing push commands?
It's not really a patch (yet), but yeah: it will.
-- 
Felipe Contreras
Previous: Mathias KunterNext: Felipe Contreras
Message 7 of 12 in “git push doesn't use local branch name as default”
  1. Mathias KunterMay 28, 2021
  2. Elijah NewrenMay 28, 2021
  3. Mathias KunterMay 28, 2021
  4. Mathias KunterMay 28, 2021
  5. git push default doesn't make senseFelipe Contreras, May 28, 2021
  6. Mathias KunterMay 30, 2021
  7. Felipe ContrerasMay 30, 2021
  8. Felipe ContrerasMay 28, 2021
  9. Felipe ContrerasMay 28, 2021
  10. Elijah NewrenMay 28, 2021
  11. Felipe ContrerasMay 28, 2021
  12. Felipe ContrerasMay 28, 2021

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.