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

Re: [PATCH] branch: fix funny-sounding error message

From
Jeff King <peff@peff.net>
Date
May 5, 2015, 23:06 UTC
Message-ID
<20150505230630.GC18817@peff.net>
In-Reply-To
<xmqqvbg6d6v3.fsf@gitster.dls.corp.google.com>
On Tue, May 05, 2015 at 02:58:24PM -0700, Junio C Hamano wrote:
> I think this "branch is NULL" condition is when an earlier call to
> branch_get() returned a NULL, and _one_ way to make that happen is
> to detach the HEAD.  There may be others, but I didn't check.

FWIW, since I have just been looking through the branch code, branch_get() should only return NULL when:

  1. We passed NULL or "HEAD" to it (i.e., we asked for the current branch). If
     you ask for a branch by name, you will always get a non-NULL return,
     even if that branch does not exist.
  2. There is no current branch (i.e., a detached HEAD).
I think the "no such branch" error message here:
               if (!branch) {
                        if (!argc || !strcmp(argv[0], "HEAD"))
                                die(_("could not unset upstream of HEAD when "
                                      "it does not point to any branch."));
			die(_("no such branch '%s'"), argv[0]);
	       }

cannot actually be triggered (and I double-checked that the test suite does not trigger it by replacing it with "exit(141)", which should cause even test_must_fail to complain).

-Peff
Previous: Junio C Hamano
Message 5 of 5 in “branch: fix funny-sounding error message”
  1. branch: fix funny-sounding error messageAlex Henrie, May 2, 2015
  2. Junio C HamanoMay 3, 2015
  3. Alex HenrieMay 5, 2015
  4. Junio C HamanoMay 5, 2015
  5. Jeff KingMay 5, 2015

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.