-
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.
rebase -i --autosquash: auto-squash commits
Teach a new option, --autosquash, to the interactive rebase. When the commit log message begins with "!fixup ...", and there is a commit whose title begins with the same ..., automatically modify the todo list of rebase -i so that the commit marked for squashing come right after the commit to be modified, and change the action of the moved commit from pick to squash. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Nanako Shiraishi
authored and
Junio C Hamano
committed
Jan 7, 2010
1 parent
0205e72
commit f59baa5
Showing
3 changed files
with
120 additions
and
0 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,73 @@ | ||
#!/bin/sh | ||
|
||
test_description='auto squash' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success setup ' | ||
echo 0 >file0 && | ||
git add . && | ||
test_tick && | ||
git commit -m "initial commit" && | ||
echo 0 >file1 && | ||
echo 2 >file2 && | ||
git add . && | ||
test_tick && | ||
git commit -m "first commit" && | ||
echo 3 >file3 && | ||
git add . && | ||
test_tick && | ||
git commit -m "second commit" && | ||
git tag base | ||
' | ||
|
||
test_expect_success 'auto fixup' ' | ||
git reset --hard base && | ||
echo 1 >file1 && | ||
git add -u && | ||
test_tick && | ||
git commit -m "fixup! first" | ||
git tag final-fixup && | ||
test_tick && | ||
git rebase --autosquash -i HEAD^^^ && | ||
git log --oneline >actual && | ||
test 3 = $(wc -l <actual) && | ||
git diff --exit-code final-fixup && | ||
test 1 = "$(git cat-file blob HEAD^:file1)" && | ||
test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) | ||
' | ||
|
||
test_expect_success 'auto squash' ' | ||
git reset --hard base && | ||
echo 1 >file1 && | ||
git add -u && | ||
test_tick && | ||
git commit -m "squash! first" | ||
git tag final-squash && | ||
test_tick && | ||
git rebase --autosquash -i HEAD^^^ && | ||
git log --oneline >actual && | ||
test 3 = $(wc -l <actual) && | ||
git diff --exit-code final-squash && | ||
test 1 = "$(git cat-file blob HEAD^:file1)" && | ||
test 2 = $(git cat-file commit HEAD^ | grep first | wc -l) | ||
' | ||
|
||
test_expect_success 'misspelled auto squash' ' | ||
git reset --hard base && | ||
echo 1 >file1 && | ||
git add -u && | ||
test_tick && | ||
git commit -m "squash! forst" | ||
git tag final-missquash && | ||
test_tick && | ||
git rebase --autosquash -i HEAD^^^ && | ||
git log --oneline >actual && | ||
test 4 = $(wc -l <actual) && | ||
git diff --exit-code final-missquash && | ||
test 0 = $(git rev-list final-missquash...HEAD | wc -l) | ||
' | ||
|
||
test_done |