git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix "git checkout -b foo ':/substring'"
@ 2008-02-02  3:06 Junio C Hamano
  2008-02-02  8:32 ` Daniel Barkalow
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-02-02  3:06 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-02  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-02  3:06 [PATCH] Fix "git checkout -b foo ':/substring'" Junio C Hamano
2008-02-02  8:32 ` Daniel Barkalow
2008-02-02  9:01   ` Junio C Hamano

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).