From 2f68c99a3beefa5556eca76811deb443599e214a Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:06 +0000 Subject: t0000-basic: modernize test format Some tests in t0000-basic.sh used the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t0000-basic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 8ea31d187a..6e300be2ac 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -1014,7 +1014,7 @@ test_expect_success 'validate object ID for a known tree' ' ' test_expect_success 'showing tree with git ls-tree' ' - git ls-tree $tree >current + git ls-tree $tree >current ' test_expect_success 'git ls-tree output for a known tree' ' -- cgit v1.2.3 From 27990663f082da1a454507e1ee7e440524fcd090 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:07 +0000 Subject: t0030-stripspace: modernize test format Some tests in t0030-stripspace.sh used the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t0030-stripspace.sh | 560 ++++++++++++++++++++++++-------------------------- 1 file changed, 271 insertions(+), 289 deletions(-) diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index 0a5713c524..d1b3be8725 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -17,396 +17,378 @@ printf_git_stripspace () { printf "$1" | git stripspace } -test_expect_success \ - 'long lines without spaces should be unchanged' ' - echo "$ttt" >expect && - git stripspace actual && - test_cmp expect actual && - - echo "$ttt$ttt" >expect && - git stripspace actual && - test_cmp expect actual && - - echo "$ttt$ttt$ttt" >expect && - git stripspace actual && - test_cmp expect actual && - - echo "$ttt$ttt$ttt$ttt" >expect && - git stripspace actual && - test_cmp expect actual +test_expect_success 'long lines without spaces should be unchanged' ' + echo "$ttt" >expect && + git stripspace actual && + test_cmp expect actual && + + echo "$ttt$ttt" >expect && + git stripspace actual && + test_cmp expect actual && + + echo "$ttt$ttt$ttt" >expect && + git stripspace actual && + test_cmp expect actual && + + echo "$ttt$ttt$ttt$ttt" >expect && + git stripspace actual && + test_cmp expect actual ' -test_expect_success \ - 'lines with spaces at the beginning should be unchanged' ' - echo "$sss$ttt" >expect && - git stripspace actual && - test_cmp expect actual && +test_expect_success 'lines with spaces at the beginning should be unchanged' ' + echo "$sss$ttt" >expect && + git stripspace actual && + test_cmp expect actual && - echo "$sss$sss$ttt" >expect && - git stripspace actual && - test_cmp expect actual && + echo "$sss$sss$ttt" >expect && + git stripspace actual && + test_cmp expect actual && - echo "$sss$sss$sss$ttt" >expect && - git stripspace actual && - test_cmp expect actual + echo "$sss$sss$sss$ttt" >expect && + git stripspace actual && + test_cmp expect actual ' -test_expect_success \ - 'lines with intermediate spaces should be unchanged' ' - echo "$ttt$sss$ttt" >expect && - git stripspace actual && - test_cmp expect actual && +test_expect_success 'lines with intermediate spaces should be unchanged' ' + echo "$ttt$sss$ttt" >expect && + git stripspace actual && + test_cmp expect actual && - echo "$ttt$sss$sss$ttt" >expect && - git stripspace actual && - test_cmp expect actual + echo "$ttt$sss$sss$ttt" >expect && + git stripspace actual && + test_cmp expect actual ' -test_expect_success \ - 'consecutive blank lines should be unified' ' - printf "$ttt\n\n$ttt\n" > expect && - printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'consecutive blank lines should be unified' ' + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n\n$ttt\n" > expect && - printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && - printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt\n" > expect && - printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt$ttt\n" > expect && - printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && - printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && + printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt\n" > expect && - printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n\n$ttt\n" > expect && - printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && - printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt\n" > expect && - printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt$ttt\n" > expect && - printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$ttt$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && - printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual + printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && + printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual ' -test_expect_success \ - 'only consecutive blank lines should be completely removed' ' +test_expect_success 'only consecutive blank lines should be completely removed' ' + printf "\n" | git stripspace >actual && + test_must_be_empty actual && - printf "\n" | git stripspace >actual && - test_must_be_empty actual && + printf "\n\n\n" | git stripspace >actual && + test_must_be_empty actual && - printf "\n\n\n" | git stripspace >actual && - test_must_be_empty actual && + printf "$sss\n$sss\n$sss\n" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss\n$sss\n$sss\n" | git stripspace >actual && - test_must_be_empty actual && + printf "$sss$sss\n$sss\n\n" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss$sss\n$sss\n\n" | git stripspace >actual && - test_must_be_empty actual && + printf "\n$sss\n$sss$sss\n" | git stripspace >actual && + test_must_be_empty actual && - printf "\n$sss\n$sss$sss\n" | git stripspace >actual && - test_must_be_empty actual && + printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual && - test_must_be_empty actual && + printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual && + test_must_be_empty actual && - printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual && - test_must_be_empty actual && - - printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual && - test_must_be_empty actual + printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual && + test_must_be_empty actual ' -test_expect_success \ - 'consecutive blank lines at the beginning should be removed' ' - printf "$ttt\n" > expect && - printf "\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'consecutive blank lines at the beginning should be removed' ' + printf "$ttt\n" > expect && + printf "\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" > expect && - printf "\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n" > expect && + printf "\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n" > expect && - printf "\n\n\n$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt\n" > expect && - printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt$ttt\n" > expect && - printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt$ttt\n" > expect && + printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" > expect && + printf "$ttt\n" > expect && - printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual && - test_cmp expect actual + printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual && + test_cmp expect actual ' -test_expect_success \ - 'consecutive blank lines at the end should be removed' ' - printf "$ttt\n" > expect && - printf "$ttt\n\n" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'consecutive blank lines at the end should be removed' ' + printf "$ttt\n" > expect && + printf "$ttt\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" > expect && - printf "$ttt\n\n\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n" > expect && + printf "$ttt\n\n\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n" > expect && - printf "$ttt$ttt\n\n\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n" > expect && + printf "$ttt$ttt\n\n\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt\n" > expect && - printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt\n" > expect && + printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt$ttt\n" > expect && - printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt$ttt$ttt\n" > expect && + printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" > expect && + printf "$ttt\n" > expect && - printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual && - test_cmp expect actual + printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual && + test_cmp expect actual ' -test_expect_success \ - 'text without newline at end should end with newline' ' - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt" +test_expect_success 'text without newline at end should end with newline' ' + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt" ' # text plus spaces at the end: -test_expect_success \ - 'text plus spaces without newline at end should end with newline' ' - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" && - test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss" +test_expect_success 'text plus spaces without newline at end should end with newline' ' + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" && + test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss" ' -test_expect_success \ - 'text plus spaces without newline at end should not show spaces' ' - printf "$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$ttt$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$ttt$ttt$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$ttt$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$ttt$ttt$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$ttt$sss$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null +test_expect_success 'text plus spaces without newline at end should not show spaces' ' + printf "$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$ttt$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$ttt$ttt$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$ttt$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$ttt$ttt$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$ttt$sss$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null ' -test_expect_success \ - 'text plus spaces without newline should show the correct lines' ' - printf "$ttt\n" >expect && - printf "$ttt$sss" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'text plus spaces without newline should show the correct lines' ' + printf "$ttt\n" >expect && + printf "$ttt$sss" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" >expect && - printf "$ttt$sss$sss" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n" >expect && + printf "$ttt$sss$sss" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n" >expect && - printf "$ttt$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n" >expect && + printf "$ttt$sss$sss$sss" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n" >expect && - printf "$ttt$ttt$sss" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n" >expect && + printf "$ttt$ttt$sss" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n" >expect && - printf "$ttt$ttt$sss$sss" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n" >expect && + printf "$ttt$ttt$sss$sss" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt$ttt\n" >expect && - printf "$ttt$ttt$ttt$sss" | git stripspace >actual && - test_cmp expect actual + printf "$ttt$ttt$ttt\n" >expect && + printf "$ttt$ttt$ttt$sss" | git stripspace >actual && + test_cmp expect actual ' -test_expect_success \ - 'text plus spaces at end should not show spaces' ' - echo "$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - echo "$ttt$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - echo "$ttt$ttt$ttt$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - echo "$ttt$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - echo "$ttt$ttt$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - echo "$ttt$sss$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null +test_expect_success 'text plus spaces at end should not show spaces' ' + echo "$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + echo "$ttt$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + echo "$ttt$ttt$ttt$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + echo "$ttt$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + echo "$ttt$ttt$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + echo "$ttt$sss$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null ' -test_expect_success \ - 'text plus spaces at end should be cleaned and newline must remain' ' - echo "$ttt" >expect && - echo "$ttt$sss" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'text plus spaces at end should be cleaned and newline must remain' ' + echo "$ttt" >expect && + echo "$ttt$sss" | git stripspace >actual && + test_cmp expect actual && - echo "$ttt" >expect && - echo "$ttt$sss$sss" | git stripspace >actual && - test_cmp expect actual && + echo "$ttt" >expect && + echo "$ttt$sss$sss" | git stripspace >actual && + test_cmp expect actual && - echo "$ttt" >expect && - echo "$ttt$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + echo "$ttt" >expect && + echo "$ttt$sss$sss$sss" | git stripspace >actual && + test_cmp expect actual && - echo "$ttt$ttt" >expect && - echo "$ttt$ttt$sss" | git stripspace >actual && - test_cmp expect actual && + echo "$ttt$ttt" >expect && + echo "$ttt$ttt$sss" | git stripspace >actual && + test_cmp expect actual && - echo "$ttt$ttt" >expect && - echo "$ttt$ttt$sss$sss" | git stripspace >actual && - test_cmp expect actual && + echo "$ttt$ttt" >expect && + echo "$ttt$ttt$sss$sss" | git stripspace >actual && + test_cmp expect actual && - echo "$ttt$ttt$ttt" >expect && - echo "$ttt$ttt$ttt$sss" | git stripspace >actual && - test_cmp expect actual + echo "$ttt$ttt$ttt" >expect && + echo "$ttt$ttt$ttt$sss" | git stripspace >actual && + test_cmp expect actual ' # spaces only: -test_expect_success \ - 'spaces with newline at end should be replaced with empty string' ' - echo | git stripspace >actual && - test_must_be_empty actual && +test_expect_success 'spaces with newline at end should be replaced with empty string' ' + echo | git stripspace >actual && + test_must_be_empty actual && - echo "$sss" | git stripspace >actual && - test_must_be_empty actual && + echo "$sss" | git stripspace >actual && + test_must_be_empty actual && - echo "$sss$sss" | git stripspace >actual && - test_must_be_empty actual && + echo "$sss$sss" | git stripspace >actual && + test_must_be_empty actual && - echo "$sss$sss$sss" | git stripspace >actual && - test_must_be_empty actual && + echo "$sss$sss$sss" | git stripspace >actual && + test_must_be_empty actual && - echo "$sss$sss$sss$sss" | git stripspace >actual && - test_must_be_empty actual + echo "$sss$sss$sss$sss" | git stripspace >actual && + test_must_be_empty actual ' -test_expect_success \ - 'spaces without newline at end should not show spaces' ' - printf "" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$sss$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null && - printf "$sss$sss$sss$sss" | git stripspace >tmp && - ! grep " " tmp >/dev/null +test_expect_success 'spaces without newline at end should not show spaces' ' + printf "" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$sss$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null && + printf "$sss$sss$sss$sss" | git stripspace >tmp && + ! grep " " tmp >/dev/null ' -test_expect_success \ - 'spaces without newline at end should be replaced with empty string' ' - printf "" | git stripspace >actual && - test_must_be_empty actual && +test_expect_success 'spaces without newline at end should be replaced with empty string' ' + printf "" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss$sss" | git stripspace >actual && - test_must_be_empty actual && + printf "$sss$sss" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss$sss$sss" | git stripspace >actual && - test_must_be_empty actual && + printf "$sss$sss$sss" | git stripspace >actual && + test_must_be_empty actual && - printf "$sss$sss$sss$sss" | git stripspace >actual && - test_must_be_empty actual + printf "$sss$sss$sss$sss" | git stripspace >actual && + test_must_be_empty actual ' -test_expect_success \ - 'consecutive text lines should be unchanged' ' - printf "$ttt$ttt\n$ttt\n" >expect && - printf "$ttt$ttt\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && +test_expect_success 'consecutive text lines should be unchanged' ' + printf "$ttt$ttt\n$ttt\n" >expect && + printf "$ttt$ttt\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$ttt$ttt\n$ttt\n" >expect && - printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$ttt$ttt\n$ttt\n" >expect && + printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect && - printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect && + printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect && - printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect && + printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect && - printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual && - test_cmp expect actual && + printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect && + printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual && + test_cmp expect actual && - printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect && - printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual && - test_cmp expect actual + printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect && + printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual && + test_cmp expect actual ' test_expect_success 'strip comments, too' ' -- cgit v1.2.3 From 3c2f5d26c0d953c5c63557a5c97cddc528d62a55 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:08 +0000 Subject: t3210-pack-refs: modernize test format Some tests in t3210-pack-refs.sh used the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t3210-pack-refs.sh | 154 +++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 07a0ff93de..5ec89931bb 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -19,101 +19,101 @@ test_expect_success 'enable reflogs' ' git config core.logallrefupdates true ' -test_expect_success \ - 'prepare a trivial repository' \ - 'echo Hello > A && - git update-index --add A && - git commit -m "Initial commit." && - HEAD=$(git rev-parse --verify HEAD)' +test_expect_success 'prepare a trivial repository' ' + echo Hello > A && + git update-index --add A && + git commit -m "Initial commit." && + HEAD=$(git rev-parse --verify HEAD) +' SHA1= -test_expect_success \ - 'see if git show-ref works as expected' \ - 'git branch a && - SHA1=$(cat .git/refs/heads/a) && - echo "$SHA1 refs/heads/a" >expect && - git show-ref a >result && - test_cmp expect result' - -test_expect_success \ - 'see if a branch still exists when packed' \ - 'git branch b && - git pack-refs --all && - rm -f .git/refs/heads/b && - echo "$SHA1 refs/heads/b" >expect && - git show-ref b >result && - test_cmp expect result' +test_expect_success 'see if git show-ref works as expected' ' + git branch a && + SHA1=$(cat .git/refs/heads/a) && + echo "$SHA1 refs/heads/a" >expect && + git show-ref a >result && + test_cmp expect result +' + +test_expect_success 'see if a branch still exists when packed' ' + git branch b && + git pack-refs --all && + rm -f .git/refs/heads/b && + echo "$SHA1 refs/heads/b" >expect && + git show-ref b >result && + test_cmp expect result +' test_expect_success 'git branch c/d should barf if branch c exists' ' - git branch c && - git pack-refs --all && - rm -f .git/refs/heads/c && - test_must_fail git branch c/d + git branch c && + git pack-refs --all && + rm -f .git/refs/heads/c && + test_must_fail git branch c/d ' -test_expect_success \ - 'see if a branch still exists after git pack-refs --prune' \ - 'git branch e && - git pack-refs --all --prune && - echo "$SHA1 refs/heads/e" >expect && - git show-ref e >result && - test_cmp expect result' +test_expect_success 'see if a branch still exists after git pack-refs --prune' ' + git branch e && + git pack-refs --all --prune && + echo "$SHA1 refs/heads/e" >expect && + git show-ref e >result && + test_cmp expect result +' test_expect_success 'see if git pack-refs --prune remove ref files' ' - git branch f && - git pack-refs --all --prune && - ! test -f .git/refs/heads/f + git branch f && + git pack-refs --all --prune && + ! test -f .git/refs/heads/f ' test_expect_success 'see if git pack-refs --prune removes empty dirs' ' - git branch r/s/t && - git pack-refs --all --prune && - ! test -e .git/refs/heads/r + git branch r/s/t && + git pack-refs --all --prune && + ! test -e .git/refs/heads/r ' -test_expect_success \ - 'git branch g should work when git branch g/h has been deleted' \ - 'git branch g/h && - git pack-refs --all --prune && - git branch -d g/h && - git branch g && - git pack-refs --all && - git branch -d g' +test_expect_success 'git branch g should work when git branch g/h has been deleted' ' + git branch g/h && + git pack-refs --all --prune && + git branch -d g/h && + git branch g && + git pack-refs --all && + git branch -d g +' test_expect_success 'git branch i/j/k should barf if branch i exists' ' - git branch i && - git pack-refs --all --prune && - test_must_fail git branch i/j/k + git branch i && + git pack-refs --all --prune && + test_must_fail git branch i/j/k +' + +test_expect_success 'test git branch k after branch k/l/m and k/lm have been deleted' ' + git branch k/l && + git branch k/lm && + git branch -d k/l && + git branch k/l/m && + git branch -d k/l/m && + git branch -d k/lm && + git branch k ' -test_expect_success \ - 'test git branch k after branch k/l/m and k/lm have been deleted' \ - 'git branch k/l && - git branch k/lm && - git branch -d k/l && - git branch k/l/m && - git branch -d k/l/m && - git branch -d k/lm && - git branch k' - -test_expect_success \ - 'test git branch n after some branch deletion and pruning' \ - 'git branch n/o && - git branch n/op && - git branch -d n/o && - git branch n/o/p && - git branch -d n/op && - git pack-refs --all --prune && - git branch -d n/o/p && - git branch n' - -test_expect_success \ - 'see if up-to-date packed refs are preserved' \ - 'git branch q && - git pack-refs --all --prune && - git update-ref refs/heads/q refs/heads/q && - ! test -f .git/refs/heads/q' +test_expect_success 'test git branch n after some branch deletion and pruning' ' + git branch n/o && + git branch n/op && + git branch -d n/o && + git branch n/o/p && + git branch -d n/op && + git pack-refs --all --prune && + git branch -d n/o/p && + git branch n +' + +test_expect_success 'see if up-to-date packed refs are preserved' ' + git branch q && + git pack-refs --all --prune && + git update-ref refs/heads/q refs/heads/q && + ! test -f .git/refs/heads/q +' test_expect_success 'pack, prune and repack' ' git tag foo && -- cgit v1.2.3 From 58db6e450b52cda221a9e8288e61ceb12553e651 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:09 +0000 Subject: t1001-read-tree-m-2way: modernize test format Some tests are still using the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t1001-read-tree-m-2way.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 3fb1b0c162..88c524f655 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -26,7 +26,7 @@ TEST_PASSES_SANITIZE_LEAK=true . "$TEST_DIRECTORY"/lib-read-tree.sh read_tree_twoway () { - git read-tree -m "$1" "$2" && git ls-files --stage + git read-tree -m "$1" "$2" && git ls-files --stage } compare_change () { -- cgit v1.2.3 From a10bb2ded5e0c7cdbf047a22c3346215d215844c Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:10 +0000 Subject: t1002-read-tree-m-u-2way: modernize test format Some tests are still using the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t1002-read-tree-m-u-2way.sh | 589 +++++++++++++++++++++--------------------- 1 file changed, 293 insertions(+), 296 deletions(-) diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index cdc077ce12..a7c2ed0d7c 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -37,315 +37,312 @@ check_cache_at () { esac } -test_expect_success \ - setup \ - 'echo frotz >frotz && - echo nitfol >nitfol && - echo bozbar >bozbar && - echo rezrov >rezrov && - git update-index --add nitfol bozbar rezrov && - treeH=$(git write-tree) && - echo treeH $treeH && - git ls-tree $treeH && - - echo gnusto >bozbar && - git update-index --add frotz bozbar --force-remove rezrov && - git ls-files --stage >M.out && - treeM=$(git write-tree) && - echo treeM $treeM && - git ls-tree $treeM && - cp bozbar bozbar.M && - cp frotz frotz.M && - cp nitfol nitfol.M && - git diff-tree $treeH $treeM' - -test_expect_success \ - '1, 2, 3 - no carry forward' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >1-3.out && - cmp M.out 1-3.out && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol && - check_cache_at bozbar clean && - check_cache_at frotz clean && - check_cache_at nitfol clean' - -test_expect_success \ - '4 - carry forward local addition.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo "+100644 X 0 yomin" >expected && - echo yomin >yomin && - git update-index --add yomin && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >4.out && - test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out && - compare_change 4diff.out expected && - check_cache_at yomin clean && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol && - echo yomin >yomin1 && - diff yomin yomin1 && - rm -f yomin1' - -test_expect_success \ - '5 - carry forward local addition.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - read_tree_u_must_succeed -m -u $treeH && - echo yomin >yomin && - git update-index --add yomin && - echo yomin yomin >yomin && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >5.out && - test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out && - compare_change 5diff.out expected && - check_cache_at yomin dirty && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol && - : dirty index should have prevented -u from checking it out. && - echo yomin yomin >yomin1 && - diff yomin yomin1 && - rm -f yomin1' - -test_expect_success \ - '6 - local addition already has the same.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo frotz >frotz && - git update-index --add frotz && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >6.out && - test_cmp M.out 6.out && - check_cache_at frotz clean && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol && - echo frotz >frotz1 && - diff frotz frotz1 && - rm -f frotz1' - -test_expect_success \ - '7 - local addition already has the same.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo frotz >frotz && - git update-index --add frotz && - echo frotz frotz >frotz && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >7.out && - test_cmp M.out 7.out && - check_cache_at frotz dirty && - test_cmp bozbar.M bozbar && - test_cmp nitfol.M nitfol && - : dirty index should have prevented -u from checking it out. && - echo frotz frotz >frotz1 && - diff frotz frotz1 && - rm -f frotz1' - -test_expect_success \ - '8 - conflicting addition.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo frotz frotz >frotz && - git update-index --add frotz && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '9 - conflicting addition.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo frotz frotz >frotz && - git update-index --add frotz && - echo frotz >frotz && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '10 - path removed.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo rezrov >rezrov && - git update-index --add rezrov && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >10.out && - cmp M.out 10.out && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol +test_expect_success setup ' + echo frotz >frotz && + echo nitfol >nitfol && + echo bozbar >bozbar && + echo rezrov >rezrov && + git update-index --add nitfol bozbar rezrov && + treeH=$(git write-tree) && + echo treeH $treeH && + git ls-tree $treeH && + + echo gnusto >bozbar && + git update-index --add frotz bozbar --force-remove rezrov && + git ls-files --stage >M.out && + treeM=$(git write-tree) && + echo treeM $treeM && + git ls-tree $treeM && + cp bozbar bozbar.M && + cp frotz frotz.M && + cp nitfol nitfol.M && + git diff-tree $treeH $treeM ' -test_expect_success \ - '11 - dirty path removed.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo rezrov >rezrov && - git update-index --add rezrov && - echo rezrov rezrov >rezrov && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '12 - unmatching local changes being removed.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo rezrov rezrov >rezrov && - git update-index --add rezrov && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '13 - unmatching local changes being removed.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo rezrov rezrov >rezrov && - git update-index --add rezrov && - echo rezrov >rezrov && - ! read_tree_u_must_succeed -m -u $treeH $treeM' +test_expect_success '1, 2, 3 - no carry forward' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >1-3.out && + cmp M.out 1-3.out && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol && + check_cache_at bozbar clean && + check_cache_at frotz clean && + check_cache_at nitfol clean +' + +test_expect_success '4 - carry forward local addition.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo "+100644 X 0 yomin" >expected && + echo yomin >yomin && + git update-index --add yomin && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >4.out && + test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out && + compare_change 4diff.out expected && + check_cache_at yomin clean && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol && + echo yomin >yomin1 && + diff yomin yomin1 && + rm -f yomin1 +' + +test_expect_success '5 - carry forward local addition.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + read_tree_u_must_succeed -m -u $treeH && + echo yomin >yomin && + git update-index --add yomin && + echo yomin yomin >yomin && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >5.out && + test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out && + compare_change 5diff.out expected && + check_cache_at yomin dirty && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol && + : dirty index should have prevented -u from checking it out. && + echo yomin yomin >yomin1 && + diff yomin yomin1 && + rm -f yomin1 +' + +test_expect_success '6 - local addition already has the same.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo frotz >frotz && + git update-index --add frotz && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >6.out && + test_cmp M.out 6.out && + check_cache_at frotz clean && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol && + echo frotz >frotz1 && + diff frotz frotz1 && + rm -f frotz1 +' + +test_expect_success '7 - local addition already has the same.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo frotz >frotz && + git update-index --add frotz && + echo frotz frotz >frotz && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >7.out && + test_cmp M.out 7.out && + check_cache_at frotz dirty && + test_cmp bozbar.M bozbar && + test_cmp nitfol.M nitfol && + : dirty index should have prevented -u from checking it out. && + echo frotz frotz >frotz1 && + diff frotz frotz1 && + rm -f frotz1 +' + +test_expect_success '8 - conflicting addition.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo frotz frotz >frotz && + git update-index --add frotz && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '9 - conflicting addition.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo frotz frotz >frotz && + git update-index --add frotz && + echo frotz >frotz && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '10 - path removed.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo rezrov >rezrov && + git update-index --add rezrov && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >10.out && + cmp M.out 10.out && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol +' + +test_expect_success '11 - dirty path removed.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo rezrov >rezrov && + git update-index --add rezrov && + echo rezrov rezrov >rezrov && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '12 - unmatching local changes being removed.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo rezrov rezrov >rezrov && + git update-index --add rezrov && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '13 - unmatching local changes being removed.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo rezrov rezrov >rezrov && + git update-index --add rezrov && + echo rezrov >rezrov && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' cat >expected <nitfol && - git update-index --add nitfol && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >14.out && - test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out && - compare_change 14diff.out expected && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - check_cache_at nitfol clean && - echo nitfol nitfol >nitfol1 && - diff nitfol nitfol1 && - rm -f nitfol1' - -test_expect_success \ - '15 - unchanged in two heads.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo nitfol nitfol >nitfol && - git update-index --add nitfol && - echo nitfol nitfol nitfol >nitfol && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >15.out && - test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out && - compare_change 15diff.out expected && - check_cache_at nitfol dirty && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - echo nitfol nitfol nitfol >nitfol1 && - diff nitfol nitfol1 && - rm -f nitfol1' - -test_expect_success \ - '16 - conflicting local change.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo bozbar bozbar >bozbar && - git update-index --add bozbar && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '17 - conflicting local change.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo bozbar bozbar >bozbar && - git update-index --add bozbar && - echo bozbar bozbar bozbar >bozbar && - ! read_tree_u_must_succeed -m -u $treeH $treeM' - -test_expect_success \ - '18 - local change already having a good result.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo gnusto >bozbar && - git update-index --add bozbar && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >18.out && - test_cmp M.out 18.out && - check_cache_at bozbar clean && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol +test_expect_success '14 - unchanged in two heads.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo nitfol nitfol >nitfol && + git update-index --add nitfol && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >14.out && + test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out && + compare_change 14diff.out expected && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + check_cache_at nitfol clean && + echo nitfol nitfol >nitfol1 && + diff nitfol nitfol1 && + rm -f nitfol1 ' -test_expect_success \ - '19 - local change already having a good result, further modified.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo gnusto >bozbar && - git update-index --add bozbar && - echo gnusto gnusto >bozbar && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >19.out && - test_cmp M.out 19.out && - check_cache_at bozbar dirty && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol && - echo gnusto gnusto >bozbar1 && - diff bozbar bozbar1 && - rm -f bozbar1' - -test_expect_success \ - '20 - no local change, use new tree.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo bozbar >bozbar && - git update-index --add bozbar && - read_tree_u_must_succeed -m -u $treeH $treeM && - git ls-files --stage >20.out && - test_cmp M.out 20.out && - check_cache_at bozbar clean && - test_cmp bozbar.M bozbar && - test_cmp frotz.M frotz && - test_cmp nitfol.M nitfol +test_expect_success '15 - unchanged in two heads.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo nitfol nitfol >nitfol && + git update-index --add nitfol && + echo nitfol nitfol nitfol >nitfol && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >15.out && + test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out && + compare_change 15diff.out expected && + check_cache_at nitfol dirty && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + echo nitfol nitfol nitfol >nitfol1 && + diff nitfol nitfol1 && + rm -f nitfol1 ' -test_expect_success \ - '21 - no local change, dirty cache.' \ - 'rm -f .git/index nitfol bozbar rezrov frotz && - read_tree_u_must_succeed --reset -u $treeH && - echo bozbar >bozbar && - git update-index --add bozbar && - echo gnusto gnusto >bozbar && - ! read_tree_u_must_succeed -m -u $treeH $treeM' +test_expect_success '16 - conflicting local change.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo bozbar bozbar >bozbar && + git update-index --add bozbar && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '17 - conflicting local change.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo bozbar bozbar >bozbar && + git update-index --add bozbar && + echo bozbar bozbar bozbar >bozbar && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' + +test_expect_success '18 - local change already having a good result.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo gnusto >bozbar && + git update-index --add bozbar && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >18.out && + test_cmp M.out 18.out && + check_cache_at bozbar clean && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol +' + +test_expect_success '19 - local change already having a good result, further modified.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo gnusto >bozbar && + git update-index --add bozbar && + echo gnusto gnusto >bozbar && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >19.out && + test_cmp M.out 19.out && + check_cache_at bozbar dirty && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol && + echo gnusto gnusto >bozbar1 && + diff bozbar bozbar1 && + rm -f bozbar1 +' + +test_expect_success '20 - no local change, use new tree.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo bozbar >bozbar && + git update-index --add bozbar && + read_tree_u_must_succeed -m -u $treeH $treeM && + git ls-files --stage >20.out && + test_cmp M.out 20.out && + check_cache_at bozbar clean && + test_cmp bozbar.M bozbar && + test_cmp frotz.M frotz && + test_cmp nitfol.M nitfol +' + +test_expect_success '21 - no local change, dirty cache.' ' + rm -f .git/index nitfol bozbar rezrov frotz && + read_tree_u_must_succeed --reset -u $treeH && + echo bozbar >bozbar && + git update-index --add bozbar && + echo gnusto gnusto >bozbar && + ! read_tree_u_must_succeed -m -u $treeH $treeM +' # Also make sure we did not break DF vs DF/DF case. -test_expect_success \ - 'DF vs DF/DF case setup.' \ - 'rm -f .git/index && - echo DF >DF && - git update-index --add DF && - treeDF=$(git write-tree) && - echo treeDF $treeDF && - git ls-tree $treeDF && - - rm -f DF && - mkdir DF && - echo DF/DF >DF/DF && - git update-index --add --remove DF DF/DF && - treeDFDF=$(git write-tree) && - echo treeDFDF $treeDFDF && - git ls-tree $treeDFDF && - git ls-files --stage >DFDF.out' - -test_expect_success \ - 'DF vs DF/DF case test.' \ - 'rm -f .git/index && - rm -fr DF && - echo DF >DF && - git update-index --add DF && - read_tree_u_must_succeed -m -u $treeDF $treeDFDF && - git ls-files --stage >DFDFcheck.out && - test_cmp DFDF.out DFDFcheck.out && - check_cache_at DF/DF clean' +test_expect_success 'DF vs DF/DF case setup.' ' + rm -f .git/index && + echo DF >DF && + git update-index --add DF && + treeDF=$(git write-tree) && + echo treeDF $treeDF && + git ls-tree $treeDF && + + rm -f DF && + mkdir DF && + echo DF/DF >DF/DF && + git update-index --add --remove DF DF/DF && + treeDFDF=$(git write-tree) && + echo treeDFDF $treeDFDF && + git ls-tree $treeDFDF && + git ls-files --stage >DFDF.out +' + +test_expect_success 'DF vs DF/DF case test.' ' + rm -f .git/index && + rm -fr DF && + echo DF >DF && + git update-index --add DF && + read_tree_u_must_succeed -m -u $treeDF $treeDFDF && + git ls-files --stage >DFDFcheck.out && + test_cmp DFDF.out DFDFcheck.out && + check_cache_at DF/DF clean +' test_done -- cgit v1.2.3 From 350c484239838679d360fd647ebe97946d9bffd0 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:11 +0000 Subject: t1006-cat-file: modernize test format Some tests in t1006-cat-file.sh used the older four space indent format. Update these to use tabs. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t1006-cat-file.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 8eac74b59c..2e70490a30 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -351,30 +351,30 @@ do done test_expect_success "--batch-check for a non-existent named object" ' - test "foobar42 missing + test "foobar42 missing foobar84 missing" = \ - "$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)" + "$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)" ' test_expect_success "--batch-check for a non-existent hash" ' - test "0000000000000000000000000000000000000042 missing + test "0000000000000000000000000000000000000042 missing 0000000000000000000000000000000000000084 missing" = \ "$( ( echo 0000000000000000000000000000000000000042 && echo_without_newline 0000000000000000000000000000000000000084 ) | - git cat-file --batch-check)" + git cat-file --batch-check)" ' test_expect_success "--batch for an existent and a non-existent hash" ' - test "$tag_sha1 tag $tag_size + test "$tag_sha1 tag $tag_size $tag_content 0000000000000000000000000000000000000000 missing" = \ - "$( ( echo $tag_sha1 && - echo_without_newline 0000000000000000000000000000000000000000 ) | - git cat-file --batch)" + "$( ( echo $tag_sha1 && + echo_without_newline 0000000000000000000000000000000000000000 ) | + git cat-file --batch)" ' test_expect_success "--batch-check for an empty line" ' - test " missing" = "$(echo | git cat-file --batch-check)" + test " missing" = "$(echo | git cat-file --batch-check)" ' test_expect_success 'empty --batch-check notices missing object' ' @@ -425,13 +425,13 @@ deadbeef missing missing" test_expect_success "--batch-check with multiple sha1s gives correct format" ' - test "$batch_check_output" = \ - "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)" + test "$batch_check_output" = \ + "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)" ' test_expect_success "--batch-check, -z with multiple sha1s gives correct format" ' - echo_without_newline_nul "$batch_check_input" >in && - test "$batch_check_output" = "$(git cat-file --batch-check -z in && + test "$batch_check_output" = "$(git cat-file --batch-check -z Date: Thu, 18 May 2023 20:03:12 +0000 Subject: t3500-cherry: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t3500-cherry.sh | 69 ++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index 0458a58b4b..78c3eac54b 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -16,46 +16,43 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME GIT_AUTHOR_EMAIL=bogus_email_address export GIT_AUTHOR_EMAIL -test_expect_success \ - 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \ - 'echo First > A && - git update-index --add A && - test_tick && - git commit -m "Add A." && - - git checkout -b my-topic-branch && - - echo Second > B && - git update-index --add B && - test_tick && - git commit -m "Add B." && - - echo AnotherSecond > C && - git update-index --add C && - test_tick && - git commit -m "Add C." && - - git checkout -f main && - rm -f B C && - - echo Third >> A && - git update-index A && - test_tick && - git commit -m "Modify A." && - - expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* + .*" +test_expect_success 'prepare repository with topic branch, and check cherry finds the 2 patches from there' ' + echo First > A && + git update-index --add A && + test_tick && + git commit -m "Add A." && + + git checkout -b my-topic-branch && + + echo Second > B && + git update-index --add B && + test_tick && + git commit -m "Add B." && + + echo AnotherSecond > C && + git update-index --add C && + test_tick && + git commit -m "Add C." && + + git checkout -f main && + rm -f B C && + + echo Third >> A && + git update-index A && + test_tick && + git commit -m "Modify A." && + + expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* + .*" ' -test_expect_success \ - 'check that cherry with limit returns only the top patch'\ - 'expr "$(echo $(git cherry main my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" +test_expect_success 'check that cherry with limit returns only the top patch' ' + expr "$(echo $(git cherry main my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" ' -test_expect_success \ - 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ - 'git cherry-pick my-topic-branch^0 && - echo $(git cherry main my-topic-branch) && - expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* - .*" +test_expect_success 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' ' + git cherry-pick my-topic-branch^0 && + echo $(git cherry main my-topic-branch) && + expr "$(echo $(git cherry main my-topic-branch) )" : "+ [^ ]* - .*" ' test_expect_success 'cherry ignores whitespace' ' -- cgit v1.2.3 From 0aa0266c4b6ad147c3275e078db547b69353b7ce Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:13 +0000 Subject: t3700-add: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t3700-add.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 82dd768944..7623689da2 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -24,17 +24,17 @@ test_mode_in_index () { esac } -test_expect_success \ - 'Test of git add' \ - 'touch foo && git add foo' +test_expect_success 'Test of git add' ' + touch foo && git add foo +' -test_expect_success \ - 'Post-check that foo is in the index' \ - 'git ls-files foo | grep foo' +test_expect_success 'Post-check that foo is in the index' ' + git ls-files foo | grep foo +' -test_expect_success \ - 'Test that "git add -- -q" works' \ - 'touch -- -q && git add -- -q' +test_expect_success 'Test that "git add -- -q" works' ' + touch -- -q && git add -- -q +' BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch' @@ -284,14 +284,14 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' ' rm -f foo2 test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' ' - git config add.ignore-errors 1 && - git reset --hard && - date >foo1 && - date >foo2 && - chmod 0 foo2 && - test_must_fail git add --verbose --no-ignore-errors . && - ! ( git ls-files foo1 | grep foo1 ) && - git config add.ignore-errors 0 + git config add.ignore-errors 1 && + git reset --hard && + date >foo1 && + date >foo2 && + chmod 0 foo2 && + test_must_fail git add --verbose --no-ignore-errors . && + ! ( git ls-files foo1 | grep foo1 ) && + git config add.ignore-errors 0 ' rm -f foo2 -- cgit v1.2.3 From a8fcc0ac89566ce2ddd4eb88e1d601613f0028fd Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:14 +0000 Subject: t3903-stash: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t3903-stash.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 376cc8f4ab..0b3dfeaea2 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1211,19 +1211,19 @@ test_expect_success 'stash with file including $IFS character' ' ' test_expect_success 'stash with pathspec matching multiple paths' ' - echo original >file && - echo original >other-file && - git commit -m "two" file other-file && - echo modified >file && - echo modified >other-file && - git stash push -- "*file" && - echo original >expect && - test_cmp expect file && - test_cmp expect other-file && - git stash pop && - echo modified >expect && - test_cmp expect file && - test_cmp expect other-file + echo original >file && + echo original >other-file && + git commit -m "two" file other-file && + echo modified >file && + echo modified >other-file && + git stash push -- "*file" && + echo original >expect && + test_cmp expect file && + test_cmp expect other-file && + git stash pop && + echo modified >expect && + test_cmp expect file && + test_cmp expect other-file ' test_expect_success 'stash push -p with pathspec shows no changes only once' ' -- cgit v1.2.3 From 9cfcbcc095fbe6bc4a1f366281bd80e53d5bb473 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:15 +0000 Subject: t4002-diff-basic: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t4002-diff-basic.sh | 243 +++++++++++++++++++++++++------------------------- 1 file changed, 121 insertions(+), 122 deletions(-) diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index ea52e5b91b..d524d4057d 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -284,132 +284,131 @@ cmp_diff_files_output () { test_cmp "$1" .test-tmp } -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree $tree_O $tree_A >.test-a && - cmp -s .test-a .test-plain-OA' - -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree -r $tree_O $tree_A >.test-a && - cmp -s .test-a .test-recursive-OA' - -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree $tree_O $tree_B >.test-a && - cmp -s .test-a .test-plain-OB' - -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree -r $tree_O $tree_B >.test-a && - cmp -s .test-a .test-recursive-OB' - -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree $tree_A $tree_B >.test-a && - cmp -s .test-a .test-plain-AB' - -test_expect_success \ - 'diff-tree of known trees.' \ - 'git diff-tree -r $tree_A $tree_B >.test-a && - cmp -s .test-a .test-recursive-AB' - -test_expect_success \ - 'diff-tree --stdin of known trees.' \ - 'echo $tree_A $tree_B | git diff-tree --stdin > .test-a && - echo $tree_A $tree_B > .test-plain-ABx && - cat .test-plain-AB >> .test-plain-ABx && - cmp -s .test-a .test-plain-ABx' - -test_expect_success \ - 'diff-tree --stdin of known trees.' \ - 'echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a && - echo $tree_A $tree_B > .test-recursive-ABx && - cat .test-recursive-AB >> .test-recursive-ABx && - cmp -s .test-a .test-recursive-ABx' - -test_expect_success \ - 'diff-cache O with A in cache' \ - 'git read-tree $tree_A && - git diff-index --cached $tree_O >.test-a && - cmp -s .test-a .test-recursive-OA' - -test_expect_success \ - 'diff-cache O with B in cache' \ - 'git read-tree $tree_B && - git diff-index --cached $tree_O >.test-a && - cmp -s .test-a .test-recursive-OB' - -test_expect_success \ - 'diff-cache A with B in cache' \ - 'git read-tree $tree_B && - git diff-index --cached $tree_A >.test-a && - cmp -s .test-a .test-recursive-AB' - -test_expect_success \ - 'diff-files with O in cache and A checked out' \ - 'rm -fr Z [A-Z][A-Z] && - git read-tree $tree_A && - git checkout-index -f -a && - git read-tree --reset $tree_O && - test_must_fail git update-index --refresh -q && - git diff-files >.test-a && - cmp_diff_files_output .test-a .test-recursive-OA' - -test_expect_success \ - 'diff-files with O in cache and B checked out' \ - 'rm -fr Z [A-Z][A-Z] && - git read-tree $tree_B && - git checkout-index -f -a && - git read-tree --reset $tree_O && - test_must_fail git update-index --refresh -q && - git diff-files >.test-a && - cmp_diff_files_output .test-a .test-recursive-OB' - -test_expect_success \ - 'diff-files with A in cache and B checked out' \ - 'rm -fr Z [A-Z][A-Z] && - git read-tree $tree_B && - git checkout-index -f -a && - git read-tree --reset $tree_A && - test_must_fail git update-index --refresh -q && - git diff-files >.test-a && - cmp_diff_files_output .test-a .test-recursive-AB' +test_expect_success 'diff-tree of known trees.' ' + git diff-tree $tree_O $tree_A >.test-a && + cmp -s .test-a .test-plain-OA +' + +test_expect_success 'diff-tree of known trees.' ' + git diff-tree -r $tree_O $tree_A >.test-a && + cmp -s .test-a .test-recursive-OA +' + +test_expect_success 'diff-tree of known trees.' ' + git diff-tree $tree_O $tree_B >.test-a && + cmp -s .test-a .test-plain-OB +' + +test_expect_success 'diff-tree of known trees.' ' + git diff-tree -r $tree_O $tree_B >.test-a && + cmp -s .test-a .test-recursive-OB +' + +test_expect_success 'diff-tree of known trees.' ' + git diff-tree $tree_A $tree_B >.test-a && + cmp -s .test-a .test-plain-AB +' + +test_expect_success 'diff-tree of known trees.' ' + git diff-tree -r $tree_A $tree_B >.test-a && + cmp -s .test-a .test-recursive-AB +' + +test_expect_success 'diff-tree --stdin of known trees.' ' + echo $tree_A $tree_B | git diff-tree --stdin > .test-a && + echo $tree_A $tree_B > .test-plain-ABx && + cat .test-plain-AB >> .test-plain-ABx && + cmp -s .test-a .test-plain-ABx +' + +test_expect_success 'diff-tree --stdin of known trees.' ' + echo $tree_A $tree_B | git diff-tree -r --stdin > .test-a && + echo $tree_A $tree_B > .test-recursive-ABx && + cat .test-recursive-AB >> .test-recursive-ABx && + cmp -s .test-a .test-recursive-ABx +' + +test_expect_success 'diff-cache O with A in cache' ' + git read-tree $tree_A && + git diff-index --cached $tree_O >.test-a && + cmp -s .test-a .test-recursive-OA +' + +test_expect_success 'diff-cache O with B in cache' ' + git read-tree $tree_B && + git diff-index --cached $tree_O >.test-a && + cmp -s .test-a .test-recursive-OB +' + +test_expect_success 'diff-cache A with B in cache' ' + git read-tree $tree_B && + git diff-index --cached $tree_A >.test-a && + cmp -s .test-a .test-recursive-AB +' + +test_expect_success 'diff-files with O in cache and A checked out' ' + rm -fr Z [A-Z][A-Z] && + git read-tree $tree_A && + git checkout-index -f -a && + git read-tree --reset $tree_O && + test_must_fail git update-index --refresh -q && + git diff-files >.test-a && + cmp_diff_files_output .test-a .test-recursive-OA +' + +test_expect_success 'diff-files with O in cache and B checked out' ' + rm -fr Z [A-Z][A-Z] && + git read-tree $tree_B && + git checkout-index -f -a && + git read-tree --reset $tree_O && + test_must_fail git update-index --refresh -q && + git diff-files >.test-a && + cmp_diff_files_output .test-a .test-recursive-OB +' + +test_expect_success 'diff-files with A in cache and B checked out' ' + rm -fr Z [A-Z][A-Z] && + git read-tree $tree_B && + git checkout-index -f -a && + git read-tree --reset $tree_A && + test_must_fail git update-index --refresh -q && + git diff-files >.test-a && + cmp_diff_files_output .test-a .test-recursive-AB +' ################################################################ # Now we have established the baseline, we do not have to # rely on individual object ID values that much. -test_expect_success \ - 'diff-tree O A == diff-tree -R A O' \ - 'git diff-tree $tree_O $tree_A >.test-a && - git diff-tree -R $tree_A $tree_O >.test-b && - cmp -s .test-a .test-b' - -test_expect_success \ - 'diff-tree -r O A == diff-tree -r -R A O' \ - 'git diff-tree -r $tree_O $tree_A >.test-a && - git diff-tree -r -R $tree_A $tree_O >.test-b && - cmp -s .test-a .test-b' - -test_expect_success \ - 'diff-tree B A == diff-tree -R A B' \ - 'git diff-tree $tree_B $tree_A >.test-a && - git diff-tree -R $tree_A $tree_B >.test-b && - cmp -s .test-a .test-b' - -test_expect_success \ - 'diff-tree -r B A == diff-tree -r -R A B' \ - 'git diff-tree -r $tree_B $tree_A >.test-a && - git diff-tree -r -R $tree_A $tree_B >.test-b && - cmp -s .test-a .test-b' - -test_expect_success \ - 'diff can read from stdin' \ - 'test_must_fail git diff --no-index -- MN - < NN | - grep -v "^index" | sed "s#/-#/NN#" >.test-a && - test_must_fail git diff --no-index -- MN NN | - grep -v "^index" >.test-b && - test_cmp .test-a .test-b' +test_expect_success 'diff-tree O A == diff-tree -R A O' ' + git diff-tree $tree_O $tree_A >.test-a && + git diff-tree -R $tree_A $tree_O >.test-b && + cmp -s .test-a .test-b +' + +test_expect_success 'diff-tree -r O A == diff-tree -r -R A O' ' + git diff-tree -r $tree_O $tree_A >.test-a && + git diff-tree -r -R $tree_A $tree_O >.test-b && + cmp -s .test-a .test-b +' + +test_expect_success 'diff-tree B A == diff-tree -R A B' ' + git diff-tree $tree_B $tree_A >.test-a && + git diff-tree -R $tree_A $tree_B >.test-b && + cmp -s .test-a .test-b +' + +test_expect_success 'diff-tree -r B A == diff-tree -r -R A B' ' + git diff-tree -r $tree_B $tree_A >.test-a && + git diff-tree -r -R $tree_A $tree_B >.test-b && + cmp -s .test-a .test-b' + +test_expect_success'diff can read from stdin' ' + test_must_fail git diff --no-index -- MN - < NN | + grep -v "^index" | sed "s#/-#/NN#" >.test-a && + test_must_fail git diff --no-index -- MN NN | + grep -v "^index" >.test-b && + test_cmp .test-a .test-b +' test_done -- cgit v1.2.3 From 9297229d15e4159c288dbce8250409d8d5be23e3 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:16 +0000 Subject: t4003-diff-rename-1: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t4003-diff-rename-1.sh | 62 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh index 181e9683a7..ebe091828c 100755 --- a/t/t4003-diff-rename-1.sh +++ b/t/t4003-diff-rename-1.sh @@ -11,20 +11,20 @@ TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash -test_expect_success \ - 'prepare reference tree' \ - 'COPYING_test_data >COPYING && - echo frotz >rezrov && - git update-index --add COPYING rezrov && - tree=$(git write-tree) && - echo $tree' - -test_expect_success \ - 'prepare work tree' \ - 'sed -e 's/HOWEVER/However/' COPYING.1 && - sed -e 's/GPL/G.P.L/g' COPYING.2 && - rm -f COPYING && - git update-index --add --remove COPYING COPYING.?' +test_expect_success 'prepare reference tree' ' + COPYING_test_data >COPYING && + echo frotz >rezrov && + git update-index --add COPYING rezrov && + tree=$(git write-tree) && + echo $tree +' + +test_expect_success 'prepare work tree' ' + sed -e 's/HOWEVER/However/' COPYING.1 && + sed -e 's/GPL/G.P.L/g' COPYING.2 && + rm -f COPYING && + git update-index --add --remove COPYING COPYING.? +' # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # both are slightly edited, and unchanged rezrov. So we say you @@ -57,14 +57,14 @@ rename to COPYING.2 + This file is licensed under the G.P.L v2, or a later version EOF -test_expect_success \ - 'validate output from rename/copy detection (#1)' \ - 'compare_diff_patch current expected' +test_expect_success 'validate output from rename/copy detection (#1)' ' + compare_diff_patch current expected +' -test_expect_success \ - 'prepare work tree again' \ - 'mv COPYING.2 COPYING && - git update-index --add --remove COPYING COPYING.1 COPYING.2' +test_expect_success 'prepare work tree again' ' + mv COPYING.2 COPYING && + git update-index --add --remove COPYING COPYING.1 COPYING.2 +' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # both are slightly edited, and unchanged rezrov. So we say you @@ -95,14 +95,14 @@ copy to COPYING.1 + However, in order to allow a migration to GPLv3 if that seems like EOF -test_expect_success \ - 'validate output from rename/copy detection (#2)' \ - 'compare_diff_patch current expected' +test_expect_success 'validate output from rename/copy detection (#2)' ' + compare_diff_patch current expected +' -test_expect_success \ - 'prepare work tree once again' \ - 'COPYING_test_data >COPYING && - git update-index --add --remove COPYING COPYING.1' +test_expect_success 'prepare work tree once again' ' + COPYING_test_data >COPYING && + git update-index --add --remove COPYING COPYING.1 +' # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # but COPYING is not edited. We say you copy-and-edit COPYING.1; this @@ -123,8 +123,8 @@ copy to COPYING.1 + However, in order to allow a migration to GPLv3 if that seems like EOF -test_expect_success \ - 'validate output from rename/copy detection (#3)' \ - 'compare_diff_patch current expected' +test_expect_success 'validate output from rename/copy detection (#3)' ' + compare_diff_patch current expected +' test_done -- cgit v1.2.3 From 93fc423e9ad2ffd2454d461792eada18e8890497 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:17 +0000 Subject: t4004-diff-rename-symlink: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t4004-diff-rename-symlink.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh index 8def4d4aee..1d70d4d221 100755 --- a/t/t4004-diff-rename-symlink.sh +++ b/t/t4004-diff-rename-symlink.sh @@ -14,21 +14,21 @@ TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-diff.sh -test_expect_success SYMLINKS \ - 'prepare reference tree' \ - 'echo xyzzy | tr -d '\\\\'012 >yomin && - ln -s xyzzy frotz && - git update-index --add frotz yomin && - tree=$(git write-tree) && - echo $tree' +test_expect_success SYMLINKS 'prepare reference tree' ' + echo xyzzy | tr -d '\\\\'012 >yomin && + ln -s xyzzy frotz && + git update-index --add frotz yomin && + tree=$(git write-tree) && + echo $tree +' -test_expect_success SYMLINKS \ - 'prepare work tree' \ - 'mv frotz rezrov && - rm -f yomin && - ln -s xyzzy nitfol && - ln -s xzzzy bozbar && - git update-index --add --remove frotz rezrov nitfol bozbar yomin' +test_expect_success SYMLINKS 'prepare work tree' ' + mv frotz rezrov && + rm -f yomin && + ln -s xyzzy nitfol && + ln -s xzzzy bozbar && + git update-index --add --remove frotz rezrov nitfol bozbar yomin +' # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and @@ -36,9 +36,9 @@ test_expect_success SYMLINKS \ # rezrov and nitfol are rename/copy of frotz and bozbar should be # a new creation. -test_expect_success SYMLINKS 'setup diff output' " - GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current && - cat >expected <<\EOF +test_expect_success SYMLINKS 'setup diff output' ' + GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current && + cat >expected <<\EOF diff --git a/bozbar b/bozbar new file mode 120000 --- /dev/null @@ -62,10 +62,10 @@ deleted file mode 100644 -xyzzy \ No newline at end of file EOF -" +' -test_expect_success SYMLINKS \ - 'validate diff output' \ - 'compare_diff_patch current expected' +test_expect_success SYMLINKS 'validate diff output' ' + compare_diff_patch current expected +' test_done -- cgit v1.2.3 From 3da9be913a2db647714011bd352cd31847fe7b04 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:18 +0000 Subject: t4202-log: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t4202-log.sh b/t/t4202-log.sh index ae73aef922..f5c0f06a56 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -2343,10 +2343,10 @@ test_expect_success 'log --decorate does not include things outside filter' ' ' test_expect_success 'log --end-of-options' ' - git update-ref refs/heads/--source HEAD && - git log --end-of-options --source >actual && - git log >expect && - test_cmp expect actual + git update-ref refs/heads/--source HEAD && + git log --end-of-options --source >actual && + git log >expect && + test_cmp expect actual ' test_expect_success 'set up commits with different authors' ' -- cgit v1.2.3 From 1afebc92ef51bc164b5ed072d777e5a19c832970 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:19 +0000 Subject: t4206-log-follow-harder-copies: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t4206-log-follow-harder-copies.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/t/t4206-log-follow-harder-copies.sh b/t/t4206-log-follow-harder-copies.sh index 33ecf82c7f..9167b0351f 100755 --- a/t/t4206-log-follow-harder-copies.sh +++ b/t/t4206-log-follow-harder-copies.sh @@ -16,29 +16,29 @@ Line 2 Line 3 ' -test_expect_success \ - 'add a file path0 and commit.' \ - 'git add path0 && - git commit -m "Add path0"' +test_expect_success 'add a file path0 and commit.' ' + git add path0 && + git commit -m "Add path0" +' echo >path0 'New line 1 New line 2 New line 3 ' -test_expect_success \ - 'Change path0.' \ - 'git add path0 && - git commit -m "Change path0"' +test_expect_success 'Change path0.' ' + git add path0 && + git commit -m "Change path0" +' cat path1 -test_expect_success \ - 'copy path0 to path1.' \ - 'git add path1 && - git commit -m "Copy path1 from path0"' +test_expect_success 'copy path0 to path1.' ' + git add path1 && + git commit -m "Copy path1 from path0" +' -test_expect_success \ - 'find the copy path0 -> path1 harder' \ - 'git log --follow --name-status --pretty="format:%s" path1 > current' +test_expect_success 'find the copy path0 -> path1 harder' ' + git log --follow --name-status --pretty="format:%s" path1 > current +' cat >expected <<\EOF Copy path1 from path0 @@ -51,8 +51,8 @@ Add path0 A path0 EOF -test_expect_success \ - 'validate the output.' \ - 'compare_diff_patch current expected' +test_expect_success 'validate the output.' ' + compare_diff_patch current expected +' test_done -- cgit v1.2.3 From e478a5208733b41ed2eaa2ab81ebd028451e95b5 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:20 +0000 Subject: t5300-pack-object: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t5300-pack-object.sh | 184 ++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index d2ce236d61..745089479c 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -208,7 +208,7 @@ test_expect_success 'unpack with OFS_DELTA' ' ' test_expect_success 'unpack with OFS_DELTA (core.fsyncmethod=batch)' ' - check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION" + check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION" ' test_expect_success 'compare delta flavors' ' @@ -263,97 +263,97 @@ test_expect_success 'survive missing objects/pack directory' ' ) ' -test_expect_success \ - 'verify pack' \ - 'git verify-pack test-1-${packname_1}.idx \ - test-2-${packname_2}.idx \ - test-3-${packname_3}.idx' - -test_expect_success \ - 'verify pack -v' \ - 'git verify-pack -v test-1-${packname_1}.idx \ - test-2-${packname_2}.idx \ - test-3-${packname_3}.idx' - -test_expect_success \ - 'verify-pack catches mismatched .idx and .pack files' \ - 'cat test-1-${packname_1}.idx >test-3.idx && - cat test-2-${packname_2}.pack >test-3.pack && - if git verify-pack test-3.idx - then false - else :; - fi' - -test_expect_success \ - 'verify-pack catches a corrupted pack signature' \ - 'cat test-1-${packname_1}.pack >test-3.pack && - echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 && - if git verify-pack test-3.idx - then false - else :; - fi' - -test_expect_success \ - 'verify-pack catches a corrupted pack version' \ - 'cat test-1-${packname_1}.pack >test-3.pack && - echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 && - if git verify-pack test-3.idx - then false - else :; - fi' - -test_expect_success \ - 'verify-pack catches a corrupted type/size of the 1st packed object data' \ - 'cat test-1-${packname_1}.pack >test-3.pack && - echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 && - if git verify-pack test-3.idx - then false - else :; - fi' - -test_expect_success \ - 'verify-pack catches a corrupted sum of the index file itself' \ - 'l=$(wc -c test-3.pack && - printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l && - if git verify-pack test-3.pack - then false - else :; - fi' - -test_expect_success \ - 'build pack index for an existing pack' \ - 'cat test-1-${packname_1}.pack >test-3.pack && - git index-pack -o tmp.idx test-3.pack && - cmp tmp.idx test-1-${packname_1}.idx && - - git index-pack --promisor=message test-3.pack && - cmp test-3.idx test-1-${packname_1}.idx && - echo message >expect && - test_cmp expect test-3.promisor && - - cat test-2-${packname_2}.pack >test-3.pack && - git index-pack -o tmp.idx test-2-${packname_2}.pack && - cmp tmp.idx test-2-${packname_2}.idx && - - git index-pack test-3.pack && - cmp test-3.idx test-2-${packname_2}.idx && - - cat test-3-${packname_3}.pack >test-3.pack && - git index-pack -o tmp.idx test-3-${packname_3}.pack && - cmp tmp.idx test-3-${packname_3}.idx && - - git index-pack test-3.pack && - cmp test-3.idx test-3-${packname_3}.idx && - - cat test-1-${packname_1}.pack >test-4.pack && - rm -f test-4.keep && - git index-pack --keep=why test-4.pack && - cmp test-1-${packname_1}.idx test-4.idx && - test -f test-4.keep && - - :' +test_expect_success 'verify pack' ' + git verify-pack test-1-${packname_1}.idx \ + test-2-${packname_2}.idx \ + test-3-${packname_3}.idx +' + +test_expect_success 'verify pack -v' ' + git verify-pack -v test-1-${packname_1}.idx \ + test-2-${packname_2}.idx \ + test-3-${packname_3}.idx +' + +test_expect_success 'verify-pack catches mismatched .idx and .pack files' ' + cat test-1-${packname_1}.idx >test-3.idx && + cat test-2-${packname_2}.pack >test-3.pack && + if git verify-pack test-3.idx + then false + else :; + fi +' + +test_expect_success 'verify-pack catches a corrupted pack signature' ' + cat test-1-${packname_1}.pack >test-3.pack && + echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 && + if git verify-pack test-3.idx + then false + else :; + fi +' + +test_expect_success 'verify-pack catches a corrupted pack version' ' + cat test-1-${packname_1}.pack >test-3.pack && + echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 && + if git verify-pack test-3.idx + then false + else :; + fi +' + +test_expect_success 'verify-pack catches a corrupted type/size of the 1st packed object data' ' + cat test-1-${packname_1}.pack >test-3.pack && + echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 && + if git verify-pack test-3.idx + then false + else :; + fi +' + +test_expect_success 'verify-pack catches a corrupted sum of the index file itself' ' + l=$(wc -c test-3.pack && + printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l && + if git verify-pack test-3.pack + then false + else :; + fi +' + +test_expect_success 'build pack index for an existing pack' ' + cat test-1-${packname_1}.pack >test-3.pack && + git index-pack -o tmp.idx test-3.pack && + cmp tmp.idx test-1-${packname_1}.idx && + + git index-pack --promisor=message test-3.pack && + cmp test-3.idx test-1-${packname_1}.idx && + echo message >expect && + test_cmp expect test-3.promisor && + + cat test-2-${packname_2}.pack >test-3.pack && + git index-pack -o tmp.idx test-2-${packname_2}.pack && + cmp tmp.idx test-2-${packname_2}.idx && + + git index-pack test-3.pack && + cmp test-3.idx test-2-${packname_2}.idx && + + cat test-3-${packname_3}.pack >test-3.pack && + git index-pack -o tmp.idx test-3-${packname_3}.pack && + cmp tmp.idx test-3-${packname_3}.idx && + + git index-pack test-3.pack && + cmp test-3.idx test-3-${packname_3}.idx && + + cat test-1-${packname_1}.pack >test-4.pack && + rm -f test-4.keep && + git index-pack --keep=why test-4.pack && + cmp test-1-${packname_1}.idx test-4.idx && + test -f test-4.keep && + + : +' test_expect_success 'unpacking with --strict' ' -- cgit v1.2.3 From cc0c1ad9adee35b9af45acfa58ff0efb1c3dc3cc Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:21 +0000 Subject: t5301-sliding-window: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t5301-sliding-window.sh | 100 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh index 3ccaaeb397..226490d60d 100755 --- a/t/t5301-sliding-window.sh +++ b/t/t5301-sliding-window.sh @@ -8,55 +8,55 @@ test_description='mmap sliding window tests' TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh -test_expect_success \ - 'setup' \ - 'rm -f .git/index* && - for i in a b c - do - echo $i >$i && - test-tool genrandom "$i" 32768 >>$i && - git update-index --add $i || return 1 - done && - echo d >d && cat c >>d && git update-index --add d && - tree=$(git write-tree) && - commit1=$(git commit-tree $tree $i && + test-tool genrandom "$i" 32768 >>$i && + git update-index --add $i || return 1 + done && + echo d >d && cat c >>d && git update-index --add d && + tree=$(git write-tree) && + commit1=$(git commit-tree $tree Date: Thu, 18 May 2023 20:03:22 +0000 Subject: t5303-pack-corruption-resilience: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t5303-pack-corruption-resilience.sh | 584 +++++++++++++++++----------------- 1 file changed, 292 insertions(+), 292 deletions(-) diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh index 2926e8dfc4..61469ef4a6 100755 --- a/t/t5303-pack-corruption-resilience.sh +++ b/t/t5303-pack-corruption-resilience.sh @@ -59,304 +59,304 @@ do_corrupt_object() { printf '\0' > zero -test_expect_success \ - 'initial setup validation' \ - 'create_test_files && - create_new_pack && - git prune-packed && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'create corruption in header of first object' \ - 'do_corrupt_object $blob_1 0 < zero && - test_must_fail git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_1 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and loose copy of first delta allows for partial recovery' \ - 'git prune-packed && - test_must_fail git cat-file blob $blob_2 > /dev/null && - mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - test_must_fail git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'create corruption in data of first object' \ - 'create_new_pack && - git prune-packed && - chmod +w ${pack}.pack && - perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack && - test_must_fail git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_1 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and loose copy of second object allows for partial recovery' \ - 'git prune-packed && - test_must_fail git cat-file blob $blob_2 > /dev/null && - mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - test_must_fail git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'create corruption in header of first delta' \ - 'create_new_pack && - git prune-packed && - do_corrupt_object $blob_2 0 < zero && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'create corruption in data of first delta' \ - 'create_new_pack && - git prune-packed && - chmod +w ${pack}.pack && - perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \ - 'create_new_pack && - git prune-packed && - do_corrupt_object $blob_2 2 < zero && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' \ - 'create_new_pack --delta-base-offset && - git prune-packed && - do_corrupt_object $blob_2 2 < zero && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack --delta-base-offset && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'corruption #1 in delta base reference of first delta (OBJ_OFS_DELTA)' \ - 'create_new_pack --delta-base-offset && - git prune-packed && - printf "\001" | do_corrupt_object $blob_2 2 && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_2 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack --delta-base-offset && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and a redundant pack allows for full recovery too' \ - 'do_corrupt_object $blob_2 2 < zero && - git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null && - mv ${pack}.idx tmp && - git hash-object -t blob -w file_1 && - git hash-object -t blob -w file_2 && - printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack && - git prune-packed && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'corruption of delta base reference pointing to wrong object' \ - 'create_new_pack --delta-base-offset && - git prune-packed && - printf "\220\033" | do_corrupt_object $blob_3 2 && - git cat-file blob $blob_1 >/dev/null && - git cat-file blob $blob_2 >/dev/null && - test_must_fail git cat-file blob $blob_3 >/dev/null' - -test_expect_success \ - '... but having a loose copy allows for full recovery' \ - 'mv ${pack}.idx tmp && - git hash-object -t blob -w file_3 && - mv tmp ${pack}.idx && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - '... and then a repack "clears" the corruption' \ - 'do_repack --delta-base-offset --no-reuse-delta && - git prune-packed && - git verify-pack ${pack}.pack && - git cat-file blob $blob_1 > /dev/null && - git cat-file blob $blob_2 > /dev/null && - git cat-file blob $blob_3 > /dev/null' - -test_expect_success \ - 'corrupting header to have too small output buffer fails unpack' \ - 'create_new_pack && - git prune-packed && - printf "\262\001" | do_corrupt_object $blob_1 0 && - test_must_fail git cat-file blob $blob_1 > /dev/null && - test_must_fail git cat-file blob $blob_2 > /dev/null && - test_must_fail git cat-file blob $blob_3 > /dev/null' +test_expect_success 'initial setup validation' ' + create_test_files && + create_new_pack && + git prune-packed && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'create corruption in header of first object' ' + do_corrupt_object $blob_1 0 < zero && + test_must_fail git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_1 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and loose copy of first delta allows for partial recovery' ' + git prune-packed && + test_must_fail git cat-file blob $blob_2 > /dev/null && + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + test_must_fail git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'create corruption in data of first object' ' + create_new_pack && + git prune-packed && + chmod +w ${pack}.pack && + perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack && + test_must_fail git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_1 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and loose copy of second object allows for partial recovery' ' + git prune-packed && + test_must_fail git cat-file blob $blob_2 > /dev/null && + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + test_must_fail git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'create corruption in header of first delta' ' + create_new_pack && + git prune-packed && + do_corrupt_object $blob_2 0 < zero && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'create corruption in data of first delta' ' + create_new_pack && + git prune-packed && + chmod +w ${pack}.pack && + perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' ' + create_new_pack && + git prune-packed && + do_corrupt_object $blob_2 2 < zero && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' ' + create_new_pack --delta-base-offset && + git prune-packed && + do_corrupt_object $blob_2 2 < zero && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack --delta-base-offset && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'corruption #1 in delta base reference of first delta (OBJ_OFS_DELTA)' ' + create_new_pack --delta-base-offset && + git prune-packed && + printf "\001" | do_corrupt_object $blob_2 2 && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_2 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack --delta-base-offset && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and a redundant pack allows for full recovery too' ' + do_corrupt_object $blob_2 2 < zero && + git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null && + mv ${pack}.idx tmp && + git hash-object -t blob -w file_1 && + git hash-object -t blob -w file_2 && + printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack && + git prune-packed && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'corruption of delta base reference pointing to wrong object' ' + create_new_pack --delta-base-offset && + git prune-packed && + printf "\220\033" | do_corrupt_object $blob_3 2 && + git cat-file blob $blob_1 >/dev/null && + git cat-file blob $blob_2 >/dev/null && + test_must_fail git cat-file blob $blob_3 >/dev/null +' + +test_expect_success '... but having a loose copy allows for full recovery' ' + mv ${pack}.idx tmp && + git hash-object -t blob -w file_3 && + mv tmp ${pack}.idx && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success '... and then a repack "clears" the corruption' ' + do_repack --delta-base-offset --no-reuse-delta && + git prune-packed && + git verify-pack ${pack}.pack && + git cat-file blob $blob_1 > /dev/null && + git cat-file blob $blob_2 > /dev/null && + git cat-file blob $blob_3 > /dev/null +' + +test_expect_success 'corrupting header to have too small output buffer fails unpack' ' + create_new_pack && + git prune-packed && + printf "\262\001" | do_corrupt_object $blob_1 0 && + test_must_fail git cat-file blob $blob_1 > /dev/null && + test_must_fail git cat-file blob $blob_2 > /dev/null && + test_must_fail git cat-file blob $blob_3 > /dev/null +' # \0 - empty base # \1 - one byte in result # \1 - one literal byte (X) -test_expect_success \ - 'apply good minimal delta' \ - 'printf "\0\1\1X" > minimal_delta && - test-tool delta -p /dev/null minimal_delta /dev/null' +test_expect_success 'apply good minimal delta' ' + printf "\0\1\1X" > minimal_delta && + test-tool delta -p /dev/null minimal_delta /dev/null +' # \0 - empty base # \1 - 1 byte in result # \2 - two literal bytes (one too many) -test_expect_success \ - 'apply delta with too many literal bytes' \ - 'printf "\0\1\2XX" > too_big_literal && - test_must_fail test-tool delta -p /dev/null too_big_literal /dev/null' +test_expect_success 'apply delta with too many literal bytes' ' + printf "\0\1\2XX" > too_big_literal && + test_must_fail test-tool delta -p /dev/null too_big_literal /dev/null +' # \4 - four bytes in base # \1 - one byte in result # \221 - copy, one byte offset, one byte size # \0 - copy from offset 0 # \2 - copy two bytes (one too many) -test_expect_success \ - 'apply delta with too many copied bytes' \ - 'printf "\4\1\221\0\2" > too_big_copy && - printf base >base && - test_must_fail test-tool delta -p base too_big_copy /dev/null' +test_expect_success 'apply delta with too many copied bytes' ' + printf "\4\1\221\0\2" > too_big_copy && + printf base >base && + test_must_fail test-tool delta -p base too_big_copy /dev/null +' # \0 - empty base # \2 - two bytes in result # \2 - two literal bytes (we are short one) -test_expect_success \ - 'apply delta with too few literal bytes' \ - 'printf "\0\2\2X" > truncated_delta && - test_must_fail test-tool delta -p /dev/null truncated_delta /dev/null' +test_expect_success 'apply delta with too few literal bytes' ' + printf "\0\2\2X" > truncated_delta && + test_must_fail test-tool delta -p /dev/null truncated_delta /dev/null +' # \0 - empty base # \1 - one byte in result # \221 - copy, one byte offset, one byte size # \0 - copy from offset 0 # \1 - copy one byte (we are short one) -test_expect_success \ - 'apply delta with too few bytes in base' \ - 'printf "\0\1\221\0\1" > truncated_base && - test_must_fail test-tool delta -p /dev/null truncated_base /dev/null' +test_expect_success 'apply delta with too few bytes in base' ' + printf "\0\1\221\0\1" > truncated_base && + test_must_fail test-tool delta -p /dev/null truncated_base /dev/null +' # \4 - four bytes in base # \2 - two bytes in result @@ -366,20 +366,20 @@ test_expect_success \ # # Note that the literal byte is necessary to get past the uninteresting minimum # delta size check. -test_expect_success \ - 'apply delta with truncated copy parameters' \ - 'printf "\4\2\1X\221" > truncated_copy_delta && - printf base >base && - test_must_fail test-tool delta -p base truncated_copy_delta /dev/null' +test_expect_success 'apply delta with truncated copy parameters' ' + printf "\4\2\1X\221" > truncated_copy_delta && + printf base >base && + test_must_fail test-tool delta -p base truncated_copy_delta /dev/null +' # \0 - empty base # \1 - one byte in result # \1 - one literal byte (X) # \1 - trailing garbage command -test_expect_success \ - 'apply delta with trailing garbage literal' \ - 'printf "\0\1\1X\1" > tail_garbage_literal && - test_must_fail test-tool delta -p /dev/null tail_garbage_literal /dev/null' +test_expect_success 'apply delta with trailing garbage literal' ' + printf "\0\1\1X\1" > tail_garbage_literal && + test_must_fail test-tool delta -p /dev/null tail_garbage_literal /dev/null +' # \4 - four bytes in base # \1 - one byte in result @@ -387,19 +387,19 @@ test_expect_success \ # \221 - copy, one byte offset, one byte size # \0 - copy from offset 0 # \1 - copy 1 byte -test_expect_success \ - 'apply delta with trailing garbage copy' \ - 'printf "\4\1\1X\221\0\1" > tail_garbage_copy && - printf base >base && - test_must_fail test-tool delta -p /dev/null tail_garbage_copy /dev/null' +test_expect_success 'apply delta with trailing garbage copy' ' + printf "\4\1\1X\221\0\1" > tail_garbage_copy && + printf base >base && + test_must_fail test-tool delta -p /dev/null tail_garbage_copy /dev/null +' # \0 - empty base # \1 - one byte in result # \1 - one literal byte (X) # \0 - bogus opcode -test_expect_success \ - 'apply delta with trailing garbage opcode' \ - 'printf "\0\1\1X\0" > tail_garbage_opcode && - test_must_fail test-tool delta -p /dev/null tail_garbage_opcode /dev/null' +test_expect_success 'apply delta with trailing garbage opcode' ' + printf "\0\1\1X\0" > tail_garbage_opcode && + test_must_fail test-tool delta -p /dev/null tail_garbage_opcode /dev/null +' test_done -- cgit v1.2.3 From a45bb750db1e5c9e4a3462572620d7037bb3f9c6 Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:23 +0000 Subject: t5306-pack-nobase: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t5306-pack-nobase.sh | 94 ++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/t/t5306-pack-nobase.sh b/t/t5306-pack-nobase.sh index 846c5ca7d3..0d50c6b4bc 100755 --- a/t/t5306-pack-nobase.sh +++ b/t/t5306-pack-nobase.sh @@ -12,18 +12,17 @@ TEST_PASSES_SANITIZE_LEAK=true # Create A-B chain # -test_expect_success \ - 'setup base' \ - 'test_write_lines a b c d e f g h i >text && - echo side >side && - git update-index --add text side && - A=$(echo A | git commit-tree $(git write-tree)) && +test_expect_success 'setup base' ' + test_write_lines a b c d e f g h i >text && + echo side >side && + git update-index --add text side && + A=$(echo A | git commit-tree $(git write-tree)) && - echo m >>text && - git update-index text && - B=$(echo B | git commit-tree $(git write-tree) -p $A) && - git update-ref HEAD $B - ' + echo m >>text && + git update-index text && + B=$(echo B | git commit-tree $(git write-tree) -p $A) && + git update-ref HEAD $B +' # Create repository with C whose parent is B. # Repository contains C, C^{tree}, C:text, B, B^{tree}. @@ -31,52 +30,49 @@ test_expect_success \ # Repository is missing A (parent of B). # Repository is missing A:side. # -test_expect_success \ - 'setup patch_clone' \ - 'base_objects=$(pwd)/.git/objects && - (mkdir patch_clone && - cd patch_clone && - git init && - echo "$base_objects" >.git/objects/info/alternates && - echo q >>text && - git read-tree $B && - git update-index text && - git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) && - rm .git/objects/info/alternates && +test_expect_success 'setup patch_clone' ' + base_objects=$(pwd)/.git/objects && + (mkdir patch_clone && + cd patch_clone && + git init && + echo "$base_objects" >.git/objects/info/alternates && + echo q >>text && + git read-tree $B && + git update-index text && + git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) && + rm .git/objects/info/alternates && - git --git-dir=../.git cat-file commit $B | - git hash-object -t commit -w --stdin && + git --git-dir=../.git cat-file commit $B | + git hash-object -t commit -w --stdin && - git --git-dir=../.git cat-file tree "$B^{tree}" | - git hash-object -t tree -w --stdin - ) && - C=$(git --git-dir=patch_clone/.git rev-parse HEAD) - ' + git --git-dir=../.git cat-file tree "$B^{tree}" | + git hash-object -t tree -w --stdin + ) && + C=$(git --git-dir=patch_clone/.git rev-parse HEAD) +' # Clone patch_clone indirectly by cloning base and fetching. # -test_expect_success \ - 'indirectly clone patch_clone' \ - '(mkdir user_clone && - cd user_clone && - git init && - git pull ../.git && - test $(git rev-parse HEAD) = $B && +test_expect_success 'indirectly clone patch_clone' ' + (mkdir user_clone && + cd user_clone && + git init && + git pull ../.git && + test $(git rev-parse HEAD) = $B && - git pull ../patch_clone/.git && - test $(git rev-parse HEAD) = $C - ) - ' + git pull ../patch_clone/.git && + test $(git rev-parse HEAD) = $C + ) +' # Cloning the patch_clone directly should fail. # -test_expect_success \ - 'clone of patch_clone is incomplete' \ - '(mkdir user_direct && - cd user_direct && - git init && - test_must_fail git fetch ../patch_clone/.git - ) - ' +test_expect_success 'clone of patch_clone is incomplete' ' + (mkdir user_direct && + cd user_direct && + git init && + test_must_fail git fetch ../patch_clone/.git + ) +' test_done -- cgit v1.2.3 From 32942346aa1b2010640503309dae276072c84f6a Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:24 +0000 Subject: t6050-replace: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t6050-replace.sh | 296 ++++++++++++++++++++++++++--------------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index 2500acc2ef..c9925edf20 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -62,59 +62,59 @@ HASH6= HASH7= test_expect_success 'set up buggy branch' ' - echo "line 1" >>hello && - echo "line 2" >>hello && - echo "line 3" >>hello && - echo "line 4" >>hello && - add_and_commit_file hello "4 lines" && - HASH1=$(git rev-parse --verify HEAD) && - echo "line BUG" >>hello && - echo "line 6" >>hello && - echo "line 7" >>hello && - echo "line 8" >>hello && - add_and_commit_file hello "4 more lines with a BUG" && - HASH2=$(git rev-parse --verify HEAD) && - echo "line 9" >>hello && - echo "line 10" >>hello && - add_and_commit_file hello "2 more lines" && - HASH3=$(git rev-parse --verify HEAD) && - echo "line 11" >>hello && - add_and_commit_file hello "1 more line" && - HASH4=$(git rev-parse --verify HEAD) && - sed -e "s/BUG/5/" hello >hello.new && - mv hello.new hello && - add_and_commit_file hello "BUG fixed" && - HASH5=$(git rev-parse --verify HEAD) && - echo "line 12" >>hello && - echo "line 13" >>hello && - add_and_commit_file hello "2 more lines" && - HASH6=$(git rev-parse --verify HEAD) && - echo "line 14" >>hello && - echo "line 15" >>hello && - echo "line 16" >>hello && - add_and_commit_file hello "again 3 more lines" && - HASH7=$(git rev-parse --verify HEAD) + echo "line 1" >>hello && + echo "line 2" >>hello && + echo "line 3" >>hello && + echo "line 4" >>hello && + add_and_commit_file hello "4 lines" && + HASH1=$(git rev-parse --verify HEAD) && + echo "line BUG" >>hello && + echo "line 6" >>hello && + echo "line 7" >>hello && + echo "line 8" >>hello && + add_and_commit_file hello "4 more lines with a BUG" && + HASH2=$(git rev-parse --verify HEAD) && + echo "line 9" >>hello && + echo "line 10" >>hello && + add_and_commit_file hello "2 more lines" && + HASH3=$(git rev-parse --verify HEAD) && + echo "line 11" >>hello && + add_and_commit_file hello "1 more line" && + HASH4=$(git rev-parse --verify HEAD) && + sed -e "s/BUG/5/" hello >hello.new && + mv hello.new hello && + add_and_commit_file hello "BUG fixed" && + HASH5=$(git rev-parse --verify HEAD) && + echo "line 12" >>hello && + echo "line 13" >>hello && + add_and_commit_file hello "2 more lines" && + HASH6=$(git rev-parse --verify HEAD) && + echo "line 14" >>hello && + echo "line 15" >>hello && + echo "line 16" >>hello && + add_and_commit_file hello "again 3 more lines" && + HASH7=$(git rev-parse --verify HEAD) ' test_expect_success 'replace the author' ' - git cat-file commit $HASH2 | grep "author A U Thor" && - R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) && - git cat-file commit $R | grep "author O Thor" && - git update-ref refs/replace/$HASH2 $R && - git show HEAD~5 | grep "O Thor" && - git show $HASH2 | grep "O Thor" + git cat-file commit $HASH2 | grep "author A U Thor" && + R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) && + git cat-file commit $R | grep "author O Thor" && + git update-ref refs/replace/$HASH2 $R && + git show HEAD~5 | grep "O Thor" && + git show $HASH2 | grep "O Thor" ' test_expect_success 'test --no-replace-objects option' ' - git cat-file commit $HASH2 | grep "author O Thor" && - git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" && - git show $HASH2 | grep "O Thor" && - git --no-replace-objects show $HASH2 | grep "A U Thor" + git cat-file commit $HASH2 | grep "author O Thor" && + git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" && + git show $HASH2 | grep "O Thor" && + git --no-replace-objects show $HASH2 | grep "A U Thor" ' test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' ' - GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" && - GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor" + GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" && + GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor" ' test_expect_success 'test core.usereplacerefs config option' ' @@ -132,64 +132,64 @@ tagger T A Gger <> 0 +0000 EOF test_expect_success 'tag replaced commit' ' - git update-ref refs/tags/mytag $(git mktag fsck_main.out && - test_i18ngrep "dangling commit $R" fsck_main.out && - test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out && - test -z "$(git fsck)" + git fsck main >fsck_main.out && + test_i18ngrep "dangling commit $R" fsck_main.out && + test_i18ngrep "dangling tag $(git show-ref -s refs/tags/mytag)" fsck_main.out && + test -z "$(git fsck)" ' test_expect_success 'repack, clone and fetch work' ' - git repack -a -d && - git clone --no-hardlinks . clone_dir && - ( - cd clone_dir && - git show HEAD~5 | grep "A U Thor" && - git show $HASH2 | grep "A U Thor" && - git cat-file commit $R && - git repack -a -d && - test_must_fail git cat-file commit $R && - git fetch ../ "refs/replace/*:refs/replace/*" && - git show HEAD~5 | grep "O Thor" && - git show $HASH2 | grep "O Thor" && - git cat-file commit $R - ) + git repack -a -d && + git clone --no-hardlinks . clone_dir && + ( + cd clone_dir && + git show HEAD~5 | grep "A U Thor" && + git show $HASH2 | grep "A U Thor" && + git cat-file commit $R && + git repack -a -d && + test_must_fail git cat-file commit $R && + git fetch ../ "refs/replace/*:refs/replace/*" && + git show HEAD~5 | grep "O Thor" && + git show $HASH2 | grep "O Thor" && + git cat-file commit $R + ) ' test_expect_success '"git replace" listing and deleting' ' - test "$HASH2" = "$(git replace -l)" && - test "$HASH2" = "$(git replace)" && - aa=${HASH2%??????????????????????????????????????} && - test "$HASH2" = "$(git replace --list "$aa*")" && - test_must_fail git replace -d $R && - test_must_fail git replace --delete && - test_must_fail git replace -l -d $HASH2 && - git replace -d $HASH2 && - git show $HASH2 | grep "A U Thor" && - test -z "$(git replace -l)" + test "$HASH2" = "$(git replace -l)" && + test "$HASH2" = "$(git replace)" && + aa=${HASH2%??????????????????????????????????????} && + test "$HASH2" = "$(git replace --list "$aa*")" && + test_must_fail git replace -d $R && + test_must_fail git replace --delete && + test_must_fail git replace -l -d $HASH2 && + git replace -d $HASH2 && + git show $HASH2 | grep "A U Thor" && + test -z "$(git replace -l)" ' test_expect_success '"git replace" replacing' ' - git replace $HASH2 $R && - git show $HASH2 | grep "O Thor" && - test_must_fail git replace $HASH2 $R && - git replace -f $HASH2 $R && - test_must_fail git replace -f && - test "$HASH2" = "$(git replace)" + git replace $HASH2 $R && + git show $HASH2 | grep "O Thor" && + test_must_fail git replace $HASH2 $R && + git replace -f $HASH2 $R && + test_must_fail git replace -f && + test "$HASH2" = "$(git replace)" ' test_expect_success '"git replace" resolves sha1' ' - SHORTHASH2=$(git rev-parse --short=8 $HASH2) && - git replace -d $SHORTHASH2 && - git replace $SHORTHASH2 $R && - git show $HASH2 | grep "O Thor" && - test_must_fail git replace $HASH2 $R && - git replace -f $HASH2 $R && - test_must_fail git replace --force && - test "$HASH2" = "$(git replace)" + SHORTHASH2=$(git rev-parse --short=8 $HASH2) && + git replace -d $SHORTHASH2 && + git replace $SHORTHASH2 $R && + git show $HASH2 | grep "O Thor" && + test_must_fail git replace $HASH2 $R && + git replace -f $HASH2 $R && + test_must_fail git replace --force && + test "$HASH2" = "$(git replace)" ' # This creates a side branch where the bug in H2 @@ -207,79 +207,79 @@ test_expect_success '"git replace" resolves sha1' ' # Then we replace H6 with P6. # test_expect_success 'create parallel branch without the bug' ' - git replace -d $HASH2 && - git show $HASH2 | grep "A U Thor" && - git checkout $HASH1 && - git cherry-pick $HASH2 && - git show $HASH5 | git apply && - git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello && - PARA2=$(git rev-parse --verify HEAD) && - git cherry-pick $HASH3 && - PARA3=$(git rev-parse --verify HEAD) && - git cherry-pick $HASH4 && - PARA4=$(git rev-parse --verify HEAD) && - git cherry-pick $HASH6 && - PARA6=$(git rev-parse --verify HEAD) && - git replace $HASH6 $PARA6 && - git checkout main && - cur=$(git rev-parse --verify HEAD) && - test "$cur" = "$HASH7" && - git log --pretty=oneline | grep $PARA2 && - git remote add cloned ./clone_dir + git replace -d $HASH2 && + git show $HASH2 | grep "A U Thor" && + git checkout $HASH1 && + git cherry-pick $HASH2 && + git show $HASH5 | git apply && + git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello && + PARA2=$(git rev-parse --verify HEAD) && + git cherry-pick $HASH3 && + PARA3=$(git rev-parse --verify HEAD) && + git cherry-pick $HASH4 && + PARA4=$(git rev-parse --verify HEAD) && + git cherry-pick $HASH6 && + PARA6=$(git rev-parse --verify HEAD) && + git replace $HASH6 $PARA6 && + git checkout main && + cur=$(git rev-parse --verify HEAD) && + test "$cur" = "$HASH7" && + git log --pretty=oneline | grep $PARA2 && + git remote add cloned ./clone_dir ' test_expect_success 'push to cloned repo' ' - git push cloned $HASH6^:refs/heads/parallel && - ( - cd clone_dir && - git checkout parallel && - git log --pretty=oneline | grep $PARA2 - ) + git push cloned $HASH6^:refs/heads/parallel && + ( + cd clone_dir && + git checkout parallel && + git log --pretty=oneline | grep $PARA2 + ) ' test_expect_success 'push branch with replacement' ' - git cat-file commit $PARA3 | grep "author A U Thor" && - S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) && - git cat-file commit $S | grep "author O Thor" && - git replace $PARA3 $S && - git show $HASH6~2 | grep "O Thor" && - git show $PARA3 | grep "O Thor" && - git push cloned $HASH6^:refs/heads/parallel2 && - ( - cd clone_dir && - git checkout parallel2 && - git log --pretty=oneline | grep $PARA3 && - git show $PARA3 | grep "A U Thor" - ) + git cat-file commit $PARA3 | grep "author A U Thor" && + S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) && + git cat-file commit $S | grep "author O Thor" && + git replace $PARA3 $S && + git show $HASH6~2 | grep "O Thor" && + git show $PARA3 | grep "O Thor" && + git push cloned $HASH6^:refs/heads/parallel2 && + ( + cd clone_dir && + git checkout parallel2 && + git log --pretty=oneline | grep $PARA3 && + git show $PARA3 | grep "A U Thor" + ) ' test_expect_success 'fetch branch with replacement' ' - git branch tofetch $HASH6 && - ( - cd clone_dir && - git fetch origin refs/heads/tofetch:refs/heads/parallel3 && - git log --pretty=oneline parallel3 >output.txt && - ! grep $PARA3 output.txt && - git show $PARA3 >para3.txt && - grep "A U Thor" para3.txt && - git fetch origin "refs/replace/*:refs/replace/*" && - git log --pretty=oneline parallel3 >output.txt && - grep $PARA3 output.txt && - git show $PARA3 >para3.txt && - grep "O Thor" para3.txt - ) + git branch tofetch $HASH6 && + ( + cd clone_dir && + git fetch origin refs/heads/tofetch:refs/heads/parallel3 && + git log --pretty=oneline parallel3 >output.txt && + ! grep $PARA3 output.txt && + git show $PARA3 >para3.txt && + grep "A U Thor" para3.txt && + git fetch origin "refs/replace/*:refs/replace/*" && + git log --pretty=oneline parallel3 >output.txt && + grep $PARA3 output.txt && + git show $PARA3 >para3.txt && + grep "O Thor" para3.txt + ) ' test_expect_success 'bisect and replacements' ' - git bisect start $HASH7 $HASH1 && - test "$PARA3" = "$(git rev-parse --verify HEAD)" && - git bisect reset && - GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 && - test "$HASH4" = "$(git rev-parse --verify HEAD)" && - git bisect reset && - git --no-replace-objects bisect start $HASH7 $HASH1 && - test "$HASH4" = "$(git rev-parse --verify HEAD)" && - git bisect reset + git bisect start $HASH7 $HASH1 && + test "$PARA3" = "$(git rev-parse --verify HEAD)" && + git bisect reset && + GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 && + test "$HASH4" = "$(git rev-parse --verify HEAD)" && + git bisect reset && + git --no-replace-objects bisect start $HASH7 $HASH1 && + test "$HASH4" = "$(git rev-parse --verify HEAD)" && + git bisect reset ' test_expect_success 'index-pack and replacements' ' -- cgit v1.2.3 From 3b8724bce65edea7abba480929457ef794ec753e Mon Sep 17 00:00:00 2001 From: John Cai Date: Thu, 18 May 2023 20:03:25 +0000 Subject: t7101-reset-empty-subdirs: modernize test format Some tests still use the old format with four spaces indentation. Standardize the tests to the new format with tab indentation. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- t/t7101-reset-empty-subdirs.sh | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/t/t7101-reset-empty-subdirs.sh b/t/t7101-reset-empty-subdirs.sh index 638bb04e21..89cf98b30c 100755 --- a/t/t7101-reset-empty-subdirs.sh +++ b/t/t7101-reset-empty-subdirs.sh @@ -10,57 +10,57 @@ TEST_PASSES_SANITIZE_LEAK=true . "$TEST_DIRECTORY"/lib-diff-data.sh test_expect_success 'creating initial files' ' - mkdir path0 && - COPYING_test_data >path0/COPYING && - git add path0/COPYING && - git commit -m add -a + mkdir path0 && + COPYING_test_data >path0/COPYING && + git add path0/COPYING && + git commit -m add -a ' test_expect_success 'creating second files' ' - mkdir path1 && - mkdir path1/path2 && - COPYING_test_data >path1/path2/COPYING && - COPYING_test_data >path1/COPYING && - COPYING_test_data >COPYING && - COPYING_test_data >path0/COPYING-TOO && - git add path1/path2/COPYING && - git add path1/COPYING && - git add COPYING && - git add path0/COPYING-TOO && - git commit -m change -a + mkdir path1 && + mkdir path1/path2 && + COPYING_test_data >path1/path2/COPYING && + COPYING_test_data >path1/COPYING && + COPYING_test_data >COPYING && + COPYING_test_data >path0/COPYING-TOO && + git add path1/path2/COPYING && + git add path1/COPYING && + git add COPYING && + git add path0/COPYING-TOO && + git commit -m change -a ' test_expect_success 'resetting tree HEAD^' ' - git reset --hard HEAD^ + git reset --hard HEAD^ ' test_expect_success 'checking initial files exist after rewind' ' - test -d path0 && - test -f path0/COPYING + test -d path0 && + test -f path0/COPYING ' test_expect_success 'checking lack of path1/path2/COPYING' ' - ! test -f path1/path2/COPYING + ! test -f path1/path2/COPYING ' test_expect_success 'checking lack of path1/COPYING' ' - ! test -f path1/COPYING + ! test -f path1/COPYING ' test_expect_success 'checking lack of COPYING' ' - ! test -f COPYING + ! test -f COPYING ' test_expect_success 'checking checking lack of path1/COPYING-TOO' ' - ! test -f path0/COPYING-TOO + ! test -f path0/COPYING-TOO ' test_expect_success 'checking lack of path1/path2' ' - ! test -d path1/path2 + ! test -d path1/path2 ' test_expect_success 'checking lack of path1' ' - ! test -d path1 + ! test -d path1 ' test_done -- cgit v1.2.3