From a900999d7cd74f878686933a6341e3852726165d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 14:49:05 +0000 Subject: [PATCH 1/3] t2106: adjust style to the current conventions We settled on the style where the test cases' code starts by the opening single quote being on the `test_expect_*` line, and the closing quote being in its own line after the code. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t2106-update-index-assume-unchanged.sh | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh index 99d858c6b7..ff0947f388 100755 --- a/t/t2106-update-index-assume-unchanged.sh +++ b/t/t2106-update-index-assume-unchanged.sh @@ -5,20 +5,22 @@ test_description='git update-index --assume-unchanged test. . ./test-lib.sh -test_expect_success 'setup' \ - ': >file && - git add file && - git commit -m initial && - git branch other && - echo upstream >file && - git add file && - git commit -m upstream' +test_expect_success 'setup' ' + : >file && + git add file && + git commit -m initial && + git branch other && + echo upstream >file && + git add file && + git commit -m upstream +' -test_expect_success 'do not switch branches with dirty file' \ - 'git reset --hard && - git checkout other && - echo dirt >file && - git update-index --assume-unchanged file && - test_must_fail git checkout master' +test_expect_success 'do not switch branches with dirty file' ' + git reset --hard && + git checkout other && + echo dirt >file && + git update-index --assume-unchanged file && + test_must_fail git checkout master +' test_done From bce46b1adc57945c26dea91829dfa7315f9292e7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 14:49:06 +0000 Subject: [PATCH 2/3] t2106: make test independent of the current main branch name We do have this wonderful shortcut `git checkout -` to go back to the previous branch, thanks to the reflog. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t2106-update-index-assume-unchanged.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh index ff0947f388..3396f23363 100755 --- a/t/t2106-update-index-assume-unchanged.sh +++ b/t/t2106-update-index-assume-unchanged.sh @@ -20,7 +20,7 @@ test_expect_success 'do not switch branches with dirty file' ' git checkout other && echo dirt >file && git update-index --assume-unchanged file && - test_must_fail git checkout master + test_must_fail git checkout - ' test_done From b6e2a4f07c238e179e4d358e84a7f9e3a5c07005 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Nov 2020 14:49:07 +0000 Subject: [PATCH 3/3] t2106: ensure that the checkout fails for the expected reason During the transition of the test suite to a new default branch name, it was noticed that this test case succeeded for the wrong reason when the default branch name was overridden. While we fixed that in the previous commit, let's make sure that we look for a tell-tale in the error message that the `git checkout` failed for the reason we wanted it to fail. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t2106-update-index-assume-unchanged.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh index 3396f23363..2d450daf5c 100755 --- a/t/t2106-update-index-assume-unchanged.sh +++ b/t/t2106-update-index-assume-unchanged.sh @@ -20,7 +20,8 @@ test_expect_success 'do not switch branches with dirty file' ' git checkout other && echo dirt >file && git update-index --assume-unchanged file && - test_must_fail git checkout - + test_must_fail git checkout - 2>err && + test_i18ngrep overwritten err ' test_done