mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Fix "git checkout -b foo ':/substring'"
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>
This commit is contained in:
parent
0509eb216f
commit
7dc4642989
|
@ -71,7 +71,8 @@ while test $# != 0; do
|
||||||
done
|
done
|
||||||
|
|
||||||
arg="$1"
|
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
|
then
|
||||||
[ -z "$rev" ] && die "unknown flag $arg"
|
[ -z "$rev" ] && die "unknown flag $arg"
|
||||||
new_name="$arg"
|
new_name="$arg"
|
||||||
|
@ -82,11 +83,11 @@ then
|
||||||
fi
|
fi
|
||||||
new="$rev"
|
new="$rev"
|
||||||
shift
|
shift
|
||||||
elif rev=$(git rev-parse --verify "$arg^{tree}" 2>/dev/null)
|
elif rev=$(git rev-parse --verify "$rev^{tree}" 2>/dev/null)
|
||||||
then
|
then
|
||||||
# checking out selected paths from a tree-ish.
|
# checking out selected paths from a tree-ish.
|
||||||
new="$rev"
|
new="$rev"
|
||||||
new_name="$arg^{tree}"
|
new_name="$rev^{tree}"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
[ "$1" = "--" ] && shift
|
[ "$1" = "--" ] && shift
|
||||||
|
|
Loading…
Reference in a new issue