-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Teach the "@{-1} syntax to "git branch"
This teaches the new "@{-1} syntax to refer to the previous branch to "git branch". After looking at somebody's faulty patch series on a topic branch too long, if you decide it is not worth merging, you can just say: $ git checkout master $ git branch -D @{-1} to get rid of it without having to type the name of the topic you now hate so much for wasting a lot of your time. Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Junio C Hamano
committed
Feb 14, 2009
1 parent
5cd12b8
commit 8415d5c
Showing
3 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
test_description='previous branch syntax @{-n}' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'branch -d @{-1}' ' | ||
test_commit A && | ||
git checkout -b junk && | ||
git checkout - && | ||
test "$(git symbolic-ref HEAD)" = refs/heads/master && | ||
git branch -d @{-1} && | ||
test_must_fail git rev-parse --verify refs/heads/junk | ||
' | ||
|
||
test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' | ||
git reflog expire --expire=now && | ||
git checkout -b junk2 && | ||
git checkout - && | ||
test "$(git symbolic-ref HEAD)" = refs/heads/master && | ||
test_must_fail git branch -d @{-12} && | ||
git rev-parse --verify refs/heads/master | ||
' | ||
|
||
test_done | ||
|