Skip to content

Commit

Permalink
rebase: allow "-" short-hand for the previous branch
Browse files Browse the repository at this point in the history
Teach rebase the same shorthand as checkout and merge to name the
branch to rebase the current branch on; that is, that "-" means "the
branch we were previously on".

Requested-by: Tim Chase <git@tim.thechases.com>
Signed-off-by: Brian Gesiak <modocache@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brian Gesiak authored and Junio C Hamano committed Mar 19, 2014
1 parent 5f95c9f commit 4f40740
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ then
test "$fork_point" = auto && fork_point=t
;;
*) upstream_name="$1"
if test "$upstream_name" = "-"
then
upstream_name="@{-1}"
fi
shift
;;
esac
Expand Down
17 changes: 17 additions & 0 deletions t/t3400-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ test_expect_success 'rebase from ambiguous branch name' '
git rebase master
'

test_expect_success 'rebase off of the previous branch using "-"' '
git checkout master &&
git checkout HEAD^ &&
git rebase @{-1} >expect.messages &&
git merge-base master HEAD >expect.forkpoint &&
git checkout master &&
git checkout HEAD^ &&
git rebase - >actual.messages &&
git merge-base master HEAD >actual.forkpoint &&
test_cmp expect.forkpoint actual.forkpoint &&
# the next one is dubious---we may want to say "-",
# instead of @{-1}, in the message
test_i18ncmp expect.messages actual.messages
'

test_expect_success 'rebase a single mode change' '
git checkout master &&
git branch -D topic &&
Expand Down

0 comments on commit 4f40740

Please sign in to comment.