git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Christoffer Stjernlöf" <a@xkqr.org>, git@vger.kernel.org
Subject: Re: Bug: git branch returns EXIT_SUCCESS when no branches found
Date: Wed, 24 Apr 2019 13:11:23 +0200	[thread overview]
Message-ID: <20190424111123.GB8695@szeder.dev> (raw)
In-Reply-To: <xmqqmukf1yh9.fsf@gitster-ct.c.googlers.com>

On Wed, Apr 24, 2019 at 07:36:34PM +0900, Junio C Hamano wrote:
> 	if git merge-base --is-ancestor master "$DEV_BRANCH"
> 	then
> 		echo "master is an ancestor of $DEV_BRANCH"
> 	else
> 		echo "master has commits not in $DEV_BRANCH"
> 		git --no-pager log "master..$DEV_BRANCH" --
> 	fi

A non-zero exit code might indicate an error in 'git merge-base'
itself; I had basically the same if-else condition in a script of my
own that had to check the same thing...  until once I mistyped the
branchname, and, well, undesired behavior ensued.  After that I
added one more branch to the condition like this:

  git merge-base --is-ancestor master "$DEV_BRANCH"
  ret=$?
  if test $ret -gt 1
  then
        die "uh-oh, git merge-base errored out"
  elif test $ret -eq 0
  then
        echo "master is an ancestor of $DEV_BRANCH"
  else
        echo "master has commits not in $DEV_BRANCH"
  fi


      parent reply	other threads:[~2019-04-24 11:11 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
2019-04-24 10:53     ` Christoffer Stjernlöf
2019-04-24 10:47   ` Christoffer Stjernlöf
2019-04-24 11:11   ` SZEDER Gábor [this message]

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=20190424111123.GB8695@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=a@xkqr.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).