summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-21 03:11:29 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-01-21 05:31:00 (GMT)
commitbcf316187699c5e97bf47c1b8a00c844bf809fbc (patch)
tree32db926508d63acebf15513e10c99dc4ee0c96df
parent11a6ddb2c8a81815ee9d5411638487ee99770a0b (diff)
downloadgit-bcf316187699c5e97bf47c1b8a00c844bf809fbc.zip
git-bcf316187699c5e97bf47c1b8a00c844bf809fbc.tar.gz
git-bcf316187699c5e97bf47c1b8a00c844bf809fbc.tar.bz2
git-rebase: allow rebasing a detached HEAD.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xgit-rebase.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index c8bd0f9..99cedad 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -275,8 +275,12 @@ case "$#" in
git-checkout "$2" || usage
;;
*)
- branch_name=`git symbolic-ref HEAD` || die "No current branch"
- branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
+ if branch_name=`git symbolic-ref -q HEAD`
+ then
+ branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
+ else
+ branch_name=HEAD ;# detached
+ fi
;;
esac
branch=$(git-rev-parse --verify "${branch_name}^0") || exit