git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Alex Henrie <alexhenrie24@gmail.com>,
	pclouds@gmail.com, Git mailing list <git@vger.kernel.org>
Subject: Re: [PATCH] branch: fix funny-sounding error message
Date: Tue, 5 May 2015 19:06:30 -0400	[thread overview]
Message-ID: <20150505230630.GC18817@peff.net> (raw)
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

  reply	other threads:[~2015-05-05 23:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  3:12 [PATCH] branch: fix funny-sounding error message Alex Henrie
2015-05-03 23:54 ` Junio C Hamano
2015-05-05 19:42   ` Alex Henrie
2015-05-05 21:58     ` Junio C Hamano
2015-05-05 23:06       ` Jeff King [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-04-02 21:27 Alex Henrie

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=20150505230630.GC18817@peff.net \
    --to=peff@peff.net \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@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;
as well as URLs for NNTP newsgroup(s).