From 6672b9f962e4f01cae3c115ed54586a6f62aced3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 7 Jul 2016 17:52:50 +0200 Subject: t3404: add a test for the --gpg-sign option For the upcoming rebase--helper work (which will accelerate the interactive rebase noticably), it is important to verify that the --gpg-sign option is handled properly. Please note that this patch does this on the cheap, by verifying that the expected option is printed in the message of the 'edit' operation. We really should test that the interactive rebase signs the commits properly, iff GPG is available. This test is left for later. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3404-rebase-interactive.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 66348f11d1..aa393d2cac 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1281,4 +1281,12 @@ test_expect_success 'editor saves as CR/LF' ' ) ' +SQ="'" +test_expect_success 'rebase -i --gpg-sign=' ' + set_fake_editor && + FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \ + >out 2>err && + grep "$SQ-S\"S I Gner\"$SQ" err +' + test_done -- cgit v1.2.1 From c94e963b537be0371d4616ec4806b01b477feae0 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 7 Jul 2016 17:52:54 +0200 Subject: rebase -i: demonstrate a bug with --autosquash When rearranging the edit script, we happily mistake the comment character for a command, and the command for a SHA-1. As a consequence, when we move fixup! and squash! commits, our logic to skip lines with already handled SHA-1s mistakenly skips anything but the first commented-out pick line, too. The upcoming rebase--helper patches will address this bug, therefore we do not need to make the current autosquash code even more complex than it already is, just to fix this bug. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3415-rebase-autosquash.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 8f53e54ce4..9b71a49f02 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -271,4 +271,28 @@ test_expect_success 'autosquash with custom inst format' ' test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l) ' +set_backup_editor () { + write_script backup-editor.sh <<-\EOF + cp "$1" .git/backup-"$(basename "$1")" + EOF + test_set_editor "$PWD/backup-editor.sh" +} + +test_expect_failure 'autosquash with multiple empty patches' ' + test_tick && + git commit --allow-empty -m "empty" && + test_tick && + git commit --allow-empty -m "empty2" && + test_tick && + >fixup && + git add fixup && + git commit --fixup HEAD^^ && + ( + set_backup_editor && + GIT_USE_REBASE_HELPER=false \ + git rebase -i --force-rebase --autosquash HEAD~4 && + grep empty2 .git/backup-git-rebase-todo + ) +' + test_done -- cgit v1.2.1 From cbcd2cbd5942cc890c1a1125593e1108c3e6a077 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 7 Jul 2016 17:52:57 +0200 Subject: rebase -i: we allow extra spaces after fixup!/squash! This new test case ensures that we handle commit messages that start with fixup! or squash! followed by more than one space. While we do not generate such messages when committing with --fixup/--squash, it is perfectly legal for users to hand-craft their own fixup messages, and we heed Postel's law by being lenient. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t3415-rebase-autosquash.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 9b71a49f02..48346f1cc0 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -295,4 +295,13 @@ test_expect_failure 'autosquash with multiple empty patches' ' ) ' +test_expect_success 'extra spaces after fixup!' ' + base=$(git rev-parse HEAD) && + test_commit to-fixup && + git commit --allow-empty -m "fixup! to-fixup" && + git rebase -i --autosquash --keep-empty HEAD~2 && + parent=$(git rev-parse HEAD^) && + test $base = $parent +' + test_done -- cgit v1.2.1