Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] git-branch: avoid getting confused by empty or nonexisting branches.
Date: Fri, 22 Jul 2005 19:08:47 -0700	[thread overview]
Message-ID: <7vzmse6zps.fsf@assigned-by-dhcp.cox.net> (raw)

When not specifying the start point explicitly, we ended up
emitting ^0 in addition to the default HEAD.  Be careful to see
if we have "$2" before finding out which commit to base the new
branch on.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 git-branch-script |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

baf3c4ffceae925d836f19382611968699414cd6
diff --git a/git-branch-script b/git-branch-script
--- a/git-branch-script
+++ b/git-branch-script
@@ -3,7 +3,13 @@
 . git-sh-setup-script || die "Not a git archive"
 
 branchname="$1"
-rev=$(git-rev-parse --verify --default HEAD "$2"^0) || exit
+case "$2" in
+'')
+	head=HEAD ;;
+*)
+	head="$2^0" ;;
+esac
+rev=$(git-rev-parse --revs-only --verify "$head") || exit
 
 [ -z "$branchname" ] && die "git branch: I want a branch name"
 [ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"

                 reply	other threads:[~2005-07-23  2:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7vzmse6zps.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.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