diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2007-09-25 16:43:15 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-26 00:42:17 -0700 |
commit | 73697a0b572f7f216d8355d83bf69e9b42e9a077 (patch) | |
tree | aa9eb581690eff932c80dcd0be14088dbeca454a /git-rebase--interactive.sh | |
parent | 61ab92df40b2c256299ad3d812ee0de14353098d (diff) | |
download | git-73697a0b572f7f216d8355d83bf69e9b42e9a077.tar.gz |
rebase -i: work on a detached HEAD
Earlier, rebase -i refused to rebase a detached HEAD. Now it no longer
does.
Incidentally, this fixes "git gc --auto" shadowing the true exit status.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rwxr-xr-x | git-rebase--interactive.sh | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 8e6e9431e8..823291d4af 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -317,17 +317,20 @@ do_next () { else NEWHEAD=$(git rev-parse HEAD) fi && - message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" && - git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD && - git symbolic-ref HEAD $HEADNAME && { + case $HEADNAME in + refs/*) + message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" && + git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD && + git symbolic-ref HEAD $HEADNAME + ;; + esac && { test ! -f "$DOTEST"/verbose || git diff --stat $(cat "$DOTEST"/head)..HEAD } && rm -rf "$DOTEST" && + git gc --auto && warn "Successfully rebased and updated $HEADNAME." - git gc --auto - exit } @@ -367,7 +370,11 @@ do HEADNAME=$(cat "$DOTEST"/head-name) HEAD=$(cat "$DOTEST"/head) - git symbolic-ref HEAD $HEADNAME && + case $HEADNAME in + refs/*) + git symbolic-ref HEAD $HEADNAME + ;; + esac && output git reset --hard $HEAD && rm -rf "$DOTEST" exit @@ -445,8 +452,8 @@ do test -z "$ONTO" && ONTO=$UPSTREAM : > "$DOTEST"/interactive || die "Could not mark as interactive" - git symbolic-ref HEAD > "$DOTEST"/head-name || - die "Could not get HEAD" + git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null || + echo "detached HEAD" > "$DOTEST"/head-name echo $HEAD > "$DOTEST"/head echo $UPSTREAM > "$DOTEST"/upstream |