From: Junio C Hamano <gitster@pobox.com>
To: a@xkqr.org (Christoffer Stjernlöf)
Cc: git@vger.kernel.org
Subject: Re: Bug: git branch returns EXIT_SUCCESS when no branches found
Date: Wed, 24 Apr 2019 19:44:44 +0900 [thread overview]
Message-ID: <xmqqimv31y3n.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqqmukf1yh9.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Wed, 24 Apr 2019 19:36:34 +0900")
Junio C Hamano <gitster@pobox.com> writes:
> The list mode ...
> ... can
> also limit the branches whose tip commits can reach a named commit
> with the "--contains".
>
> $ DEV_BRANCH=cs/topic
> $ git branch --contains master "$DEV_BRANCH"
>
> asks the subcommand to show only the branches that can reach the
> commit at the tip of 'master', *AND* whose name match cs/topic. So
> it may show the cs/topic branch (and nothing else, even there are
> cs/topic1 or cs/topic/2 branches) if and only if that branch
> can reach the tip of 'master'.
One crucial bit is missing from my response. In general, a git
subcommand that shows zero or more things in response to a request
to list things that match criteria does *NOT* consider it an error
to make a request that happens to produce a zero result. The above
command will exit with non-zero status if 'master' does not name a
commit. But if cs/topic branch does not exist, of if the branch
does not contain 'master', the command will show "here are the
branches that match the criteria you gave me" by giving no lines in
its standard output, and exits with 0 to signal that what you see on
the screen indeed was computed correctly (as opposed to the command
internally crashing and failing to produce a result, in which case
you would want to be told with non-zero exit status).
next prev parent reply other threads:[~2019-04-24 10:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 10:13 Bug: git branch returns EXIT_SUCCESS when no branches found Christoffer Stjernlöf
2019-04-24 10:36 ` Junio C Hamano
2019-04-24 10:44 ` Junio C Hamano [this message]
2019-04-24 10:53 ` Christoffer Stjernlöf
2019-04-24 10:47 ` Christoffer Stjernlöf
2019-04-24 11:11 ` SZEDER Gábor
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=xmqqimv31y3n.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=a@xkqr.org \
--cc=git@vger.kernel.org \
/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).