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

Re: git branch --set-upstream regression in master

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 16, 2011, 22:58 UTC
Message-ID
<7v7h58dri4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAG+J_DyxNpPevwfrJVkv3GBmv0tEXgW2LZtdHgarFoXb9Qqghw@mail.gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 9 quoted lines
> This used to be possible on the checked out branch:
>
>   $ git branch master --set-upstream origin/master
>
> Now it gives "fatal: Cannot force update the current branch." which is
> broken. You should be able to setup/change the tracking information on
> the checked out branch.
>
> It's apparently due to ci/forbid-unwanted-current-branch-update.
Does
	git branch --set-upstream master origin/master

work? If so then I wouldn't worry too much about it (your "arg then option" should be forbidden in the longer term anyway). If not, we would need to patch it.

Show 5 quoted lines
> (BTW, --set-upstream still needs to be fixed so that these mean the same
> thing:
>
>   $ git branch master --set-upstream origin/master
>   $ git branch --set-upstream origin/master master

If we are doing anythning, I think it needs to be fixed not to allow the former, period.

Show 5 quoted lines
> .. to just allow:
>
>   $ git branch --set-upstream origin/master
>
> w/o having to specify the checked-out branch.
That may be a nice feature enhancement, post 1.7.7 release.

I took a brief look at --set-upstream codepath, and I have to say that the implementation is totally broken with respect to an existing branch.

Given
	$ git branch master --set-upstream origin/master
it passes the exact same codepath as
	$ git branch master origin/master

uses, only with a different "track" flag, no? That is, it calls a function that is meant to _create_ branch "master" from given branch point "origin/master", namely create_branch(). And then create_branch(), contrary to its name, is littered with "dont_change_ref" special case to work it around, depending on the value of "track".

Previous: Jay SoffianNext: Junio C Hamano
Message 2 of 5 in “git branch --set-upstream regression in master”
  1. Jay SoffianSep 16, 2011
  2. Junio C HamanoSep 16, 2011
  3. Junio C HamanoSep 16, 2011
  4. Junio C HamanoSep 16, 2011
  5. Jay SoffianSep 17, 2011

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.