From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] Fix "git checkout -b foo ':/substring'"
Date: Fri, 01 Feb 2008 19:06:56 -0800 [thread overview]
Message-ID: <7v1w7w6oq7.fsf@gitster.siamese.dyndns.org> (raw)
Because ':/substring' extended SHA1 expression cannot take
postfix modifiers such as ^{tree} and ^{commit}, we would need
to do it in multiple steps. With the patch, you can start a new
branch from a randomly-picked commit whose message has the named
string in it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* As we advertize that ":/string" syntax is usable for any
command that wnats to take a commit object name in the
Release Notes, we might want to put this in 1.5.4 final. It
looks simple and safe enough.
diff --git a/git-checkout.sh b/git-checkout.sh
index 5621c69..bd74d70 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -71,7 +71,8 @@ while test $# != 0; do
done
arg="$1"
-if rev=$(git rev-parse --verify "$arg^0" 2>/dev/null)
+rev=$(git rev-parse --verify "$arg" 2>/dev/null)
+if rev=$(git rev-parse --verify "$rev^0" 2>/dev/null)
then
[ -z "$rev" ] && die "unknown flag $arg"
new_name="$arg"
@@ -82,11 +83,11 @@ then
fi
new="$rev"
shift
-elif rev=$(git rev-parse --verify "$arg^{tree}" 2>/dev/null)
+elif rev=$(git rev-parse --verify "$rev^{tree}" 2>/dev/null)
then
# checking out selected paths from a tree-ish.
new="$rev"
- new_name="$arg^{tree}"
+ new_name="$rev^{tree}"
shift
fi
[ "$1" = "--" ] && shift
next reply other threads:[~2008-02-02 3:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-02 3:06 Junio C Hamano [this message]
2008-02-02 8:32 ` [PATCH] Fix "git checkout -b foo ':/substring'" Daniel Barkalow
2008-02-02 9:01 ` Junio C Hamano
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=7v1w7w6oq7.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--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).