{"thread":{"id":"55480","subject":"[PATCH 00/16] test-lib.sh: new test_commit args, simplification & fixes","startedAt":"2021-04-12T11:09:13Z","lastAt":"2021-05-13T20:11:05Z","messageCount":175,"participants":["Ævar Arnfjörð Bjarmason","Eric Sunshine","Matthieu Moy","Junio C Hamano","Andreas Schwab","Đoàn Trần Công Danh","SZEDER Gábor","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":16},"messages":[{"id":"421648","messageId":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":null,"subject":"[PATCH 00/16] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:49Z","receivedAt":"2021-04-12T11:09:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This is a \"various small fixes\" series to test-lib.sh,\ntest-lib-functions.sh.\n\nI have a couple of outstanding patch serieses that I've pulled this\nfrom (ab/describe-tests-fix, ab/pickaxe-pcre2), as well as some other\nlocal work I've been having a chicken and egg problem with.\n\nI think the approach of pulling out these various miscellaneous test\nfixes into their own topic makes the most sense, I'll then submit\nre-rolled versions of other topics that e.g. need these new\ntest_commit arguments on top of this.\n\nÆvar Arnfjörð Bjarmason (16):\n  check-non-portable-shell: complain about \"test\" a/-o instead of &&/||\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated-tag option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: modernize test_create_repo() function\n  test-lib-functions: normalize test_path_is_missing() debugging\n  test-lib-functions: use \"return 1\" instead of \"false\"\n  Revert and amend \"test-lib-functions: assert correct parameter count\"\n  test-lib-functions: remove last two parameter count assertions\n\n t/check-non-portable-shell.pl       |   4 +\n t/lib-submodule-update.sh           |   3 +-\n t/t0000-basic.sh                    |   4 -\n t/t1307-config-blob.sh              |   4 +-\n t/t1403-show-ref.sh                 |   6 +-\n t/t2030-unresolve-info.sh           |   3 +-\n t/t4006-diff-mode.sh                |   6 +-\n t/t4030-diff-textconv.sh            |   8 +-\n t/t5406-remote-rejects.sh           |   1 -\n t/t5407-post-rewrite-hook.sh        |   2 -\n t/t5409-colorize-remote-messages.sh |   1 -\n t/t5520-pull.sh                     |  10 +--\n t/t6120-describe.sh                 |  58 +++----------\n t/test-lib-functions.sh             | 125 ++++++++++++++--------------\n t/test-lib.sh                       |  36 ++++----\n 15 files changed, 113 insertions(+), 158 deletions(-)\n\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421649","messageId":"patch-01.16-8e4b4a2a216-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:50Z","receivedAt":"2021-04-12T11:09:17Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Expand the t/check-non-portable-shell.pl checks to complain about the\nuse of \"-a\" and \"-o\" to the \"test\" shell built-in to to mean \"and\" and\n\"or\", as opposed to using two \"test\" invocations with \"&&\" or \"||\".\n\nThere aren't any portability issues with using that construct that I\nknow of, but since Junio expressed a dislike of it in [1] and we've\ncurrently got no such constructs let's add it to the lint checking. I\nhad various in-flight and WIP patches that used this construct.\n\n1. https://lore.kernel.org/git/xmqqa6qkb5fi.fsf@gitster.g/\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/check-non-portable-shell.pl | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\nindex fd3303552be..a5367346255 100755\n--- a/t/check-non-portable-shell.pl\n+++ b/t/check-non-portable-shell.pl\n@@ -35,6 +35,7 @@ sub err {\n \tnext if $line =~ s/\\\\$//;\n \n \t$_ = $line;\n+\t# Portability issues\n \t/\\bcp\\s+-a/ and err 'cp -a is not portable';\n \t/\\bsed\\s+-[^efn]\\s+/ and err 'sed option not portable (use only -n, -e, -f)';\n \t/\\becho\\s+-[neE]/ and err 'echo with option is not portable (use printf)';\n@@ -48,6 +49,9 @@ sub err {\n \t/\\bexport\\s+[A-Za-z0-9_]*=/ and err '\"export FOO=bar\" is not portable (use FOO=bar && export FOO)';\n \t/^\\s*([A-Z0-9_]+=(\\w*|([\"']).*?\\3)\\s+)+(\\w+)/ and exists($func{$4}) and\n \t\terr '\"FOO=bar shell_func\" assignment extends beyond \"shell_func\"';\n+\t# Coding style preferences\n+\t/\\btest\\s+-[a-z]\\s+.*?\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n+\t/\\btest\\s+-[a-z]\\s+.*?\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n \t$line = '';\n \t# this resets our $. for each file\n \tclose ARGV if eof;\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421650","messageId":"patch-02.16-44223ae777e-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 02/16] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:51Z","receivedAt":"2021-04-12T11:09:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests.\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 31 +++++++++++++++++--------------\n 1 file changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex d3f6af6a654..a8869eee58f 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1167,7 +1167,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1332,6 +1332,21 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1339,10 +1354,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1354,15 +1366,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421651","messageId":"patch-04.16-4ecce153b99-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 04/16] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:53Z","receivedAt":"2021-04-12T11:09:19Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6348e8d7339..d169fb2f597 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421652","messageId":"patch-03.16-3d04553d710-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 03/16] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:52Z","receivedAt":"2021-04-12T11:09:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27a..2c6e34b9478 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421653","messageId":"patch-05.16-6df03776940-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 05/16] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:54Z","receivedAt":"2021-04-12T11:09:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d169fb2f597..fa3e3e975fd 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,9 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit, if supplied giving the\n+#\toptional \"<tag>\" argument is an error.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421654","messageId":"patch-06.16-8d43fdd5865-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 06/16] test-lib functions: add an --annotated-tag option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:55Z","receivedAt":"2021-04-12T11:09:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated-tag option to test_commit. The tag will share the\nsame message as the commit, and we'll call test_tick before creating\nit (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c3..17d3cc14050 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex fa3e3e975fd..a0fcc383d0b 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -180,6 +180,10 @@ debug () {\n #   --no-tag\n #\tDo not tag the resulting commit, if supplied giving the\n #\toptional \"<tag>\" argument is an error.\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag unless --notick is\n+#\tgiven.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -192,7 +196,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -220,7 +224,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -244,10 +251,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test \"$tag$notick\" = \"annotate\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421655","messageId":"patch-07.16-ec4809e7466-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 07/16] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:56Z","receivedAt":"2021-04-12T11:09:24Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotated-tag option to\ntest_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747bee..88fddc91424 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421656","messageId":"patch-08.16-352eeff41c9-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:57Z","receivedAt":"2021-04-12T11:09:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 12 ++++++++++--\n 6 files changed, 18 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388e..930dce06f0f 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a2..f691e6d9032 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15b..6cdee2a2164 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60d..a39a626664d 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f9..e2c0c510222 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex a0fcc383d0b..a90a6b2cc27 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,10 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -192,6 +196,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -203,6 +208,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -239,9 +247,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421657","messageId":"patch-09.16-e7432294215-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 09/16] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:58Z","receivedAt":"2021-04-12T11:09:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e93083..f7c7df0ca42 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421658","messageId":"patch-10.16-634038c3a8d-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 10/16] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:08:59Z","receivedAt":"2021-04-12T11:09:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex a90a6b2cc27..674b865a20d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1258,8 +1258,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421659","messageId":"patch-11.16-cdbff4df362-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 11/16] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:00Z","receivedAt":"2021-04-12T11:09:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 674b865a20d..c81726acb9e 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1259,7 +1259,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex a8869eee58f..0057dfa69d0 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421660","messageId":"patch-12.16-424caad189f-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:01Z","receivedAt":"2021-04-12T11:09:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove redundant \"mkdir -p\", argument number checking', test\nenvironment sanity checking, and disabling of hooks from\ntest_create_repo(). As we'll see below these were all either redundant\nto other test other framework code, or to changes in git itself.\n\nRespectively:\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. We don't need to check the number of arguments anymore, instead\n    we'll feed \"git init\" with \"$@\". It will die if given too many\n    arguments.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n 5. Since we don't need to move the .git/hooks directory we don't need\n    the subshell here either.\n\nIn the end it turns out that all we needed was a plain \"git init\"\ninvocation with a custom --template directory.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 +++------------\n 4 files changed, 3 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649e..5c509db6fc3 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4e..6da8d760e28 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8ec..9f1a483f426 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c81726acb9e..1258329fdd8 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1252,18 +1252,9 @@ test_atexit () {\n # Most tests can use the created repository, but some may need to create more.\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\tinit \\\n+\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" \"$@\" >&3 2>&4\n }\n \n # This function helps on symlink challenged file systems when it is not\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421661","messageId":"patch-13.16-0813aa8e34e-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 13/16] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:02Z","receivedAt":"2021-04-12T11:09:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test_path_is_missing() to be consistent with related\nfunctions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to\ntest [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\necho-ing $* if it exists. Let's just say that it exists instead.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 1258329fdd8..2518a9b8274 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -811,12 +811,7 @@ test_path_is_missing () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \tif test -e \"$1\"\n \tthen\n-\t\techo \"Path exists:\"\n-\t\tls -ld \"$1\"\n-\t\tif test $# -ge 1\n-\t\tthen\n-\t\t\techo \"$*\"\n-\t\tfi\n+\t\techo \"Path $1 exists!\"\n \t\tfalse\n \tfi\n }\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421662","messageId":"patch-14.16-b6e9d971b40-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 14/16] test-lib-functions: use \"return 1\" instead of \"false\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:03Z","receivedAt":"2021-04-12T11:09:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a few functions that relied on a \"false\" being the last\nstatement in the function to use an explicit \"return 1\" like the other\nfunctions in this file.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2518a9b8274..c46bf0ff09c 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -763,7 +763,7 @@ test_path_is_file () {\n \tif ! test -f \"$1\"\n \tthen\n \t\techo \"File $1 doesn't exist\"\n-\t\tfalse\n+\t\treturn 1\n \tfi\n }\n \n@@ -772,7 +772,7 @@ test_path_is_dir () {\n \tif ! test -d \"$1\"\n \tthen\n \t\techo \"Directory $1 doesn't exist\"\n-\t\tfalse\n+\t\treturn 1\n \tfi\n }\n \n@@ -781,7 +781,7 @@ test_path_exists () {\n \tif ! test -e \"$1\"\n \tthen\n \t\techo \"Path $1 doesn't exist\"\n-\t\tfalse\n+\t\treturn 1\n \tfi\n }\n \n@@ -803,7 +803,7 @@ test_file_not_empty () {\n \tif ! test -s \"$1\"\n \tthen\n \t\techo \"'$1' is not a non-empty file.\"\n-\t\tfalse\n+\t\treturn 1\n \tfi\n }\n \n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421664","messageId":"patch-15.16-0cd511206c4-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:04Z","receivedAt":"2021-04-12T11:09:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This reverts and amends my my own e7884b353b7 (test-lib-functions:\nassert correct parameter count, 2021-02-12) in order to improve the -x\noutput.\n\nWhen I added these BUG assertions in e7884b353b7 I missed that this\nmade the -x output much more verbose.\n\nE.g. for each test_cmp invocation we'd now emit:\n\n    + test_cmp expect actual\n    + test 2 -ne 2\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThat \"test 2 -ne 2\" line is new in e7884b353b7. As noted in\n45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\nhelper param, 2021-02-12) we had buggy invocations of some of these\nfunctions with too many parameters.\n\nLet's instead use \"$@\" instead of \"$1\" to achieve the same ends with\nno extra -x output verbosity. The \"test\" operator will die with an\nerror if given more than one argument in these contexts, so using \"$@\"\nachieves the same goal.\n\nThe same goes for \"cmp\" and \"diff -u\" (which we typically use for\ntest_cmp).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 41 ++++++++++++++++-------------------------\n 1 file changed, 16 insertions(+), 25 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c46bf0ff09c..2cf72b56851 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -759,39 +759,35 @@ test_external_without_stderr () {\n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n # The commands test the existence or non-existence of $1\n test_path_is_file () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -f \"$1\"\n+\tif ! test -f \"$@\"\n \tthen\n-\t\techo \"File $1 doesn't exist\"\n+\t\techo \"File $@ doesn't exist\"\n \t\treturn 1\n \tfi\n }\n \n test_path_is_dir () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -d \"$1\"\n+\tif ! test -d \"$@\"\n \tthen\n-\t\techo \"Directory $1 doesn't exist\"\n+\t\techo \"Directory $@ doesn't exist\"\n \t\treturn 1\n \tfi\n }\n \n test_path_exists () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -e \"$1\"\n+\tif ! test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 doesn't exist\"\n+\t\techo \"Path $@ doesn't exist\"\n \t\treturn 1\n \tfi\n }\n \n # Check if the directory exists and is empty as expected, barf otherwise.\n test_dir_is_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\ttest_path_is_dir \"$@\" &&\n+\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n \tthen\n-\t\techo \"Directory '$1' is not empty, it contains:\"\n+\t\techo \"Directory '$@' is not empty, it contains:\"\n \t\tls -la \"$1\"\n \t\treturn 1\n \tfi\n@@ -799,17 +795,15 @@ test_dir_is_empty () {\n \n # Check if the file exists and has a size greater than zero\n test_file_not_empty () {\n-\ttest \"$#\" = 2 && BUG \"2 param\"\n-\tif ! test -s \"$1\"\n+\tif ! test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not a non-empty file.\"\n+\t\techo \"'$@' is not a non-empty file.\"\n \t\treturn 1\n \tfi\n }\n \n test_path_is_missing () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif test -e \"$1\"\n+\tif test -e \"$@\"\n \tthen\n \t\techo \"Path $1 exists!\"\n \t\tfalse\n@@ -1013,7 +1007,6 @@ test_expect_code () {\n # - not all diff versions understand \"-u\"\n \n test_cmp () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \teval \"$GIT_TEST_CMP\" '\"$@\"'\n }\n \n@@ -1043,7 +1036,6 @@ test_cmp_config () {\n # test_cmp_bin - helper to compare binary files\n \n test_cmp_bin () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \tcmp \"$@\"\n }\n \n@@ -1104,12 +1096,11 @@ verbose () {\n # otherwise.\n \n test_must_be_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_file \"$1\" &&\n-\tif test -s \"$1\"\n+\ttest_path_is_file \"$@\" &&\n+\tif test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not empty, it contains:\"\n-\t\tcat \"$1\"\n+\t\techo \"'$@' is not empty, it contains:\"\n+\t\tcat \"$@\"\n \t\treturn 1\n \tfi\n }\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421663","messageId":"patch-16.16-b4a018a63f3-20210412T110456Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH 16/16] test-lib-functions: remove last two parameter count assertions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-12T11:09:05Z","receivedAt":"2021-04-12T11:09:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove a couple of parameter count assertions where we'll now silently\ndo the wrong thing if given too many parameters, unlike the \"$@\" cases\nin the preceding commit where \"test\" etc. handle the check for usi.\n\nIn the case of \"test_file_size\", the \"test-tool\" we're invoking is\nhappy to accept N parameters (it'll print out all N sizes). Let's just\nuse \"$@\" in that case anyway, there's only a few callers, and\neventually those should probably be moved to use the test-tool\ndirectly.\n\nThat only leaves test_line_count, I suppose I could leave that one\nalone, but since it's the only common function left that does this\nassertion let's remove it for the brevity of the -x output and\nconsistency with other functions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2cf72b56851..32d6b98b972 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -822,10 +822,7 @@ test_path_is_missing () {\n # output through when the number of lines is wrong.\n \n test_line_count () {\n-\tif test $# != 3\n-\tthen\n-\t\tBUG \"not 3 parameters to test_line_count\"\n-\telif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n+\tif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n \tthen\n \t\techo \"test_line_count: line count for $3 !$1 $2\"\n \t\tcat \"$3\"\n@@ -834,8 +831,7 @@ test_line_count () {\n }\n \n test_file_size () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest-tool path-utils file-size \"$1\"\n+\ttest-tool path-utils file-size \"$@\"\n }\n \n # Returns success if a comma separated string of keywords ($1) contains a\n-- \n2.31.1.634.gb41287a30b0\n\n"},{"id":"421710","messageId":"CAPig+cQFFsLeE921WpzTxVnBMnNRiKs4N=hUQ2UQi1VznNEQwg@mail.gmail.com","threadId":"55480","inReplyTo":"patch-01.16-8e4b4a2a216-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-12T17:00:06Z","receivedAt":"2021-04-12T17:01:35Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Apr 12, 2021 at 7:09 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> Expand the t/check-non-portable-shell.pl checks to complain about the\n> use of \"-a\" and \"-o\" to the \"test\" shell built-in to to mean \"and\" and\n> \"or\", as opposed to using two \"test\" invocations with \"&&\" or \"||\".\n>\n> There aren't any portability issues with using that construct that I\n> know of, but since Junio expressed a dislike of it in [1] and we've\n> currently got no such constructs let's add it to the lint checking. I\n> had various in-flight and WIP patches that used this construct.\n\nIt's not only Junio's dislike of `-a` and `-o` but also that they have\nlong been considered obsolescent by POSIX[1]. GNU has likewise warned\nagainst it[2] for a few decades.\n\n[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16\n[2]: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html\n\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n> diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\n> @@ -35,6 +35,7 @@ sub err {\n> +       # Portability issues\n> @@ -48,6 +49,9 @@ sub err {\n> +       # Coding style preferences\n\nGiven that these flags are considered obsolescent, thus may someday be\ndropped from some implementations, these seem a better fit for the\n\"portability issues\" section than the \"coding style preferences\"\nsection. (I'd probably just drop those section titles, though.)\n\n> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n\nThese will only match the simplistic forms of `test -X blah` (where\n\"-X\" is some single letter option), but will miss expressions such as\n`test \"$foo\" = bar`. Crafting a regex to match more generally would be\nnon-trivial, so this simpler match is a reasonable start. Okay.\n"},{"id":"421713","messageId":"CAPig+cTJNrTrV=oEDRgGeaqOLmj8gpHKfxJTqfXynBYibd=+Ag@mail.gmail.com","threadId":"55480","inReplyTo":"patch-05.16-6df03776940-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 05/16] test-lib-functions: document test_commit --no-tag","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-12T17:07:10Z","receivedAt":"2021-04-12T17:07:25Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Apr 12, 2021 at 7:09 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n> 2021-01-12) I added missing documentation to test_commit, but in less\n> than a month later in 3803a3a099 (t: add --no-tag option to\n> test_commit, 2021-02-09) we got another undocumented option. Let's fix\n> that.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> @@ -177,6 +177,9 @@ debug () {\n> +#   --no-tag\n> +#      Do not tag the resulting commit, if supplied giving the\n> +#      optional \"<tag>\" argument is an error.\n\nThis is difficult to understand for a native English speaker/reader\ndue to the comma-splice[1]. A period or semicolon in place of the\ncomma would fix it.\n\n[1]: https://lore.kernel.org/git/CAPx1GvfFPWvJsj+uJV7RZrv1rgEpio=pk6rKF2UrjHebVY=LPA@mail.gmail.com/\n"},{"id":"421741","messageId":"926894000.404076765.1618247601502.JavaMail.zimbra@matthieu-moy.fr","threadId":"55480","inReplyTo":"CAPig+cQFFsLeE921WpzTxVnBMnNRiKs4N=hUQ2UQi1VznNEQwg@mail.gmail.com","subject":"Re: [PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Matthieu Moy","fromEmail":"git@matthieu-moy.fr","sentAt":"2021-04-12T17:13:21Z","receivedAt":"2021-04-12T17:42:42Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\"Eric Sunshine\" <sunshine@sunshineco.com> wrote:\n\n> On Mon, Apr 12, 2021 at 7:09 AM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n> > Expand the t/check-non-portable-shell.pl checks to complain about the\n> > use of \"-a\" and \"-o\" to the \"test\" shell built-in to to mean \"and\" and\n> > \"or\", as opposed to using two \"test\" invocations with \"&&\" or \"||\".\n\n> > There aren't any portability issues with using that construct that I\n> > know of, but since Junio expressed a dislike of it in [1] and we've\n> > currently got no such constructs let's add it to the lint checking. I\n> > had various in-flight and WIP patches that used this construct.\n\n> It's not only Junio's dislike of `-a` and `-o` but also that they have\n> long been considered obsolescent by POSIX[1]. GNU has likewise warned\n> against it[2] for a few decades.\n\n> [1]:\n> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16\n> [2]:\n> https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html\n\nAnd also in Git's Documentation/CodingGuidelines, which motivates the advice with an example:\n\n     test -n \"$x\" -a \"$a\" = \"$b\"\n\n   is buggy and breaks when $x is \"=\", but\n\n     test -n \"$x\" && test \"$a\" = \"$b\"\n\n   does not have such a problem.\n\n-- \nMatthieu Moy\nhttps://matthieu-moy.fr/\n"},{"id":"421744","messageId":"xmqqa6q3e59d.fsf@gitster.g","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 00/16] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T18:18:06Z","receivedAt":"2021-04-12T18:18:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> This is a \"various small fixes\" series to test-lib.sh,\n> test-lib-functions.sh.\n>\n> I have a couple of outstanding patch serieses that I've pulled this\n> from (ab/describe-tests-fix, ab/pickaxe-pcre2), as well as some other\n> local work I've been having a chicken and egg problem with.\n>\n> I think the approach of pulling out these various miscellaneous test\n> fixes into their own topic makes the most sense,...\n\nI guess I'm expected to discard the other topics that have been\nexpecting rerolls from my tree to make room for this, queue this\ntopic and wait it to stabilize, before taking the rerools of these\nother topics.\n\nI find it a bit distracting to retract multiple topics that have\nbeen already reviewed and reorganizing them in a new topic.  The\nreviewer resource spent for the last round might not be completely\nlost, but for reviewers it makes it unnecessarily harder to verify\nwhich review comments have been addressed and which parts haven't\nchanged, so the net effect is to require them a fresh review anyway.\nIf you can entice reviewers to review this new series and making\nthem giving it priority over other topics in flight, that is.\n\n> Ævar Arnfjörð Bjarmason (16):\n>   check-non-portable-shell: complain about \"test\" a/-o instead of &&/||\n>   test-lib: bring $remove_trash out of retirement\n>   test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n>   test-lib-functions: reword \"test_commit --append\" docs\n>   test-lib-functions: document test_commit --no-tag\n>   test-lib functions: add an --annotated-tag option to \"test_commit\"\n>   describe tests: convert setup to use test_commit\n>   test-lib functions: add --printf option to test_commit\n>   submodule tests: use symbolic-ref --short to discover branch name\n>   test-lib: reformat argument list in test_create_repo()\n>   test-lib: do not show advice about init.defaultBranch under --verbose\n>   test-lib: modernize test_create_repo() function\n>   test-lib-functions: normalize test_path_is_missing() debugging\n>   test-lib-functions: use \"return 1\" instead of \"false\"\n>   Revert and amend \"test-lib-functions: assert correct parameter count\"\n>   test-lib-functions: remove last two parameter count assertions\n"},{"id":"421747","messageId":"xmqqwnt7cpu2.fsf@gitster.g","threadId":"55480","inReplyTo":"926894000.404076765.1618247601502.JavaMail.zimbra@matthieu-moy.fr","subject":"Re: [PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T18:36:37Z","receivedAt":"2021-04-12T18:36:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <git@matthieu-moy.fr> writes:\n\n> And also in Git's Documentation/CodingGuidelines, which motivates the advice with an example:\n>\n>      test -n \"$x\" -a \"$a\" = \"$b\"\n>\n>    is buggy and breaks when $x is \"=\", but\n>\n>      test -n \"$x\" && test \"$a\" = \"$b\"\n>\n>    does not have such a problem.\n\nGood advice to cite Documentation/CodingGuidelines in the log\nmessage.\n\nThanks (and nice to hear from you again ;-).\n\n"},{"id":"421748","messageId":"xmqqsg3vcpqv.fsf@gitster.g","threadId":"55480","inReplyTo":"CAPig+cQFFsLeE921WpzTxVnBMnNRiKs4N=hUQ2UQi1VznNEQwg@mail.gmail.com","subject":"Re: [PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T18:38:32Z","receivedAt":"2021-04-12T18:38:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> Given that these flags are considered obsolescent, thus may someday be\n> dropped from some implementations, these seem a better fit for the\n> \"portability issues\" section than the \"coding style preferences\"\n> section. (I'd probably just drop those section titles, though.)\n>\n>> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n>> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n>\n> These will only match the simplistic forms of `test -X blah` (where\n> \"-X\" is some single letter option), but will miss expressions such as\n> `test \"$foo\" = bar`. Crafting a regex to match more generally would be\n> non-trivial, so this simpler match is a reasonable start. Okay.\n\nWould it be a trivial improvement to do\n\n    'test', followed by anything other than '&' or '|', and then\n    followed by '-a' or '-o'\n\ninstead?\n"},{"id":"421749","messageId":"CAPig+cSiwq3KwSLyfNezx77FvLMu0gDjLq2jCKVnLQ-uVXP3Yw@mail.gmail.com","threadId":"55480","inReplyTo":"xmqqsg3vcpqv.fsf@gitster.g","subject":"Re: [PATCH 01/16] check-non-portable-shell: complain about \"test\" a/-o instead of &&/||","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-12T18:48:43Z","receivedAt":"2021-04-12T18:48:57Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Apr 12, 2021 at 2:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n> >> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n> >> +       /\\btest\\s+-[a-z]\\s+.*?\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n> >\n> > These will only match the simplistic forms of `test -X blah` (where\n> > \"-X\" is some single letter option), but will miss expressions such as\n> > `test \"$foo\" = bar`. Crafting a regex to match more generally would be\n> > non-trivial, so this simpler match is a reasonable start. Okay.\n>\n> Would it be a trivial improvement to do\n>\n>     'test', followed by anything other than '&' or '|', and then\n>     followed by '-a' or '-o'\n>\n> instead?\n\nThat seems plausible and trivial enough. In fact, I think it\neliminates a source of false-positives that Ævar's pattern can report,\nsuch as:\n\n    test whatever && ls -a foo\n\nand\n\n    test whatever && foo -o outfile\n\namong others.\n"},{"id":"421750","messageId":"CAPig+cTTjX=keJJdXLfsP52tQJZULgzjqbvYm=QZLK2312qRmw@mail.gmail.com","threadId":"55480","inReplyTo":"patch-08.16-352eeff41c9-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-12T19:05:56Z","receivedAt":"2021-04-12T19:06:11Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Apr 12, 2021 at 7:09 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> Add a --printf option to test_commit to allow writing to the file with\n> \"printf\" instead of \"echo\".\n>\n> This is useful for writing \"\\n\", \"\\0\" etc., in particular in\n> combination with the --append option added in 3373518cc8 (test-lib\n> functions: add an --append option to test_commit, 2021-01-12).\n> [...]\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n\nJust a bit of pure bikeshedding...\n\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> @@ -173,6 +173,10 @@ debug () {\n> +#   --printf\n> +#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n> +#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n> +#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n\nThe name \"printf\" has such strong association in programmer's minds\nwith \"%\" and argument consumption that the name of this option alone\nalmost begs people to take advantage of argument interpolation even\nthough it's documented here as not allowing it. Taking into\nconsideration that people often do not read documentation, `--printf`\nas the name of the option may be an unfortunate one. Perhaps it could\nbe called `--raw` or something less likely to suggest argument\ninterpolation.\n\n> @@ -192,6 +196,7 @@ debug () {\n>\n>  test_commit () {\n>         notick= &&\n> +       echo=echo &&\n\nThis could be slightly confusing. I wonder if naming this variable\n`emit` would be clearer.\n"},{"id":"421751","messageId":"xmqqo8ejcogj.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-02.16-44223ae777e-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 02/16] test-lib: bring $remove_trash out of retirement","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T19:06:20Z","receivedAt":"2021-04-12T19:06:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> There's no point in creating a repository or directory only to decide\n> right afterwards that we're skipping all the tests.\n>\n> So let's partially revert 06478dab4c (test-lib: retire $remove_trash\n> variable, 2017-04-23) and move the decision about whether to skip all\n> tests earlier.\n>\n> I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\n> under --debug at the end of the test, 2017-04-24) for a bug we don't\n> want to re-introduce.\n>\n> While I'm at it let's move the HOME assignment to just before\n> test_create_repo, it could be lower, but it seems better to set it\n> before calling anything in test-lib-functions.sh\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n\nI am not clear what the reasoning behind this change is.  Is it\ncorrect to say that the idea flows like the following?\n\n 0. If we do the $GIT_SKIP_TESTS check early, specifically, before\n    we create the trash directory to run the tests in, we do not\n    have to create and then remove it.\n\n 1. If we naïvely do the above, test_done called in the \"ah, the\n    entirety of test is skipped\" case will try to see if the trash\n    directory exists and complain, so we need to add more code in\n    that test_done codepath to avoid complaints.\n\n 2. As a part of that \"more code\", we mark the fact that we created\n    a new repository with $remove_trash variable.\n\nAssuming that the above flow of thought is what is behind this\npatch, I think the patch is mostly sensible.\n\nremove_trash needs to be cleared at the beginning, perhaps where\nstore_arg_to and opt_required_arg are cleared, though, to protect\nus from a stray environment variable.\n\nThanks.\n"},{"id":"421774","messageId":"xmqqk0p7cnhv.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-12.16-424caad189f-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T19:27:08Z","receivedAt":"2021-04-12T19:27:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n>  4. We don't need to move .git/hooks out of the way.\n\nIt might be unsafe to assume that we'd never have an\n'enabled-by-default' hook in blt/ template directory forever,\nthough.\n"},{"id":"421775","messageId":"xmqqfszvcna4.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-14.16-b6e9d971b40-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 14/16] test-lib-functions: use \"return 1\" instead of \"false\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T19:31:47Z","receivedAt":"2021-04-12T19:31:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Change a few functions that relied on a \"false\" being the last\n> statement in the function to use an explicit \"return 1\" like the other\n> functions in this file.\n\nWhile not wrong per-se, this and a few other changes in this series\nare typical of your multi-patch series that unnecessarily consume\nreviewer bandwidth that could be better spent on other more\nimportant and correctness sensitive steps (like 07/16) in the same\nseries.\n\nYou should find a good balance to avoid wearing out and distracting\nyour reviewers---they are the most scarce resource around here that\nmust be shared by other people, not just with other topics of your\nown.\n\nThanks.\n\n"},{"id":"421777","messageId":"xmqqa6q3cn0s.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-15.16-0cd511206c4-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T19:37:23Z","receivedAt":"2021-04-12T19:37:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n>  test_path_is_file () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif ! test -f \"$1\"\n> +\tif ! test -f \"$@\"\n>  \tthen\n> -\t\techo \"File $1 doesn't exist\"\n> +\t\techo \"File $@ doesn't exist\"\n>  \t\treturn 1\n\nWhat does it even mean to call\n\n\ttest_path_is_file Documentation/ Makefile\n\nwith this patch applied?\n\nIf there were three files \"COPYING Makefile\", \"COPYING\", and\n\"Makefile\", what would happen when you did\n\n\ttest_path_is_file COPYING Makefile\n\n(without dq around them)?\n\nI think this particular medicine is far worse than the symptom it\ntries to cure.\n\n\n"},{"id":"421778","messageId":"xmqq5z0rcmvz.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-16.16-b4a018a63f3-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 16/16] test-lib-functions: remove last two parameter count assertions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T19:40:16Z","receivedAt":"2021-04-12T19:40:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Remove a couple of parameter count assertions where we'll now silently\n> do the wrong thing if given too many parameters, unlike the \"$@\" cases\n> in the preceding commit where \"test\" etc. handle the check for usi.\n\nWhat's \"usi\" (not a \"cow\", I presume)?\n\nIf test_line_count is given 2 or 4 parameters, we'd call BUG---does\nthat \"silently do the wrong thing\"?  Why?\n\n> In the case of \"test_file_size\", the \"test-tool\" we're invoking is\n> happy to accept N parameters (it'll print out all N sizes). Let's just\n> use \"$@\" in that case anyway, there's only a few callers, and\n> eventually those should probably be moved to use the test-tool\n> directly.\n>\n> That only leaves test_line_count, I suppose I could leave that one\n> alone, but since it's the only common function left that does this\n> assertion let's remove it for the brevity of the -x output and\n> consistency with other functions.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/test-lib-functions.sh | 8 ++------\n>  1 file changed, 2 insertions(+), 6 deletions(-)\n>\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 2cf72b56851..32d6b98b972 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -822,10 +822,7 @@ test_path_is_missing () {\n>  # output through when the number of lines is wrong.\n>  \n>  test_line_count () {\n> -\tif test $# != 3\n> -\tthen\n> -\t\tBUG \"not 3 parameters to test_line_count\"\n> -\telif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n> +\tif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n>  \tthen\n>  \t\techo \"test_line_count: line count for $3 !$1 $2\"\n>  \t\tcat \"$3\"\n> @@ -834,8 +831,7 @@ test_line_count () {\n>  }\n>  \n>  test_file_size () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\ttest-tool path-utils file-size \"$1\"\n> +\ttest-tool path-utils file-size \"$@\"\n>  }\n>  \n>  # Returns success if a comma separated string of keywords ($1) contains a\n"},{"id":"421812","messageId":"xmqqo8ejb3lq.fsf@gitster.g","threadId":"55480","inReplyTo":"xmqqo8ejcogj.fsf@gitster.g","subject":"Re: [PATCH 02/16] test-lib: bring $remove_trash out of retirement","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T21:22:09Z","receivedAt":"2021-04-12T21:22:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> There's no point in creating a repository or directory only to decide\n>> right afterwards that we're skipping all the tests.\n>>\n>> So let's partially revert 06478dab4c (test-lib: retire $remove_trash\n>> variable, 2017-04-23) and move the decision about whether to skip all\n>> tests earlier.\n>>\n>> I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\n>> under --debug at the end of the test, 2017-04-24) for a bug we don't\n>> want to re-introduce.\n>>\n>> While I'm at it let's move the HOME assignment to just before\n>> test_create_repo, it could be lower, but it seems better to set it\n>> before calling anything in test-lib-functions.sh\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>\n> I am not clear what the reasoning behind this change is.  Is it\n> correct to say that the idea flows like the following?\n>\n>  0. If we do the $GIT_SKIP_TESTS check early, specifically, before\n>     we create the trash directory to run the tests in, we do not\n>     have to create and then remove it.\n>\n>  1. If we naïvely do the above, test_done called in the \"ah, the\n>     entirety of test is skipped\" case will try to see if the trash\n>     directory exists and complain, so we need to add more code in\n>     that test_done codepath to avoid complaints.\n>\n>  2. As a part of that \"more code\", we mark the fact that we created\n>     a new repository with $remove_trash variable.\n>\n> Assuming that the above flow of thought is what is behind this\n> patch, I think the patch is mostly sensible.\n\nBy the way, I did wonder if the call to test_done is even needed, or\nif it is even ready to be called (in other words, the machineries it\ntries to finalize like junit and HARNESS_ACTIVE are even initialized\nyet).  I verified that calling test_done this early is fine with\nrespect to the call it makes to finalize_junit_xml, though.\n\n> remove_trash needs to be cleared at the beginning, perhaps where\n> store_arg_to and opt_required_arg are cleared, though, to protect\n> us from a stray environment variable.\n>\n> Thanks.\n"},{"id":"421813","messageId":"xmqqk0p7b3d5.fsf@gitster.g","threadId":"55480","inReplyTo":"CAPig+cTTjX=keJJdXLfsP52tQJZULgzjqbvYm=QZLK2312qRmw@mail.gmail.com","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T21:27:18Z","receivedAt":"2021-04-12T21:27:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> The name \"printf\" has such strong association in programmer's minds\n> with \"%\" and argument consumption that the name of this option alone\n> almost begs people to take advantage of argument interpolation even\n> though it's documented here as not allowing it. Taking into\n> consideration that people often do not read documentation, `--printf`\n> as the name of the option may be an unfortunate one. Perhaps it could\n> be called `--raw` or something less likely to suggest argument\n> interpolation.\n\nThe reason we want to use 'printf' instead of 'echo' is because only\nsome implementations of 'echo' honors '\\t\\n\\r' etc., and 'echo' by\nothers show these literally.  Using printf(1) allows us to write\nthese backslashed special characters universally.\n\nSo, I find 'raw' equally confusing, if not more.\n\n>> @@ -192,6 +196,7 @@ debug () {\n>>\n>>  test_commit () {\n>>         notick= &&\n>> +       echo=echo &&\n>\n> This could be slightly confusing. I wonder if naming this variable\n> `emit` would be clearer.\n\nPerhaps.\n"},{"id":"421821","messageId":"CAPig+cQSS8yp-K8Z5q9eG1t-7sFAyuPEvFDNvX_JaY07BKcMhQ@mail.gmail.com","threadId":"55480","inReplyTo":"xmqqk0p7b3d5.fsf@gitster.g","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-12T23:04:22Z","receivedAt":"2021-04-12T23:04:38Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Apr 12, 2021 at 5:27 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n> > The name \"printf\" has such strong association in programmer's minds\n> > with \"%\" and argument consumption that the name of this option alone\n> > almost begs people to take advantage of argument interpolation even\n> > though it's documented here as not allowing it. Taking into\n> > consideration that people often do not read documentation, `--printf`\n> > as the name of the option may be an unfortunate one. Perhaps it could\n> > be called `--raw` or something less likely to suggest argument\n> > interpolation.\n>\n> The reason we want to use 'printf' instead of 'echo' is because only\n> some implementations of 'echo' honors '\\t\\n\\r' etc., and 'echo' by\n> others show these literally.  Using printf(1) allows us to write\n> these backslashed special characters universally.\n>\n> So, I find 'raw' equally confusing, if not more.\n\nI don't care for `--raw` either but couldn't think of anything better\nat the time. But perhaps a name such as `--allow-escapes` would be\nclearer, or perhaps not. `--c-style-escapes`?\n\nAnyhow, it's pure bikeshedding as I mentioned in my original email, so\nnot a big deal. I brought it up only because the very first thought\nthat popped into my head when reading the commit message saying it was\nadding `--printf` was \"oh, interesting; how do I specify the arguments\nto interpolate into the `printf` format string?\".\n"},{"id":"421822","messageId":"xmqqpmyzm71v.fsf@gitster.g","threadId":"55480","inReplyTo":"CAPig+cQSS8yp-K8Z5q9eG1t-7sFAyuPEvFDNvX_JaY07BKcMhQ@mail.gmail.com","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-12T23:12:12Z","receivedAt":"2021-04-12T23:12:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> I don't care for `--raw` either but couldn't think of anything better\n> at the time. But perhaps a name such as `--allow-escapes` would be\n> clearer, or perhaps not. `--c-style-escapes`?\n\nIt's printf(1) style escapes ;-)\n\n> Anyhow, it's pure bikeshedding as I mentioned in my original email, so\n> not a big deal. I brought it up only because the very first thought\n> that popped into my head when reading the commit message saying it was\n> adding `--printf` was \"oh, interesting; how do I specify the arguments\n> to interpolate into the `printf` format string?\".\n"},{"id":"422024","messageId":"87blafvl49.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"xmqqa6q3cn0s.fsf@gitster.g","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-15T11:32:38Z","receivedAt":"2021-04-15T11:32:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Apr 12 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>>  test_path_is_file () {\n>> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n>> -\tif ! test -f \"$1\"\n>> +\tif ! test -f \"$@\"\n>>  \tthen\n>> -\t\techo \"File $1 doesn't exist\"\n>> +\t\techo \"File $@ doesn't exist\"\n>>  \t\treturn 1\n>\n> What does it even mean to call\n>\n> \ttest_path_is_file Documentation/ Makefile\n>\n> with this patch applied?\n>\n> If there were three files \"COPYING Makefile\", \"COPYING\", and\n> \"Makefile\", what would happen when you did\n>\n> \ttest_path_is_file COPYING Makefile\n>\n> (without dq around them)?\n>\n> I think this particular medicine is far worse than the symptom it\n> tries to cure.\n\nWe'll error with:\n\n    test: foo: unexpected operator\n\nAnd then say:\n\n    File COPYING Makefile doesn't exist\n\nI thought guarding just for the one-off development error of not using\nthe function correctly wasn't worth it, but I thought it made sense not\nto litter all of this with:\n\t\n\tdiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n\tindex 28b8826e565..0bd7367a07e 100644\n\t--- a/t/test-lib-functions.sh\n\t+++ b/t/test-lib-functions.sh\n\t@@ -690,6 +690,7 @@ test_expect_success () {\n\t test_path_is_file () {\n\t \tif ! test -f \"$@\"\n\t \tthen\n\t+\t\ttest $# -eq 1 || BUG \"Do not call test_path_is_file() with more than one argument!\"\n\t \t\techo \"File $@ doesn't exist\"\n\t \t\treturn 1\n\t \tfi\n\nBut I could do that if you think it's better.\n\nWe could also just emit $1 in the \"echo\". I don't feel strongly about\nthat, but think that's arguably worse, since having it be $@ means the\ndeveloper is more likely to notice the invalid usage right away.\n\t\n"},{"id":"422025","messageId":"878s5jvl3i.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"xmqqpmyzm71v.fsf@gitster.g","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-15T11:33:05Z","receivedAt":"2021-04-15T11:33:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Apr 13 2021, Junio C Hamano wrote:\n\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>\n>> I don't care for `--raw` either but couldn't think of anything better\n>> at the time. But perhaps a name such as `--allow-escapes` would be\n>> clearer, or perhaps not. `--c-style-escapes`?\n>\n> It's printf(1) style escapes ;-)\n>\n>> Anyhow, it's pure bikeshedding as I mentioned in my original email, so\n>> not a big deal. I brought it up only because the very first thought\n>> that popped into my head when reading the commit message saying it was\n>> adding `--printf` was \"oh, interesting; how do I specify the arguments\n>> to interpolate into the `printf` format string?\".\n\nSo, the conclusion of this thread is let's keep it as --printf?\n"},{"id":"422026","messageId":"875z0nvkqi.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"xmqqk0p7cnhv.fsf@gitster.g","subject":"Re: [PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-15T11:40:53Z","receivedAt":"2021-04-15T11:41:01Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Apr 12 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>>  4. We don't need to move .git/hooks out of the way.\n>\n> It might be unsafe to assume that we'd never have an\n> 'enabled-by-default' hook in blt/ template directory forever,\n> though.\n\nI would think that if we injected run-by-default hooks into the\ntop-level repo creation any such breakage in the test suite would be a\nfeature, i.e. we'd want to see and adjust for the breakage, because\nsurely the same sort of breakage would occur in the wild.\n\nFWIW I've got some WIP local patches for the \"just ship a README in\nhooks/\":\nhttps://lore.kernel.org/git/20180601070609.GC15578@sigill.intra.peff.net/\n\nFrom memory the cumultive footprint of foot a -d run on the whole test\nsuite is on the order of ~1GB, and ~100MB is just the hooks over and\nover again...\n"},{"id":"422027","messageId":"87y2djrao7.fsf@igel.home","threadId":"55480","inReplyTo":"87blafvl49.fsf@evledraar.gmail.com","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2021-04-15T12:31:52Z","receivedAt":"2021-04-15T12:31:58Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Apr 15 2021, Ævar Arnfjörð Bjarmason wrote:\n\n> On Mon, Apr 12 2021, Junio C Hamano wrote:\n>\n>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>\n>>>  test_path_is_file () {\n>>> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n>>> -\tif ! test -f \"$1\"\n>>> +\tif ! test -f \"$@\"\n>>>  \tthen\n>>> -\t\techo \"File $1 doesn't exist\"\n>>> +\t\techo \"File $@ doesn't exist\"\n>>>  \t\treturn 1\n>>\n>> What does it even mean to call\n>>\n>> \ttest_path_is_file Documentation/ Makefile\n>>\n>> with this patch applied?\n>>\n>> If there were three files \"COPYING Makefile\", \"COPYING\", and\n>> \"Makefile\", what would happen when you did\n>>\n>> \ttest_path_is_file COPYING Makefile\n>>\n>> (without dq around them)?\n>>\n>> I think this particular medicine is far worse than the symptom it\n>> tries to cure.\n>\n> We'll error with:\n>\n>     test: foo: unexpected operator\n\nIf you want a single argument you should use \"$*\", not \"$@\".\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"},{"id":"422031","messageId":"CAPig+cRJ1j_FJcuf-T2xhPhJBWGH0_84SfbZ7V9NbSP+QdJpXQ@mail.gmail.com","threadId":"55480","inReplyTo":"878s5jvl3i.fsf@evledraar.gmail.com","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-15T14:52:33Z","receivedAt":"2021-04-15T14:54:14Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Apr 15, 2021 at 7:33 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> On Tue, Apr 13 2021, Junio C Hamano wrote:\n> > Eric Sunshine <sunshine@sunshineco.com> writes:\n> >> I don't care for `--raw` either but couldn't think of anything better\n> >> at the time. But perhaps a name such as `--allow-escapes` would be\n> >> clearer, or perhaps not. `--c-style-escapes`?\n> >\n> > It's printf(1) style escapes ;-)\n> >\n> So, the conclusion of this thread is let's keep it as --printf?\n\nIt was bikeshedding on my part, so I don't feel strongly. As\nmentioned, I only brought it up because my first thought was to wonder\nhow interpolation would work. One might suggest --printf-escapes or\n--string-escapes but the audience for this is so narrow (Git\ndevelopers) that the short and concise --printf is probably\npreferable.\n"},{"id":"422036","messageId":"YHhcwzYstq3i9qT4@danh.dev","threadId":"55480","inReplyTo":"patch-06.16-8d43fdd5865-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 06/16] test-lib functions: add an --annotated-tag option to \"test_commit\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-15T15:33:23Z","receivedAt":"2021-04-15T15:33:27Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-12 13:08:55+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>  \tgit branch B A^0\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index fa3e3e975fd..a0fcc383d0b 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -180,6 +180,10 @@ debug () {\n>  #   --no-tag\n>  #\tDo not tag the resulting commit, if supplied giving the\n>  #\toptional \"<tag>\" argument is an error.\n\nThis comment applied to previous patch, but I think we need this patch\nto justify for optional \"<tag>\" argument is an error for \"--no-tag\"\n\n----8<----\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex a0fcc383d0..ed0a4e5e5d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -253,6 +253,10 @@ test_commit () {\n \t    $signoff -m \"$1\" &&\n \tcase \"$tag\" in\n \tnone)\n+\t\tif test -z \"$4\"\n+\t\tthen\n+\t\t\tBUG \"<tag> given to test_commit --no-tag\"\n+\t\tfi\n \t\t;;\n \tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n----8<----\n> +#   --annotate\n> +#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n> +#\ttest_tick between making the commit and tag unless --notick is\n> +#\tgiven.\n>  #\n>  # This will commit a file with the given contents and the given commit\n>  # message, and tag the resulting commit with the given tag name.\n> @@ -192,7 +196,7 @@ test_commit () {\n>  \tauthor= &&\n>  \tsignoff= &&\n>  \tindir= &&\n> -\tno_tag= &&\n> +\ttag=light &&\n>  \twhile test $# != 0\n>  \tdo\n>  \t\tcase \"$1\" in\n> @@ -220,7 +224,10 @@ test_commit () {\n>  \t\t\tshift\n>  \t\t\t;;\n>  \t\t--no-tag)\n> -\t\t\tno_tag=yes\n> +\t\t\ttag=none\n> +\t\t\t;;\n> +\t\t--annotate)\n> +\t\t\ttag=annotate\n>  \t\t\t;;\n>  \t\t*)\n>  \t\t\tbreak\n> @@ -244,10 +251,20 @@ test_commit () {\n>  \tgit ${indir:+ -C \"$indir\"} commit \\\n>  \t    ${author:+ --author \"$author\"} \\\n>  \t    $signoff -m \"$1\" &&\n> -\tif test -z \"$no_tag\"\n> -\tthen\n> +\tcase \"$tag\" in\n> +\tnone)\n> +\t\t;;\n> +\tlight)\n>  \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n> -\tfi\n> +\t\t;;\n> +\tannotate)\n> +\t\tif test \"$tag$notick\" = \"annotate\"\n\nPerhap I'm missing something, however, I couldn't get the reason for\ninserting \"$tag\" here. I wonder what wrong with:\n\n\tif test -z \"$notick\"\n\tthen\n\t\ttest_tick\n\tfi &&\n\n> +\t\tthen\n> +\t\t\ttest_tick\n> +\t\tfi &&\n> +\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n> +\t\t;;\n> +\tesac\n>  }\n>  \n>  # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n> -- \n> 2.31.1.634.gb41287a30b0\n> \n\n-- \nDanh\n"},{"id":"422046","messageId":"xmqqh7k7qttn.fsf@gitster.g","threadId":"55480","inReplyTo":"87blafvl49.fsf@evledraar.gmail.com","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-15T18:35:48Z","receivedAt":"2021-04-15T18:35:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Mon, Apr 12 2021, Junio C Hamano wrote:\n>\n>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>\n>>>  test_path_is_file () {\n>>> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n>>> -\tif ! test -f \"$1\"\n>>> +\tif ! test -f \"$@\"\n>>>  \tthen\n>>> -\t\techo \"File $1 doesn't exist\"\n>>> +\t\techo \"File $@ doesn't exist\"\n>>>  \t\treturn 1\n>>\n>> What does it even mean to call\n>>\n>> \ttest_path_is_file Documentation/ Makefile\n>>\n>> with this patch applied?\n>>\n>> If there were three files \"COPYING Makefile\", \"COPYING\", and\n>> \"Makefile\", what would happen when you did\n>>\n>> \ttest_path_is_file COPYING Makefile\n>>\n>> (without dq around them)?\n>>\n>> I think this particular medicine is far worse than the symptom it\n>> tries to cure.\n>\n> We'll error with:\n>\n>     test: foo: unexpected operator\n\nAh, so use of \"$@\" was intentional.  That's clever (I thought it was\na common typo people make when they mean \"$*\").\n\nOf course, it would not work if the caller did a nonsense like so:\n\n\ttest_path_is_file foo -o ok\n\nbut as long as we trust that the callers would not make stupid\nmistakes, this is OK.  Is that the reasoning behind this removal of\nthe BUG?\n\n> I thought guarding just for the one-off development error of not using\n> the function correctly wasn't worth it, but I thought it made sense not\n> to litter all of this with:\n> \t\n> \tdiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> \tindex 28b8826e565..0bd7367a07e 100644\n> \t--- a/t/test-lib-functions.sh\n> \t+++ b/t/test-lib-functions.sh\n> \t@@ -690,6 +690,7 @@ test_expect_success () {\n> \t test_path_is_file () {\n> \t \tif ! test -f \"$@\"\n> \t \tthen\n> \t+\t\ttest $# -eq 1 || BUG \"Do not call test_path_is_file() with more than one argument!\"\n\nBut this breaks our assumption that the caller would not be making\nstupid mistakes, so I am not sure if it is worth it.  If we were to\nhave a sanity check, shouldn't we do the check upfront, like the\noriginal?\n\nThanks.\n"},{"id":"422047","messageId":"xmqqczuvqtr8.fsf@gitster.g","threadId":"55480","inReplyTo":"CAPig+cRJ1j_FJcuf-T2xhPhJBWGH0_84SfbZ7V9NbSP+QdJpXQ@mail.gmail.com","subject":"Re: [PATCH 08/16] test-lib functions: add --printf option to test_commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-15T18:37:15Z","receivedAt":"2021-04-15T18:37:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Thu, Apr 15, 2021 at 7:33 AM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>> On Tue, Apr 13 2021, Junio C Hamano wrote:\n>> > Eric Sunshine <sunshine@sunshineco.com> writes:\n>> >> I don't care for `--raw` either but couldn't think of anything better\n>> >> at the time. But perhaps a name such as `--allow-escapes` would be\n>> >> clearer, or perhaps not. `--c-style-escapes`?\n>> >\n>> > It's printf(1) style escapes ;-)\n>> >\n>> So, the conclusion of this thread is let's keep it as --printf?\n>\n> It was bikeshedding on my part, so I don't feel strongly. As\n> mentioned, I only brought it up because my first thought was to wonder\n> how interpolation would work. One might suggest --printf-escapes or\n> --string-escapes but the audience for this is so narrow (Git\n> developers) that the short and concise --printf is probably\n> preferable.\n\nAfter seeing you raised the issue, I wish we had a better option\nname than --printf to be even more clear, but the wish is not strong\nenough to make me say \"let's stop until we come up with the perfect\nname\".  I am OK with --printf\n\nThanks.\n"},{"id":"422048","messageId":"20210415190751.GL2947267@szeder.dev","threadId":"55480","inReplyTo":"patch-11.16-cdbff4df362-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 11/16] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-15T19:07:51Z","receivedAt":"2021-04-15T19:07:56Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 12, 2021 at 01:09:00PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 674b865a20d..c81726acb9e 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1259,7 +1259,6 @@ test_create_repo () {\n>  \t(\n>  \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n>  \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n> -\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n>  \t\t\tinit \\\n\nThis change got my hopes up that\n\n  GIT_TEST_INSTALLED=/.../v1.6.0/bin ./t9999-foo.sh\n\nwill work again (it didn't yet support 'git init -c <...>'), but,\nalas, already the next patch will turn this into 'git init ...\n<trash-dir>', and v1.6.0 didn't support that, either, so it will\nremain broken...  Oh, well.\n\n>  \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n>  \t\terror \"cannot run git init -- have you built things yet?\"\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index a8869eee58f..0057dfa69d0 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -64,6 +64,11 @@ then\n>  \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n>  fi\n>  \n> +# Explicitly set the default branch name for testing, to avoid the\n> +# transitory \"git init\" warning under --verbose.\n> +: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n> +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n> +\n>  ################################################################\n>  # It appears that people try to run tests without building...\n>  \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n> -- \n> 2.31.1.634.gb41287a30b0\n> \n"},{"id":"422060","messageId":"20210415211013.GM2947267@szeder.dev","threadId":"55480","inReplyTo":"patch-12.16-424caad189f-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-15T21:10:13Z","receivedAt":"2021-04-15T21:10:19Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 12, 2021 at 01:09:01PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> Remove redundant \"mkdir -p\", argument number checking', test\n> environment sanity checking, and disabling of hooks from\n> test_create_repo(). As we'll see below these were all either redundant\n> to other test other framework code, or to changes in git itself.\n> \n> Respectively:\n> \n>  1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n>     leading directories if needed.\n> \n>  2. We don't need to check the number of arguments anymore, instead\n>     we'll feed \"git init\" with \"$@\". It will die if given too many\n>     arguments.\n\nOr it will succeed if invoked as e.g. 'test_create_repo --bare repo'.\n\n>  3. We won't ever hit that \"Cannot setup test environment\"\n>     error.\n\nENOSPC?  Some rogue background process on Windows still desperately\nclinging to an open file descriptor to some file in the same\ndirectory, preventing 'rm -rf \"$TRASH_DIRECTORY\"' near the beginning\nof 'test-lib.sh' and interfering with 'git init'?\n\n>     Checking the test environment sanity when doing \"git init\" dates\n>     back to eea420693be (t0000: catch trivial pilot errors.,\n>     2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n>     was successfully created, 2006-01-05).\n> \n>     We can also see it in another form a bit later in my own\n>     0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n>     $old, 2010-08-30).\n> \n>     But since 2006f0adaee (t/test-lib: make sure Git has already been\n>     built, 2012-09-17) we already check if we have a built git\n>     earlier.\n> \n>     The one thing this was testing after that 2012 change was that\n>     we'd just built \"git\", but not \"git-init\", but since\n>     3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n>     repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n> \n>     So all of that's been checked already, and we don't need to\n>     re-check it here.\n\nI agree that if we already have a 'git' binary that can run 'git\nversion', then we can safely assume that it will be able to run 'git\ninit' as well.  It might be that 'git init' is buggy and segfaults,\nbut that is not a \"have you built things yet?\" kind of error.\n\n>  4. We don't need to move .git/hooks out of the way.\n> \n>     That dates back to c09a69a83e3 (Disable hooks during tests.,\n>     2005-10-16), since then hooks became disabled by default in\n>     f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n> \n>     So the hooks were already disabled by default, but as can be seen\n>     from \"mkdir .git/hooks\" changes various tests needed to re-setup\n>     that directory. Now they no longer do.\n> \n>  5. Since we don't need to move the .git/hooks directory we don't need\n>     the subshell here either.\n\nWe needed the subshell because we changed directory in\n'test_create_repo' (even you referenced 0d314ce834d above), not\nbecause we moved the hooks directory.\n\n> In the end it turns out that all we needed was a plain \"git init\"\n> invocation with a custom --template directory.\n\nWe don't need '--template', either; see below.\n\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index c81726acb9e..1258329fdd8 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1252,18 +1252,9 @@ test_atexit () {\n>  # Most tests can use the created repository, but some may need to create more.\n>  # Usage: test_create_repo <directory>\n>  test_create_repo () {\n> -\ttest \"$#\" = 1 ||\n> -\tBUG \"not 1 parameter to test-create-repo\"\n> -\trepo=\"$1\"\n> -\tmkdir -p \"$repo\"\n> -\t(\n> -\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n> -\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n> -\t\t\tinit \\\n> -\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n> -\t\terror \"cannot run git init -- have you built things yet?\"\n> -\t\tmv .git/hooks .git/hooks-disabled\n> -\t) || exit\n\nThis patch removes this '|| exit', which is...\n\n  - good: if 'test_create_repo' is invoked in a test case (and not in\n    a subshell) and if it were to fail for some reason, then it won't\n    abort the whole test script, but will fail only that test case.\n\n  - bad: 'test_create_repo' is responsible for creating the repository\n    in the trash directory as well; if that were to fail for any\n    reason, then the test script will not be aborted early.\n\nI think the 'exit' on error should be removed from 'test_create_repo',\nbut the callsite in 'test-lib.sh' should become 'test_create_repo ||\nexit 1'.\n\nIn any case, removing this '|| exit' is not mentioned in the commit\nmessage.\n\n> +\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n\nPATH is already set up to start with GIT_TEST_INSTALLED and/or\nGIT_EXEC_PATH before 'test_create_repo' is called to init the repo in\nthe trash directory, so we could simply run 'git' and rely on PATH\nlookup choosing the right executable.\n\n> +\t\tinit \\\n> +\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" \"$@\" >&3 2>&4\n\nLikewise, GIT_TEMPLATE_DIR is already set up to the same value as in\nthis '--template=...' option, so we could omit this option as well.\n\nAnd after that all that would remain in this function is:\n\n  git init \"$1\" >&3 2>&4\n\nAnd those redirections are only needed when this function is called to\ninitialize the repo in the trash directory, but not when it creates a\nrepo in a test case.  This makes me question the value of having this\n'test_create_repo' helper function at all; there are already over 800\ncases where we run plain 'git init' outside of 't0001-init.sh' instead\nof 'test_create_repo', though removing it would be definitely cause\nsome churn with over 300 callsites.\n\n\n\n>  }\n>  \n>  # This function helps on symlink challenged file systems when it is not\n> -- \n> 2.31.1.634.gb41287a30b0\n> \n"},{"id":"422068","messageId":"20210415220526.GO2947267@szeder.dev","threadId":"55480","inReplyTo":"patch-15.16-0cd511206c4-20210412T110456Z-avarab@gmail.com","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-15T22:05:26Z","receivedAt":"2021-04-15T22:05:35Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Apr 12, 2021 at 01:09:04PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> This reverts and amends my my own e7884b353b7 (test-lib-functions:\n> assert correct parameter count, 2021-02-12) in order to improve the -x\n> output.\n> \n> When I added these BUG assertions in e7884b353b7 I missed that this\n> made the -x output much more verbose.\n> \n> E.g. for each test_cmp invocation we'd now emit:\n> \n>     + test_cmp expect actual\n>     + test 2 -ne 2\n>     + eval diff -u \"$@\"\n>     + diff -u expect actual\n> \n> That \"test 2 -ne 2\" line is new in e7884b353b7. As noted in\n> 45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\n> helper param, 2021-02-12) we had buggy invocations of some of these\n> functions with too many parameters.\n> \n> Let's instead use \"$@\" instead of \"$1\" to achieve the same ends with\n> no extra -x output verbosity. The \"test\" operator will die with an\n> error if given more than one argument in these contexts, so using \"$@\"\n> achieves the same goal.\n\nI prefer the current check for its explicitness over the implicit and\nsomewhat cryptic approach introduced in this patch.  I hope that\nsooner or later I'll finish up my patch series to suppress '-x' output\nfrom test helper functions, and then this issue will become moot\nanyway.\n\n> The same goes for \"cmp\" and \"diff -u\" (which we typically use for\n> test_cmp).\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/test-lib-functions.sh | 41 ++++++++++++++++-------------------------\n>  1 file changed, 16 insertions(+), 25 deletions(-)\n> \n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index c46bf0ff09c..2cf72b56851 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -759,39 +759,35 @@ test_external_without_stderr () {\n>  # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n>  # The commands test the existence or non-existence of $1\n>  test_path_is_file () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif ! test -f \"$1\"\n> +\tif ! test -f \"$@\"\n>  \tthen\n> -\t\techo \"File $1 doesn't exist\"\n> +\t\techo \"File $@ doesn't exist\"\n>  \t\treturn 1\n>  \tfi\n>  }\n>  \n>  test_path_is_dir () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif ! test -d \"$1\"\n> +\tif ! test -d \"$@\"\n>  \tthen\n> -\t\techo \"Directory $1 doesn't exist\"\n> +\t\techo \"Directory $@ doesn't exist\"\n>  \t\treturn 1\n>  \tfi\n>  }\n>  \n>  test_path_exists () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif ! test -e \"$1\"\n> +\tif ! test -e \"$@\"\n>  \tthen\n> -\t\techo \"Path $1 doesn't exist\"\n> +\t\techo \"Path $@ doesn't exist\"\n>  \t\treturn 1\n>  \tfi\n>  }\n>  \n>  # Check if the directory exists and is empty as expected, barf otherwise.\n>  test_dir_is_empty () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\ttest_path_is_dir \"$1\" &&\n> -\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n> +\ttest_path_is_dir \"$@\" &&\n> +\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n>  \tthen\n> -\t\techo \"Directory '$1' is not empty, it contains:\"\n> +\t\techo \"Directory '$@' is not empty, it contains:\"\n>  \t\tls -la \"$1\"\n>  \t\treturn 1\n>  \tfi\n> @@ -799,17 +795,15 @@ test_dir_is_empty () {\n>  \n>  # Check if the file exists and has a size greater than zero\n>  test_file_not_empty () {\n> -\ttest \"$#\" = 2 && BUG \"2 param\"\n> -\tif ! test -s \"$1\"\n> +\tif ! test -s \"$@\"\n>  \tthen\n> -\t\techo \"'$1' is not a non-empty file.\"\n> +\t\techo \"'$@' is not a non-empty file.\"\n>  \t\treturn 1\n>  \tfi\n>  }\n>  \n>  test_path_is_missing () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif test -e \"$1\"\n> +\tif test -e \"$@\"\n>  \tthen\n>  \t\techo \"Path $1 exists!\"\n>  \t\tfalse\n> @@ -1013,7 +1007,6 @@ test_expect_code () {\n>  # - not all diff versions understand \"-u\"\n>  \n>  test_cmp () {\n> -\ttest \"$#\" -ne 2 && BUG \"2 param\"\n>  \teval \"$GIT_TEST_CMP\" '\"$@\"'\n>  }\n>  \n> @@ -1043,7 +1036,6 @@ test_cmp_config () {\n>  # test_cmp_bin - helper to compare binary files\n>  \n>  test_cmp_bin () {\n> -\ttest \"$#\" -ne 2 && BUG \"2 param\"\n>  \tcmp \"$@\"\n>  }\n>  \n> @@ -1104,12 +1096,11 @@ verbose () {\n>  # otherwise.\n>  \n>  test_must_be_empty () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\ttest_path_is_file \"$1\" &&\n> -\tif test -s \"$1\"\n> +\ttest_path_is_file \"$@\" &&\n> +\tif test -s \"$@\"\n>  \tthen\n> -\t\techo \"'$1' is not empty, it contains:\"\n> -\t\tcat \"$1\"\n> +\t\techo \"'$@' is not empty, it contains:\"\n> +\t\tcat \"$@\"\n>  \t\treturn 1\n>  \tfi\n>  }\n> -- \n> 2.31.1.634.gb41287a30b0\n> \n"},{"id":"422070","messageId":"xmqqfszrnq4b.fsf@gitster.g","threadId":"55480","inReplyTo":"20210415220526.GO2947267@szeder.dev","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-15T22:24:04Z","receivedAt":"2021-04-15T22:24:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> ...  suppress '-x' output\n> from test helper functions, and then this issue will become moot\n> anyway.\n\nThat is certainly a better approach than tweaking each call site of\nBUG.\n\nThe interface to BUG is \"write a code to determine condition and\nthen die by calling BUG\", which means under '-x' you are bound to\nsee the trace from \"code to determine condition\" part.\n\nI wonder if introducing a BUG_ON helper function that\n\n - turns off '-x' trace upon entry;\n - takes a condition as one of its arguments and evals it;\n - issues a message and dies if needed;\n - otherwise arranges to turn '-x' trace on and return.\n\nwould solve it well?\n\nThanks.\n"},{"id":"422122","messageId":"87zgxy0wje.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"xmqqh7k7qttn.fsf@gitster.g","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-16T21:06:13Z","receivedAt":"2021-04-16T21:06:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Apr 15 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> On Mon, Apr 12 2021, Junio C Hamano wrote:\n>>\n>>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>>\n>>>>  test_path_is_file () {\n>>>> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n>>>> -\tif ! test -f \"$1\"\n>>>> +\tif ! test -f \"$@\"\n>>>>  \tthen\n>>>> -\t\techo \"File $1 doesn't exist\"\n>>>> +\t\techo \"File $@ doesn't exist\"\n>>>>  \t\treturn 1\n>>>\n>>> What does it even mean to call\n>>>\n>>> \ttest_path_is_file Documentation/ Makefile\n>>>\n>>> with this patch applied?\n>>>\n>>> If there were three files \"COPYING Makefile\", \"COPYING\", and\n>>> \"Makefile\", what would happen when you did\n>>>\n>>> \ttest_path_is_file COPYING Makefile\n>>>\n>>> (without dq around them)?\n>>>\n>>> I think this particular medicine is far worse than the symptom it\n>>> tries to cure.\n>>\n>> We'll error with:\n>>\n>>     test: foo: unexpected operator\n>\n> Ah, so use of \"$@\" was intentional.  That's clever (I thought it was\n> a common typo people make when they mean \"$*\").\n>\n> Of course, it would not work if the caller did a nonsense like so:\n>\n> \ttest_path_is_file foo -o ok\n>\n> but as long as we trust that the callers would not make stupid\n> mistakes, this is OK.  Is that the reasoning behind this removal of\n> the BUG?\n\nThe reasoning is to get rid of verbosity in the trace output, while\nstill effectively retaining the error checking.\n\nYes you could do \"foo -o ok\", but as my already-on-master fixes to the\nfew misuses showed we only realistically have to worry about them being\nused with many normal looking file names (if that).\n\n>> I thought guarding just for the one-off development error of not using\n>> the function correctly wasn't worth it, but I thought it made sense not\n>> to litter all of this with:\n>> \t\n>> \tdiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n>> \tindex 28b8826e565..0bd7367a07e 100644\n>> \t--- a/t/test-lib-functions.sh\n>> \t+++ b/t/test-lib-functions.sh\n>> \t@@ -690,6 +690,7 @@ test_expect_success () {\n>> \t test_path_is_file () {\n>> \t \tif ! test -f \"$@\"\n>> \t \tthen\n>> \t+\t\ttest $# -eq 1 || BUG \"Do not call test_path_is_file() with more than one argument!\"\n>\n> But this breaks our assumption that the caller would not be making\n> stupid mistakes, so I am not sure if it is worth it.  If we were to\n> have a sanity check, shouldn't we do the check upfront, like the\n> original?\n\nIt's fine to do sanity checking if it's in the \"else\" branch where we're\nalready emitting an error, and we only do so in the BUG case.\n\nI.e. if it's written like e.g. this:\n\t\n\ttest_path_is_file () {\n\t\tif test $# -ne 1\n\t\tthen\n\t\t\tBUG \"Do not call test_path_is_file() with more than one argument!\"\n\t\telif ! test -f \"$@\"\n\t\tthen\n\t\t\techo \"File $@ doesn't exist\"\n\nThen with e.g.:\n\n    ./t3600-rm.sh  --run=1-3 -vx\n\nWe get:\n\t\n\t+ test_path_is_file foo\n\t+ test 1 -ne 1\n\t+ test -f foo\n\t+ git ls-files --error-unmatch foo\n\nBut if we, as my patch does, piggy-pack on the test-built in to panic on\ntoo many arguments we get the much more succinct:\n\t\n\t+ test_path_is_file foo\n\t+ test -f foo\n\t+ git ls-files --error-unmatch foo\n\nI think that's the only trace output that matters, having \"test 2 -ne 1\"\nor whatever in the case where we're just about to invoke BUG anyway is\nfine.\n\n\n\n\t\n"},{"id":"422124","messageId":"20210416212251.GQ2947267@szeder.dev","threadId":"55480","inReplyTo":"20210415211013.GM2947267@szeder.dev","subject":"Re: [PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-16T21:22:51Z","receivedAt":"2021-04-16T21:22:58Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Thu, Apr 15, 2021 at 11:10:13PM +0200, SZEDER Gábor wrote:\n> >  3. We won't ever hit that \"Cannot setup test environment\"\n> >     error.\n> \n> ENOSPC?  Some rogue background process on Windows still desperately\n> clinging to an open file descriptor to some file in the same\n> directory, preventing 'rm -rf \"$TRASH_DIRECTORY\"' near the beginning\n> of 'test-lib.sh' and interfering with 'git init'?\n> \n> >     Checking the test environment sanity when doing \"git init\" dates\n> >     back to eea420693be (t0000: catch trivial pilot errors.,\n> >     2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n> >     was successfully created, 2006-01-05).\n> > \n> >     We can also see it in another form a bit later in my own\n> >     0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n> >     $old, 2010-08-30).\n> > \n> >     But since 2006f0adaee (t/test-lib: make sure Git has already been\n> >     built, 2012-09-17) we already check if we have a built git\n> >     earlier.\n> > \n> >     The one thing this was testing after that 2012 change was that\n> >     we'd just built \"git\", but not \"git-init\", but since\n> >     3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n> >     repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n> > \n> >     So all of that's been checked already, and we don't need to\n> >     re-check it here.\n> \n> I agree that if we already have a 'git' binary that can run 'git\n> version', then we can safely assume that it will be able to run 'git\n> init' as well.  It might be that 'git init' is buggy and segfaults,\n> but that is not a \"have you built things yet?\" kind of error.\n\n> > -\tmkdir -p \"$repo\"\n> > -\t(\n> > -\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n> > -\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n> > -\t\t\tinit \\\n> > -\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n> > -\t\terror \"cannot run git init -- have you built things yet?\"\n> > -\t\tmv .git/hooks .git/hooks-disabled\n> > -\t) || exit\n> \n> This patch removes this '|| exit', which is...\n> \n>   - good: if 'test_create_repo' is invoked in a test case (and not in\n>     a subshell) and if it were to fail for some reason, then it won't\n>     abort the whole test script, but will fail only that test case.\n> \n>   - bad: 'test_create_repo' is responsible for creating the repository\n>     in the trash directory as well; if that were to fail for any\n>     reason, then the test script will not be aborted early.\n> \n> I think the 'exit' on error should be removed from 'test_create_repo',\n> but the callsite in 'test-lib.sh' should become 'test_create_repo ||\n> exit 1'.\n\nCase in point: the bug I just reported in\n\n  https://public-inbox.org/git/20210416211451.GP2947267@szeder.dev/\n\ndoes break Git in a way that in one of our CI jobs 'git init' is\nunable to create the repository in the trash directory.\n\n"},{"id":"422136","messageId":"87wnt12424.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"20210415211013.GM2947267@szeder.dev","subject":"Re: [PATCH 12/16] test-lib: modernize test_create_repo() function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-16T23:38:27Z","receivedAt":"2021-04-16T23:38:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Apr 15 2021, SZEDER Gábor wrote:\n\n> On Mon, Apr 12, 2021 at 01:09:01PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>> Remove redundant \"mkdir -p\", argument number checking', test\n>> environment sanity checking, and disabling of hooks from\n>> test_create_repo(). As we'll see below these were all either redundant\n>> to other test other framework code, or to changes in git itself.\n>> \n>> Respectively:\n>> \n>>  1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n>>     leading directories if needed.\n>> \n>>  2. We don't need to check the number of arguments anymore, instead\n>>     we'll feed \"git init\" with \"$@\". It will die if given too many\n>>     arguments.\n>\n> Or it will succeed if invoked as e.g. 'test_create_repo --bare repo'.\n\nWhich is fine, no? I'll make it clearer in the commit message, but I'm\naiming to address plausible bugs due to these functions not erroring out\nin one way or another, if you call it with \"--bare repo\" that's clearly\nwhat you wanted, as opposed to \"foo bar\" and we don't create a repo\nunder \"bar\".\n\n>>  3. We won't ever hit that \"Cannot setup test environment\"\n>>     error.\n>\n> ENOSPC?  Some rogue background process on Windows still desperately\n> clinging to an open file descriptor to some file in the same\n> directory, preventing 'rm -rf \"$TRASH_DIRECTORY\"' near the beginning\n> of 'test-lib.sh' and interfering with 'git init'?\n\nI mean to say we won't hit it for the reasons we'd have that error there\nin the first place.\n\nOf course \"git init\" can still error, but we'll catch that in other\nways.\n\n>>     Checking the test environment sanity when doing \"git init\" dates\n>>     back to eea420693be (t0000: catch trivial pilot errors.,\n>>     2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n>>     was successfully created, 2006-01-05).\n>> \n>>     We can also see it in another form a bit later in my own\n>>     0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n>>     $old, 2010-08-30).\n>> \n>>     But since 2006f0adaee (t/test-lib: make sure Git has already been\n>>     built, 2012-09-17) we already check if we have a built git\n>>     earlier.\n>> \n>>     The one thing this was testing after that 2012 change was that\n>>     we'd just built \"git\", but not \"git-init\", but since\n>>     3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n>>     repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n>> \n>>     So all of that's been checked already, and we don't need to\n>>     re-check it here.\n>\n> I agree that if we already have a 'git' binary that can run 'git\n> version', then we can safely assume that it will be able to run 'git\n> init' as well.  It might be that 'git init' is buggy and segfaults,\n> but that is not a \"have you built things yet?\" kind of error.\n\n*nod*\n\n>>  4. We don't need to move .git/hooks out of the way.\n>> \n>>     That dates back to c09a69a83e3 (Disable hooks during tests.,\n>>     2005-10-16), since then hooks became disabled by default in\n>>     f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n>> \n>>     So the hooks were already disabled by default, but as can be seen\n>>     from \"mkdir .git/hooks\" changes various tests needed to re-setup\n>>     that directory. Now they no longer do.\n>> \n>>  5. Since we don't need to move the .git/hooks directory we don't need\n>>     the subshell here either.\n>\n> We needed the subshell because we changed directory in\n> 'test_create_repo' (even you referenced 0d314ce834d above), not\n> because we moved the hooks directory.\n\nWell, yes and no, a minor point but we'd need to do some juggling with\nsaving the $PWD in a variable etc. if it wasn't for the subshell, I\nthink that's why it got added in the first place.\n\n>> In the end it turns out that all we needed was a plain \"git init\"\n>> invocation with a custom --template directory.\n>\n> We don't need '--template', either; see below.\n\nAh, interesting.\n\n>> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n>> index c81726acb9e..1258329fdd8 100644\n>> --- a/t/test-lib-functions.sh\n>> +++ b/t/test-lib-functions.sh\n>> @@ -1252,18 +1252,9 @@ test_atexit () {\n>>  # Most tests can use the created repository, but some may need to create more.\n>>  # Usage: test_create_repo <directory>\n>>  test_create_repo () {\n>> -\ttest \"$#\" = 1 ||\n>> -\tBUG \"not 1 parameter to test-create-repo\"\n>> -\trepo=\"$1\"\n>> -\tmkdir -p \"$repo\"\n>> -\t(\n>> -\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n>> -\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n>> -\t\t\tinit \\\n>> -\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n>> -\t\terror \"cannot run git init -- have you built things yet?\"\n>> -\t\tmv .git/hooks .git/hooks-disabled\n>> -\t) || exit\n>\n> This patch removes this '|| exit', which is...\n>\n>   - good: if 'test_create_repo' is invoked in a test case (and not in\n>     a subshell) and if it were to fail for some reason, then it won't\n>     abort the whole test script, but will fail only that test case.\n\n*nod*\n\n>   - bad: 'test_create_repo' is responsible for creating the repository\n>     in the trash directory as well; if that were to fail for any\n>     reason, then the test script will not be aborted early.\n>\n> I think the 'exit' on error should be removed from 'test_create_repo',\n> but the callsite in 'test-lib.sh' should become 'test_create_repo ||\n> exit 1'.\n>\n> In any case, removing this '|| exit' is not mentioned in the commit\n> message.\n\nI'll fix that code. FWIW I the \"|| exit 1\" is effectively not removed in\nalmost all cases where \"git init\" would error, because in test-lib.sh we\ncd to the just-init-ed directory, and if we can't we'll fail.\n\nBut yes, it won't catch e.g. git-init dying midway through, us running\nout of space while populating that directory etc.\n\n>> +\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n>\n> PATH is already set up to start with GIT_TEST_INSTALLED and/or\n> GIT_EXEC_PATH before 'test_create_repo' is called to init the repo in\n> the trash directory, so we could simply run 'git' and rely on PATH\n> lookup choosing the right executable.\n\n>> +\t\tinit \\\n>> +\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" \"$@\" >&3 2>&4\n>\n> Likewise, GIT_TEMPLATE_DIR is already set up to the same value as in\n> this '--template=...' option, so we could omit this option as well.\n>\n> And after that all that would remain in this function is:\n>\n>   git init \"$1\" >&3 2>&4\n>\n> And those redirections are only needed when this function is called to\n> initialize the repo in the trash directory, but not when it creates a\n> repo in a test case.  This makes me question the value of having this\n> 'test_create_repo' helper function at all; there are already over 800\n> cases where we run plain 'git init' outside of 't0001-init.sh' instead\n> of 'test_create_repo', though removing it would be definitely cause\n> some churn with over 300 callsites.\n\nI'd missed how GIT_TEMPLATE_DIR was being set, that allows us to make\nthis much simpler indeed!\n\n>>  }\n>>  \n>>  # This function helps on symlink challenged file systems when it is not\n>> -- \n>> 2.31.1.634.gb41287a30b0\n>> \n\n"},{"id":"422137","messageId":"87tuo523l8.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"20210415220526.GO2947267@szeder.dev","subject":"Re: [PATCH 15/16] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-16T23:48:35Z","receivedAt":"2021-04-16T23:48:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Apr 16 2021, SZEDER Gábor wrote:\n\n> On Mon, Apr 12, 2021 at 01:09:04PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>> This reverts and amends my my own e7884b353b7 (test-lib-functions:\n>> assert correct parameter count, 2021-02-12) in order to improve the -x\n>> output.\n>> \n>> When I added these BUG assertions in e7884b353b7 I missed that this\n>> made the -x output much more verbose.\n>> \n>> E.g. for each test_cmp invocation we'd now emit:\n>> \n>>     + test_cmp expect actual\n>>     + test 2 -ne 2\n>>     + eval diff -u \"$@\"\n>>     + diff -u expect actual\n>> \n>> That \"test 2 -ne 2\" line is new in e7884b353b7. As noted in\n>> 45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\n>> helper param, 2021-02-12) we had buggy invocations of some of these\n>> functions with too many parameters.\n>> \n>> Let's instead use \"$@\" instead of \"$1\" to achieve the same ends with\n>> no extra -x output verbosity. The \"test\" operator will die with an\n>> error if given more than one argument in these contexts, so using \"$@\"\n>> achieves the same goal.\n>\n> I prefer the current check for its explicitness over the implicit and\n> somewhat cryptic approach introduced in this patch.\n\nFair enough, I think it's worth it to have a bit of a non-obvious pattern there for less trace verbosity across the board.\n\n> I hope that sooner or later I'll finish up my patch series to suppress\n> '-x' output from test helper functions, and then this issue will\n> become moot anyway.\n\nThat sounds like an interesting feature for those who want it, but it's\nentirely orthagonal to the direction this patch is taking.\n\nI'd like to have trace output for when tests descend into\ntest-lib-functions.sh and friends, I'd just like the most frequently\nused code there to not be needlessly verbose.\n\nThat's not the same as wanting to hide it entirely, i.e. treat\ntest_path_is_file et al as though they were shell built-ins.\n"},{"id":"422164","messageId":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH v2 00/12] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:33Z","receivedAt":"2021-04-17T12:53:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This is a \"various small fixes\" series to test-lib.sh,\ntest-lib-functions.sh.\n\nI've addressed the feedback on v1, the \"test_create_repo\" function is\nnow purely a dumb \"git init\" wrapper without any arguments, thanks to\nSZEDER's observation.\n\nThe trickery with \"test\" arguments and \"$@\" later in the series seemed\nmore controversial, so I've peeled those patches off. I'll submit them\nas another series, I've got various other serieses waiting on the\n\"test_commit\" functions here so I'd like to get this in sooner than\nlater, rather than having it hang on the discussion around that.\n\nÆvar Arnfjörð Bjarmason (12):\n  check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: split up and deprecate test_create_repo()\n\n t/check-non-portable-shell.pl       |  2 +\n t/lib-submodule-update.sh           |  3 +-\n t/t0000-basic.sh                    |  4 --\n t/t1307-config-blob.sh              |  4 +-\n t/t1403-show-ref.sh                 |  6 +--\n t/t2030-unresolve-info.sh           |  3 +-\n t/t4006-diff-mode.sh                |  6 +--\n t/t4030-diff-textconv.sh            |  8 +---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 -\n t/t5409-colorize-remote-messages.sh |  1 -\n t/t5520-pull.sh                     | 10 +----\n t/t6120-describe.sh                 | 58 +++++++---------------------\n t/test-lib-functions.sh             | 60 ++++++++++++++++++-----------\n t/test-lib.sh                       | 41 ++++++++++++--------\n 15 files changed, 90 insertions(+), 119 deletions(-)\n\nRange-diff against v1:\n 1:  8e4b4a2a216 !  1:  a8b483bc771 check-non-portable-shell: complain about \"test\" a/-o instead of &&/||\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    check-non-portable-shell: complain about \"test\" a/-o instead of &&/||\n    +    check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"\n     \n    -    Expand the t/check-non-portable-shell.pl checks to complain about the\n    -    use of \"-a\" and \"-o\" to the \"test\" shell built-in to to mean \"and\" and\n    -    \"or\", as opposed to using two \"test\" invocations with \"&&\" or \"||\".\n    +    Add a check for -a/-o in \"test\", as a follow-up to the\n    +    CodingGuidelines having recommended against their use since\n    +    897f964c0dc (CodingGuidelines: avoid \"test <cond> -a/-o <cond>\",\n    +    2014-05-20).\n     \n    -    There aren't any portability issues with using that construct that I\n    -    know of, but since Junio expressed a dislike of it in [1] and we've\n    -    currently got no such constructs let's add it to the lint checking. I\n    -    had various in-flight and WIP patches that used this construct.\n    +    These constructs are considered obsolescent by POSIX[1]. GNU has\n    +    likewise warned against them[2] for a few decades.\n     \n    -    1. https://lore.kernel.org/git/xmqqa6qkb5fi.fsf@gitster.g/\n    +    These will only match the simplistic forms of `test -X blah` (where\n    +    \"-X\" is some single letter option), but will miss expressions such as\n    +    `test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\n    +    things like:\n    +\n    +        test whatever && ls -a foo\n    +        test whatever && foo -o outfile\n    +\n    +    1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16\n    +    2. https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## t/check-non-portable-shell.pl ##\n     @@ t/check-non-portable-shell.pl: sub err {\n    - \tnext if $line =~ s/\\\\$//;\n    - \n    - \t$_ = $line;\n    -+\t# Portability issues\n    - \t/\\bcp\\s+-a/ and err 'cp -a is not portable';\n    - \t/\\bsed\\s+-[^efn]\\s+/ and err 'sed option not portable (use only -n, -e, -f)';\n    - \t/\\becho\\s+-[neE]/ and err 'echo with option is not portable (use printf)';\n    -@@ t/check-non-portable-shell.pl: sub err {\n    - \t/\\bexport\\s+[A-Za-z0-9_]*=/ and err '\"export FOO=bar\" is not portable (use FOO=bar && export FOO)';\n    - \t/^\\s*([A-Z0-9_]+=(\\w*|([\"']).*?\\3)\\s+)+(\\w+)/ and exists($func{$4}) and\n    - \t\terr '\"FOO=bar shell_func\" assignment extends beyond \"shell_func\"';\n    -+\t# Coding style preferences\n    -+\t/\\btest\\s+-[a-z]\\s+.*?\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n    -+\t/\\btest\\s+-[a-z]\\s+.*?\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n    - \t$line = '';\n    - \t# this resets our $. for each file\n    - \tclose ARGV if eof;\n    + \t/^\\s*declare\\s+/ and err 'arrays/declare not portable';\n    + \t/^\\s*[^#]\\s*which\\s/ and err 'which is not portable (use type)';\n    + \t/\\btest\\s+[^=]*==/ and err '\"test a == b\" is not portable (use =)';\n    ++\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n    ++\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n    + \t/\\bwc -l.*\"\\s*=/ and err '`\"$(wc -l)\"` is not portable (use test_line_count)';\n    + \t/\\bhead\\s+-c\\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';\n    + \t/(?:\\$\\(seq|^\\s*seq\\b)/ and err 'seq is not portable (use test_seq)';\n 2:  44223ae777e !  2:  39759d00adf test-lib: bring $remove_trash out of retirement\n    @@ Commit message\n         test-lib: bring $remove_trash out of retirement\n     \n         There's no point in creating a repository or directory only to decide\n    -    right afterwards that we're skipping all the tests.\n    +    right afterwards that we're skipping all the tests. We can save\n    +    ourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\n    +    case.\n    +\n    +    We carry around the \"$remove_trash\" variable because if the directory\n    +    is unexpectedly gone at test_done time we'll hit the error about it\n    +    being unexpectedly gone added in df4c0d1a792 (test-lib: abort when\n    +    can't remove trash directory, 2017-04-20).\n     \n         So let's partially revert 06478dab4c (test-lib: retire $remove_trash\n         variable, 2017-04-23) and move the decision about whether to skip all\n 3:  3d04553d710 =  3:  d669ce31961 test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n 4:  4ecce153b99 =  4:  9313d35bf86 test-lib-functions: reword \"test_commit --append\" docs\n 5:  6df03776940 !  5:  c916d648e49 test-lib-functions: document test_commit --no-tag\n    @@ t/test-lib-functions.sh: debug () {\n      #   --author <author>\n      #\tInvoke \"git commit\" with --author <author>\n     +#   --no-tag\n    -+#\tDo not tag the resulting commit, if supplied giving the\n    -+#\toptional \"<tag>\" argument is an error.\n    ++#\tDo not tag the resulting commit\n      #\n      # This will commit a file with the given contents and the given commit\n      # message, and tag the resulting commit with the given tag name.\n 6:  8d43fdd5865 !  6:  9b6bf65ce1c test-lib functions: add an --annotated-tag option to \"test_commit\"\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    test-lib functions: add an --annotated-tag option to \"test_commit\"\n    +    test-lib functions: add an --annotated option to \"test_commit\"\n     \n    -    Add an --annotated-tag option to test_commit. The tag will share the\n    -    same message as the commit, and we'll call test_tick before creating\n    -    it (unless --notick) is provided.\n    +    Add an --annotated option to test_commit to create annotated tags. The\n    +    tag will share the same message as the commit, and we'll call\n    +    test_tick before creating it (unless --notick) is provided.\n     \n         There's quite a few tests that could be simplified with this\n         construct. I've picked one to convert in this change as a\n    @@ t/t1403-show-ref.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n     \n      ## t/test-lib-functions.sh ##\n     @@ t/test-lib-functions.sh: debug () {\n    + #\tInvoke \"git commit\" with --author <author>\n      #   --no-tag\n    - #\tDo not tag the resulting commit, if supplied giving the\n    - #\toptional \"<tag>\" argument is an error.\n    + #\tDo not tag the resulting commit\n     +#   --annotate\n     +#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n    -+#\ttest_tick between making the commit and tag unless --notick is\n    -+#\tgiven.\n    ++#\ttest_tick between making the commit and tag, unless --notick\n    ++#\tis given.\n      #\n      # This will commit a file with the given contents and the given commit\n      # message, and tag the resulting commit with the given tag name.\n    @@ t/test-lib-functions.sh: test_commit () {\n     -\tfi\n     +\t\t;;\n     +\tannotate)\n    -+\t\tif test \"$tag$notick\" = \"annotate\"\n    ++\t\tif test -z \"$notick\"\n     +\t\tthen\n     +\t\t\ttest_tick\n     +\t\tfi &&\n 7:  ec4809e7466 =  7:  683b3ba3dd9 describe tests: convert setup to use test_commit\n 8:  352eeff41c9 =  8:  dc0a863db72 test-lib functions: add --printf option to test_commit\n 9:  e7432294215 =  9:  90bf55d2d42 submodule tests: use symbolic-ref --short to discover branch name\n10:  634038c3a8d = 10:  e0a1e2fd529 test-lib: reformat argument list in test_create_repo()\n11:  cdbff4df362 = 11:  cedf5d383b0 test-lib: do not show advice about init.defaultBranch under --verbose\n12:  424caad189f ! 12:  a3e20ef18f7 test-lib: modernize test_create_repo() function\n    @@ Metadata\n     Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## Commit message ##\n    -    test-lib: modernize test_create_repo() function\n    +    test-lib: split up and deprecate test_create_repo()\n     \n    -    Remove redundant \"mkdir -p\", argument number checking', test\n    -    environment sanity checking, and disabling of hooks from\n    -    test_create_repo(). As we'll see below these were all either redundant\n    -    to other test other framework code, or to changes in git itself.\n    +    Remove various redundant or obsolete code from the test_create_repo()\n    +    function, and split up its use in test-lib.sh from what tests need\n    +    from it, leaving us with a pass-through wrapper for \"git init\" in\n    +    test-lib-functions.sh\n     \n    -    Respectively:\n    +    Reasons for why we can remove various code from test_create_repo():\n     \n          1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n             leading directories if needed.\n     \n    -     2. We don't need to check the number of arguments anymore, instead\n    -        we'll feed \"git init\" with \"$@\". It will die if given too many\n    -        arguments.\n    +     2. Since we're now a simple wrapper for \"git init\" we don't need to\n    +        check that we have only one argument. If someone wants to run\n    +        \"test_create_repo --bare x\" that's OK.\n     \n          3. We won't ever hit that \"Cannot setup test environment\"\n             error.\n    @@ Commit message\n          5. Since we don't need to move the .git/hooks directory we don't need\n             the subshell here either.\n     \n    +        That wasn't really needed for the .git/hooks either, but was being\n    +        done for the convenience of not having to quote the path to the\n    +        repository as we moved the hooks.\n    +\n    +     6. We can drop the --template argument and instead rely on the\n    +        GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    +        8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n    +\n    +     7. We only needed that \">&3 2>&4\" redirection when invoked from\n    +        test-lib.sh, and the same goes for needing the full path to \"git\".\n    +\n    +        Let's move that special behavior into test-lib.sh itself.\n    +\n         In the end it turns out that all we needed was a plain \"git init\"\n    -    invocation with a custom --template directory.\n    +    invocation.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    @@ t/t5409-colorize-remote-messages.sh: test_description='remote messages are color\n     \n      ## t/test-lib-functions.sh ##\n     @@ t/test-lib-functions.sh: test_atexit () {\n    - # Most tests can use the created repository, but some may need to create more.\n    + \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n    + }\n    + \n    +-# Most tests can use the created repository, but some may need to create more.\n    ++# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n      # Usage: test_create_repo <directory>\n      test_create_repo () {\n     -\ttest \"$#\" = 1 ||\n    @@ t/test-lib-functions.sh: test_atexit () {\n     -\t\terror \"cannot run git init -- have you built things yet?\"\n     -\t\tmv .git/hooks .git/hooks-disabled\n     -\t) || exit\n    -+\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n    -+\t\tinit \\\n    -+\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" \"$@\" >&3 2>&4\n    ++\tgit init \"$@\"\n      }\n      \n      # This function helps on symlink challenged file systems when it is not\n    +\n    + ## t/test-lib.sh ##\n    +@@ t/test-lib.sh: rm -fr \"$TRASH_DIRECTORY\" || {\n    + remove_trash=t\n    + if test -z \"$TEST_NO_CREATE_REPO\"\n    + then\n    +-\ttest_create_repo \"$TRASH_DIRECTORY\"\n    ++\t\"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" \\\n    ++\t\tinit \\\n    ++\t\t\"$TRASH_DIRECTORY\" >&3 2>&4 ||\n    ++\terror \"cannot run git init\"\n    + else\n    + \tmkdir -p \"$TRASH_DIRECTORY\"\n    + fi\n13:  0813aa8e34e <  -:  ----------- test-lib-functions: normalize test_path_is_missing() debugging\n14:  b6e9d971b40 <  -:  ----------- test-lib-functions: use \"return 1\" instead of \"false\"\n15:  0cd511206c4 <  -:  ----------- Revert and amend \"test-lib-functions: assert correct parameter count\"\n16:  b4a018a63f3 <  -:  ----------- test-lib-functions: remove last two parameter count assertions\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422165","messageId":"patch-03.12-d669ce31961-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 03/12] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:36Z","receivedAt":"2021-04-17T12:53:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27a..2c6e34b9478 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422170","messageId":"patch-01.12-a8b483bc771-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:34Z","receivedAt":"2021-04-17T12:53:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a check for -a/-o in \"test\", as a follow-up to the\nCodingGuidelines having recommended against their use since\n897f964c0dc (CodingGuidelines: avoid \"test <cond> -a/-o <cond>\",\n2014-05-20).\n\nThese constructs are considered obsolescent by POSIX[1]. GNU has\nlikewise warned against them[2] for a few decades.\n\nThese will only match the simplistic forms of `test -X blah` (where\n\"-X\" is some single letter option), but will miss expressions such as\n`test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\nthings like:\n\n    test whatever && ls -a foo\n    test whatever && foo -o outfile\n\n1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16\n2. https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/check-non-portable-shell.pl | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\nindex fd3303552be..894aa0a4f92 100755\n--- a/t/check-non-portable-shell.pl\n+++ b/t/check-non-portable-shell.pl\n@@ -41,6 +41,8 @@ sub err {\n \t/^\\s*declare\\s+/ and err 'arrays/declare not portable';\n \t/^\\s*[^#]\\s*which\\s/ and err 'which is not portable (use type)';\n \t/\\btest\\s+[^=]*==/ and err '\"test a == b\" is not portable (use =)';\n+\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n+\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n \t/\\bwc -l.*\"\\s*=/ and err '`\"$(wc -l)\"` is not portable (use test_line_count)';\n \t/\\bhead\\s+-c\\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';\n \t/(?:\\$\\(seq|^\\s*seq\\b)/ and err 'seq is not portable (use test_seq)';\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422166","messageId":"patch-04.12-9313d35bf86-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 04/12] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:37Z","receivedAt":"2021-04-17T12:53:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6348e8d7339..d169fb2f597 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422167","messageId":"patch-05.12-c916d648e49-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 05/12] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:38Z","receivedAt":"2021-04-17T12:53:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d169fb2f597..d0f4f3885d6 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,8 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422168","messageId":"patch-07.12-683b3ba3dd9-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 07/12] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:40Z","receivedAt":"2021-04-17T12:53:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotated-tag option to\ntest_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747bee..88fddc91424 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422169","messageId":"patch-06.12-9b6bf65ce1c-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 06/12] test-lib functions: add an --annotated option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:39Z","receivedAt":"2021-04-17T12:53:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated option to test_commit to create annotated tags. The\ntag will share the same message as the commit, and we'll call\ntest_tick before creating it (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c3..17d3cc14050 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d0f4f3885d6..6e2332a324a 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -179,6 +179,10 @@ debug () {\n #\tInvoke \"git commit\" with --author <author>\n #   --no-tag\n #\tDo not tag the resulting commit\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag, unless --notick\n+#\tis given.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -191,7 +195,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -219,7 +223,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -243,10 +250,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test -z \"$notick\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422171","messageId":"patch-08.12-dc0a863db72-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 08/12] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:41Z","receivedAt":"2021-04-17T12:53:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 12 ++++++++++--\n 6 files changed, 18 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388e..930dce06f0f 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a2..f691e6d9032 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15b..6cdee2a2164 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60d..a39a626664d 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f9..e2c0c510222 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6e2332a324a..dbeb3d92628 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,10 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -191,6 +195,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -202,6 +207,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -238,9 +246,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422172","messageId":"patch-09.12-90bf55d2d42-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 09/12] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:42Z","receivedAt":"2021-04-17T12:53:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e93083..f7c7df0ca42 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422173","messageId":"patch-10.12-e0a1e2fd529-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 10/12] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:43Z","receivedAt":"2021-04-17T12:53:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex dbeb3d92628..21271020c79 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1257,8 +1257,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422174","messageId":"patch-11.12-cedf5d383b0-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 11/12] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:44Z","receivedAt":"2021-04-17T12:53:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 21271020c79..8e75a013a43 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1258,7 +1258,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7522faf39fc..9ebb595c335 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422175","messageId":"patch-12.12-a3e20ef18f7-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 12/12] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:45Z","receivedAt":"2021-04-17T12:53:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove various redundant or obsolete code from the test_create_repo()\nfunction, and split up its use in test-lib.sh from what tests need\nfrom it, leaving us with a pass-through wrapper for \"git init\" in\ntest-lib-functions.sh\n\nReasons for why we can remove various code from test_create_repo():\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. Since we're now a simple wrapper for \"git init\" we don't need to\n    check that we have only one argument. If someone wants to run\n    \"test_create_repo --bare x\" that's OK.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n 5. Since we don't need to move the .git/hooks directory we don't need\n    the subshell here either.\n\n    That wasn't really needed for the .git/hooks either, but was being\n    done for the convenience of not having to quote the path to the\n    repository as we moved the hooks.\n\n 6. We can drop the --template argument and instead rely on the\n    GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n\n 7. We only needed that \">&3 2>&4\" redirection when invoked from\n    test-lib.sh, and the same goes for needing the full path to \"git\".\n\n    Let's move that special behavior into test-lib.sh itself.\n\nIn the end it turns out that all we needed was a plain \"git init\"\ninvocation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 ++-------------\n t/test-lib.sh                       |  5 ++++-\n 5 files changed, 6 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649e..5c509db6fc3 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4e..6da8d760e28 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8ec..9f1a483f426 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 8e75a013a43..bd64a15c731 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1248,21 +1248,10 @@ test_atexit () {\n \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n }\n \n-# Most tests can use the created repository, but some may need to create more.\n+# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\tgit init \"$@\"\n }\n \n # This function helps on symlink challenged file systems when it is not\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 9ebb595c335..f73c3c6fc72 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1364,7 +1364,10 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n-\ttest_create_repo \"$TRASH_DIRECTORY\"\n+\t\"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" \\\n+\t\tinit \\\n+\t\t\"$TRASH_DIRECTORY\" >&3 2>&4 ||\n+\terror \"cannot run git init\"\n else\n \tmkdir -p \"$TRASH_DIRECTORY\"\n fi\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422176","messageId":"patch-02.12-39759d00adf-20210417T124424Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v2 02/12] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:52:35Z","receivedAt":"2021-04-17T12:54:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests. We can save\nourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\ncase.\n\nWe carry around the \"$remove_trash\" variable because if the directory\nis unexpectedly gone at test_done time we'll hit the error about it\nbeing unexpectedly gone added in df4c0d1a792 (test-lib: abort when\ncan't remove trash directory, 2017-04-20).\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 31 +++++++++++++++++--------------\n 1 file changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3dec266221c..7522faf39fc 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1169,7 +1169,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1334,6 +1334,21 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1341,10 +1356,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1356,15 +1368,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422177","messageId":"cover-0.3-00000000000-20210417T125539Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH 0/3] test-lib-functions.sh: trickery to make -x less verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:58:24Z","receivedAt":"2021-04-17T12:58:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series makes the \"-x\" output less verbose for our various helper\nfunctions, mainly using the trickery of feeding \"$@\" to \"test\" to rely\non it to die when given too many arguments.\n\nIt was split off from v2 of my larger test-lib.sh series as noted in\nits CL:\nhttps://lore.kernel.org/git/cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com/\n\nThe range-diff below is to v1 of the relevant part of that series,\nshowing what's changed just for these commits.\n\nÆvar Arnfjörð Bjarmason (3):\n  test-lib-functions: normalize test_path_is_missing() debugging\n  Revert and amend \"test-lib-functions: assert correct parameter count\"\n  test-lib-functions: remove last two parameter count assertions\n\n t/test-lib-functions.sh | 64 +++++++++++++++--------------------------\n 1 file changed, 23 insertions(+), 41 deletions(-)\n\nRange-diff:\n1:  0813aa8e34e = 1:  c22e3f7764f test-lib-functions: normalize test_path_is_missing() debugging\n2:  b6e9d971b40 < -:  ----------- test-lib-functions: use \"return 1\" instead of \"false\"\n3:  0cd511206c4 ! 2:  6f9e09a2017 Revert and amend \"test-lib-functions: assert correct parameter count\"\n    @@ Commit message\n         assert correct parameter count, 2021-02-12) in order to improve the -x\n         output.\n     \n    -    When I added these BUG assertions in e7884b353b7 I missed that this\n    -    made the -x output much more verbose.\n    +    The goal here is to get rid of the verbosity of having e.g. a \"test 2\n    +    -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n    +    to intentionally feed the \"test\" operator too many arguments if the\n    +    functions are called with too many arguments, thus piggy-backing on it\n    +    to check the number of arguments we get.\n     \n    -    E.g. for each test_cmp invocation we'd now emit:\n    +    Before this for each test_cmp invocation we'd emit:\n     \n             + test_cmp expect actual\n             + test 2 -ne 2\n             + eval diff -u \"$@\"\n             + diff -u expect actual\n     \n    -    That \"test 2 -ne 2\" line is new in e7884b353b7. As noted in\n    +    That \"test 2 -ne 2\" line is new in my e7884b353b7. As noted in\n         45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\n         helper param, 2021-02-12) we had buggy invocations of some of these\n         functions with too many parameters.\n     \n    -    Let's instead use \"$@\" instead of \"$1\" to achieve the same ends with\n    -    no extra -x output verbosity. The \"test\" operator will die with an\n    -    error if given more than one argument in these contexts, so using \"$@\"\n    -    achieves the same goal.\n    +    Now we'll get just:\n     \n    -    The same goes for \"cmp\" and \"diff -u\" (which we typically use for\n    -    test_cmp).\n    +        + test_cmp expect actual\n    +        + eval diff -u \"$@\"\n    +        + diff -u expect actual\n    +\n    +    This does not to the \"right\" thing in cases like:\n    +\n    +        test_path_is_file x -a y\n    +\n    +    Which will now turn into:\n    +\n    +        test -f x -a y\n    +\n    +    I consider that to be OK given the trade-off that any extra checking\n    +    would produce more verbose trace output. As shown in 45a2686441b we\n    +    had issues with these functions being invoked with multiple\n    +    parameters (e.g. a glob) by accident, we don't need to be paranoid in\n    +    guarding against hostile misuse from our own test suite.\n    +\n    +    While I'm at it change a few functions that relied on a \"false\" being\n    +    the last statement in the function to use an explicit \"return 1\" like\n    +    the other functions in this file.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    @@ t/test-lib-functions.sh: test_external_without_stderr () {\n     +\tif ! test -f \"$@\"\n      \tthen\n     -\t\techo \"File $1 doesn't exist\"\n    -+\t\techo \"File $@ doesn't exist\"\n    - \t\treturn 1\n    +-\t\tfalse\n    ++\t\techo \"File $* doesn't exist\"\n    ++\t\treturn 1\n      \tfi\n      }\n      \n    @@ t/test-lib-functions.sh: test_external_without_stderr () {\n     +\tif ! test -d \"$@\"\n      \tthen\n     -\t\techo \"Directory $1 doesn't exist\"\n    -+\t\techo \"Directory $@ doesn't exist\"\n    - \t\treturn 1\n    +-\t\tfalse\n    ++\t\techo \"Directory $* doesn't exist\"\n    ++\t\treturn 1\n      \tfi\n      }\n      \n    @@ t/test-lib-functions.sh: test_external_without_stderr () {\n     +\tif ! test -e \"$@\"\n      \tthen\n     -\t\techo \"Path $1 doesn't exist\"\n    -+\t\techo \"Path $@ doesn't exist\"\n    - \t\treturn 1\n    +-\t\tfalse\n    ++\t\techo \"Path $* doesn't exist\"\n    ++\t\treturn 1\n      \tfi\n      }\n      \n    @@ t/test-lib-functions.sh: test_external_without_stderr () {\n     +\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n      \tthen\n     -\t\techo \"Directory '$1' is not empty, it contains:\"\n    -+\t\techo \"Directory '$@' is not empty, it contains:\"\n    ++\t\techo \"Directory '$*' is not empty, it contains:\"\n      \t\tls -la \"$1\"\n      \t\treturn 1\n      \tfi\n    @@ t/test-lib-functions.sh: test_dir_is_empty () {\n     +\tif ! test -s \"$@\"\n      \tthen\n     -\t\techo \"'$1' is not a non-empty file.\"\n    -+\t\techo \"'$@' is not a non-empty file.\"\n    - \t\treturn 1\n    +-\t\tfalse\n    ++\t\techo \"'$*' is not a non-empty file.\"\n    ++\t\treturn 1\n      \tfi\n      }\n      \n    @@ t/test-lib-functions.sh: test_dir_is_empty () {\n     -\tif test -e \"$1\"\n     +\tif test -e \"$@\"\n      \tthen\n    - \t\techo \"Path $1 exists!\"\n    +-\t\techo \"Path $1 exists!\"\n    ++\t\techo \"Path $* exists!\"\n      \t\tfalse\n    + \tfi\n    + }\n     @@ t/test-lib-functions.sh: test_expect_code () {\n      # - not all diff versions understand \"-u\"\n      \n    @@ t/test-lib-functions.sh: verbose () {\n      \tthen\n     -\t\techo \"'$1' is not empty, it contains:\"\n     -\t\tcat \"$1\"\n    -+\t\techo \"'$@' is not empty, it contains:\"\n    ++\t\techo \"'$*' is not empty, it contains:\"\n     +\t\tcat \"$@\"\n      \t\treturn 1\n      \tfi\n4:  b4a018a63f3 ! 3:  b7b11a60bcd test-lib-functions: remove last two parameter count assertions\n    @@ Metadata\n      ## Commit message ##\n         test-lib-functions: remove last two parameter count assertions\n     \n    -    Remove a couple of parameter count assertions where we'll now silently\n    -    do the wrong thing if given too many parameters, unlike the \"$@\" cases\n    -    in the preceding commit where \"test\" etc. handle the check for usi.\n    +    Remove a couple of parameter count assertions where, unlike the\n    +    preceding commit's migration to 'test -$x \"$@\"', we'll now silently do\n    +    the \"wrong\" thing if given too many parameters. The benefit is less\n    +    verbose trace output, as noted in the preceding commit.\n     \n         In the case of \"test_file_size\", the \"test-tool\" we're invoking is\n         happy to accept N parameters (it'll print out all N sizes). Let's just\n    -    use \"$@\" in that case anyway, there's only a few callers, and\n    +    use \"$@\" in that case anyway. There's only a few callers, and\n         eventually those should probably be moved to use the test-tool\n         directly.\n     \n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422178","messageId":"patch-1.3-c22e3f7764f-20210417T125540Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-00000000000-20210417T125539Z-avarab@gmail.com","subject":"[PATCH 1/3] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:58:25Z","receivedAt":"2021-04-17T12:58:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test_path_is_missing() to be consistent with related\nfunctions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to\ntest [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\necho-ing $* if it exists. Let's just say that it exists instead.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex bd64a15c731..0232cc9f46d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -810,12 +810,7 @@ test_path_is_missing () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \tif test -e \"$1\"\n \tthen\n-\t\techo \"Path exists:\"\n-\t\tls -ld \"$1\"\n-\t\tif test $# -ge 1\n-\t\tthen\n-\t\t\techo \"$*\"\n-\t\tfi\n+\t\techo \"Path $1 exists!\"\n \t\tfalse\n \tfi\n }\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422179","messageId":"patch-2.3-6f9e09a2017-20210417T125540Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-00000000000-20210417T125539Z-avarab@gmail.com","subject":"[PATCH 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:58:26Z","receivedAt":"2021-04-17T12:58:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This reverts and amends my my own e7884b353b7 (test-lib-functions:\nassert correct parameter count, 2021-02-12) in order to improve the -x\noutput.\n\nThe goal here is to get rid of the verbosity of having e.g. a \"test 2\n-ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\nto intentionally feed the \"test\" operator too many arguments if the\nfunctions are called with too many arguments, thus piggy-backing on it\nto check the number of arguments we get.\n\nBefore this for each test_cmp invocation we'd emit:\n\n    + test_cmp expect actual\n    + test 2 -ne 2\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThat \"test 2 -ne 2\" line is new in my e7884b353b7. As noted in\n45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\nhelper param, 2021-02-12) we had buggy invocations of some of these\nfunctions with too many parameters.\n\nNow we'll get just:\n\n    + test_cmp expect actual\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThis does not to the \"right\" thing in cases like:\n\n    test_path_is_file x -a y\n\nWhich will now turn into:\n\n    test -f x -a y\n\nI consider that to be OK given the trade-off that any extra checking\nwould produce more verbose trace output. As shown in 45a2686441b we\nhad issues with these functions being invoked with multiple\nparameters (e.g. a glob) by accident, we don't need to be paranoid in\nguarding against hostile misuse from our own test suite.\n\nWhile I'm at it change a few functions that relied on a \"false\" being\nthe last statement in the function to use an explicit \"return 1\" like\nthe other functions in this file.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 51 +++++++++++++++++------------------------\n 1 file changed, 21 insertions(+), 30 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 0232cc9f46d..9f6d46b8b1b 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -758,39 +758,35 @@ test_external_without_stderr () {\n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n # The commands test the existence or non-existence of $1\n test_path_is_file () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -f \"$1\"\n+\tif ! test -f \"$@\"\n \tthen\n-\t\techo \"File $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"File $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_dir () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -d \"$1\"\n+\tif ! test -d \"$@\"\n \tthen\n-\t\techo \"Directory $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Directory $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_exists () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -e \"$1\"\n+\tif ! test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Path $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n # Check if the directory exists and is empty as expected, barf otherwise.\n test_dir_is_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\ttest_path_is_dir \"$@\" &&\n+\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n \tthen\n-\t\techo \"Directory '$1' is not empty, it contains:\"\n+\t\techo \"Directory '$*' is not empty, it contains:\"\n \t\tls -la \"$1\"\n \t\treturn 1\n \tfi\n@@ -798,19 +794,17 @@ test_dir_is_empty () {\n \n # Check if the file exists and has a size greater than zero\n test_file_not_empty () {\n-\ttest \"$#\" = 2 && BUG \"2 param\"\n-\tif ! test -s \"$1\"\n+\tif ! test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not a non-empty file.\"\n-\t\tfalse\n+\t\techo \"'$*' is not a non-empty file.\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_missing () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif test -e \"$1\"\n+\tif test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 exists!\"\n+\t\techo \"Path $* exists!\"\n \t\tfalse\n \tfi\n }\n@@ -1012,7 +1006,6 @@ test_expect_code () {\n # - not all diff versions understand \"-u\"\n \n test_cmp () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \teval \"$GIT_TEST_CMP\" '\"$@\"'\n }\n \n@@ -1042,7 +1035,6 @@ test_cmp_config () {\n # test_cmp_bin - helper to compare binary files\n \n test_cmp_bin () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \tcmp \"$@\"\n }\n \n@@ -1103,12 +1095,11 @@ verbose () {\n # otherwise.\n \n test_must_be_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_file \"$1\" &&\n-\tif test -s \"$1\"\n+\ttest_path_is_file \"$@\" &&\n+\tif test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not empty, it contains:\"\n-\t\tcat \"$1\"\n+\t\techo \"'$*' is not empty, it contains:\"\n+\t\tcat \"$@\"\n \t\treturn 1\n \tfi\n }\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422180","messageId":"patch-3.3-b7b11a60bcd-20210417T125540Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-00000000000-20210417T125539Z-avarab@gmail.com","subject":"[PATCH 3/3] test-lib-functions: remove last two parameter count assertions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T12:58:27Z","receivedAt":"2021-04-17T12:58:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove a couple of parameter count assertions where, unlike the\npreceding commit's migration to 'test -$x \"$@\"', we'll now silently do\nthe \"wrong\" thing if given too many parameters. The benefit is less\nverbose trace output, as noted in the preceding commit.\n\nIn the case of \"test_file_size\", the \"test-tool\" we're invoking is\nhappy to accept N parameters (it'll print out all N sizes). Let's just\nuse \"$@\" in that case anyway. There's only a few callers, and\neventually those should probably be moved to use the test-tool\ndirectly.\n\nThat only leaves test_line_count, I suppose I could leave that one\nalone, but since it's the only common function left that does this\nassertion let's remove it for the brevity of the -x output and\nconsistency with other functions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 9f6d46b8b1b..a2081ebcdea 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -821,10 +821,7 @@ test_path_is_missing () {\n # output through when the number of lines is wrong.\n \n test_line_count () {\n-\tif test $# != 3\n-\tthen\n-\t\tBUG \"not 3 parameters to test_line_count\"\n-\telif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n+\tif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n \tthen\n \t\techo \"test_line_count: line count for $3 !$1 $2\"\n \t\tcat \"$3\"\n@@ -833,8 +830,7 @@ test_line_count () {\n }\n \n test_file_size () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest-tool path-utils file-size \"$1\"\n+\ttest-tool path-utils file-size \"$@\"\n }\n \n # Returns success if a comma separated string of keywords ($1) contains a\n-- \n2.31.1.722.g788886f50a2\n\n"},{"id":"422185","messageId":"20210417154218.GS2947267@szeder.dev","threadId":"55480","inReplyTo":"patch-12.12-a3e20ef18f7-20210417T124424Z-avarab@gmail.com","subject":"Re: [PATCH v2 12/12] test-lib: split up and deprecate test_create_repo()","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-17T15:42:18Z","receivedAt":"2021-04-17T15:42:27Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sat, Apr 17, 2021 at 02:52:45PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> Remove various redundant or obsolete code from the test_create_repo()\n> function, and split up its use in test-lib.sh from what tests need\n> from it, leaving us with a pass-through wrapper for \"git init\" in\n> test-lib-functions.sh\n> \n> Reasons for why we can remove various code from test_create_repo():\n> \n>  1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n>     leading directories if needed.\n> \n>  2. Since we're now a simple wrapper for \"git init\" we don't need to\n>     check that we have only one argument. If someone wants to run\n>     \"test_create_repo --bare x\" that's OK.\n> \n>  3. We won't ever hit that \"Cannot setup test environment\"\n>     error.\n> \n>     Checking the test environment sanity when doing \"git init\" dates\n>     back to eea420693be (t0000: catch trivial pilot errors.,\n>     2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n>     was successfully created, 2006-01-05).\n> \n>     We can also see it in another form a bit later in my own\n>     0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n>     $old, 2010-08-30).\n> \n>     But since 2006f0adaee (t/test-lib: make sure Git has already been\n>     built, 2012-09-17) we already check if we have a built git\n>     earlier.\n> \n>     The one thing this was testing after that 2012 change was that\n>     we'd just built \"git\", but not \"git-init\", but since\n>     3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n>     repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n> \n>     So all of that's been checked already, and we don't need to\n>     re-check it here.\n> \n>  4. We don't need to move .git/hooks out of the way.\n> \n>     That dates back to c09a69a83e3 (Disable hooks during tests.,\n>     2005-10-16), since then hooks became disabled by default in\n>     f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n> \n>     So the hooks were already disabled by default, but as can be seen\n>     from \"mkdir .git/hooks\" changes various tests needed to re-setup\n>     that directory. Now they no longer do.\n> \n>  5. Since we don't need to move the .git/hooks directory\n\nSince we don't change directory anymore...\n\n> we don't need\n>     the subshell here either.\n> \n>     That wasn't really needed for the .git/hooks either, but was being\n>     done for the convenience of not having to quote the path to the\n>     repository as we moved the hooks.\n\nAnd then this dubious explanation will not be necessary.\n\n>  6. We can drop the --template argument and instead rely on the\n>     GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n>     8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n> \n>  7. We only needed that \">&3 2>&4\" redirection when invoked from\n>     test-lib.sh, and the same goes for needing the full path to \"git\".\n> \n>     Let's move that special behavior into test-lib.sh itself.\n\nQuoting myself from my review of the previous version of this patch:\n\n  PATH is already set up to start with GIT_TEST_INSTALLED and/or\n  GIT_EXEC_PATH before 'test_create_repo' is called to init the repo in\n  the trash directory, so we could simply run 'git' and rely on PATH\n  lookup choosing the right executable.\n\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 9ebb595c335..f73c3c6fc72 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -1364,7 +1364,10 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n>  remove_trash=t\n>  if test -z \"$TEST_NO_CREATE_REPO\"\n>  then\n> -\ttest_create_repo \"$TRASH_DIRECTORY\"\n> +\t\"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" \\\n> +\t\tinit \\\n> +\t\t\"$TRASH_DIRECTORY\" >&3 2>&4 ||\n\nSo this could be just:\n\n  git init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n\n> +\terror \"cannot run git init\"\n>  else\n>  \tmkdir -p \"$TRASH_DIRECTORY\"\n>  fi\n> -- \n> 2.31.1.722.g788886f50a2\n> \n"},{"id":"422192","messageId":"87h7k41t6i.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"20210417154218.GS2947267@szeder.dev","subject":"Re: [PATCH v2 12/12] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-17T21:45:41Z","receivedAt":"2021-04-17T21:45:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Apr 17 2021, SZEDER Gábor wrote:\n\n> On Sat, Apr 17, 2021 at 02:52:45PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>> Remove various redundant or obsolete code from the test_create_repo()\n>> function, and split up its use in test-lib.sh from what tests need\n>> from it, leaving us with a pass-through wrapper for \"git init\" in\n>> test-lib-functions.sh\n>> \n>> Reasons for why we can remove various code from test_create_repo():\n>> \n>>  1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n>>     leading directories if needed.\n>> \n>>  2. Since we're now a simple wrapper for \"git init\" we don't need to\n>>     check that we have only one argument. If someone wants to run\n>>     \"test_create_repo --bare x\" that's OK.\n>> \n>>  3. We won't ever hit that \"Cannot setup test environment\"\n>>     error.\n>> \n>>     Checking the test environment sanity when doing \"git init\" dates\n>>     back to eea420693be (t0000: catch trivial pilot errors.,\n>>     2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n>>     was successfully created, 2006-01-05).\n>> \n>>     We can also see it in another form a bit later in my own\n>>     0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n>>     $old, 2010-08-30).\n>> \n>>     But since 2006f0adaee (t/test-lib: make sure Git has already been\n>>     built, 2012-09-17) we already check if we have a built git\n>>     earlier.\n>> \n>>     The one thing this was testing after that 2012 change was that\n>>     we'd just built \"git\", but not \"git-init\", but since\n>>     3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n>>     repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n>> \n>>     So all of that's been checked already, and we don't need to\n>>     re-check it here.\n>> \n>>  4. We don't need to move .git/hooks out of the way.\n>> \n>>     That dates back to c09a69a83e3 (Disable hooks during tests.,\n>>     2005-10-16), since then hooks became disabled by default in\n>>     f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n>> \n>>     So the hooks were already disabled by default, but as can be seen\n>>     from \"mkdir .git/hooks\" changes various tests needed to re-setup\n>>     that directory. Now they no longer do.\n>> \n>>  5. Since we don't need to move the .git/hooks directory\n>\n> Since we don't change directory anymore...\n>\n>> we don't need\n>>     the subshell here either.\n>> \n>>     That wasn't really needed for the .git/hooks either, but was being\n>>     done for the convenience of not having to quote the path to the\n>>     repository as we moved the hooks.\n>\n> And then this dubious explanation will not be necessary.\n\nWhy dubious? That's why we had the subshell-ing. See 0d314ce834\n(test-lib: use subshell instead of cd $new && .. && cd $old,\n2010-08-30).\n\nI don't mind rewording or not including some of this verbosity per-se,\nbut I wonder why you're honing in on the subshell part in\nparticular. Maybe there's something I'm missing...\n\nThe goal of the commit messsage is to point-by-point tear apart facets\nof the previous behavior, and assure the reader that e.g. the\nsubshelling isn't needed for some other subtle reason.\n\n>>  6. We can drop the --template argument and instead rely on the\n>>     GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n>>     8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n>> \n>>  7. We only needed that \">&3 2>&4\" redirection when invoked from\n>>     test-lib.sh, and the same goes for needing the full path to \"git\".\n>> \n>>     Let's move that special behavior into test-lib.sh itself.\n>\n> Quoting myself from my review of the previous version of this patch:\n>\n>   PATH is already set up to start with GIT_TEST_INSTALLED and/or\n>   GIT_EXEC_PATH before 'test_create_repo' is called to init the repo in\n>   the trash directory, so we could simply run 'git' and rely on PATH\n>   lookup choosing the right executable.\n>\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 9ebb595c335..f73c3c6fc72 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -1364,7 +1364,10 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n>>  remove_trash=t\n>>  if test -z \"$TEST_NO_CREATE_REPO\"\n>>  then\n>> -\ttest_create_repo \"$TRASH_DIRECTORY\"\n>> +\t\"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" \\\n>> +\t\tinit \\\n>> +\t\t\"$TRASH_DIRECTORY\" >&3 2>&4 ||\n>\n> So this could be just:\n>\n>   git init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n\nAh yes, I see that now. FWIW I managed to misread that in the last round\nas it applying only once we were calling the test-lib-functions.sh\nhelper, but I see it's finishe setting up a few lines before the\ntest_create_repo in test-lib.sh too, nice.\n"},{"id":"422197","messageId":"CAPig+cSR_y4uqPnYt+P4EFxPrhN8LHDjLX=_5uJFWYbL1skixA@mail.gmail.com","threadId":"55480","inReplyTo":"patch-2.3-6f9e09a2017-20210417T125540Z-avarab@gmail.com","subject":"Re: [PATCH 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-18T05:11:35Z","receivedAt":"2021-04-18T05:11:53Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Apr 17, 2021 at 8:58 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> [...]\n> The goal here is to get rid of the verbosity of having e.g. a \"test 2\n> -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n> to intentionally feed the \"test\" operator too many arguments if the\n> functions are called with too many arguments, thus piggy-backing on it\n> to check the number of arguments we get.\n\nMy one concern about this change is that it enters the realm of\n\"huh?\". Although it's dead-simple to understand what this code is\ndoing:\n\n    test \"$#\" -ne 1 && BUG \"1 param\"\n    if ! test -f \"$1\"\n\nthe replacement code:\n\n    if ! test -f \"$@\"\n\ncan easily lead to head-scratching, wondering why the author chose to\nuse \"$@\" rather than the more obvious \"$1\". This sort of unusual local\nidiom might normally deserve an in-code comment explaining why the\nmore obvious code is not employed. However, adding a comment at each\nsite would be overkill, so it might be the sort of thing to explain in\ndocumentation somewhere (\"In order to make -x output less noisy,\nemploy \"$@\" rather than explicitly checking function arguments when\nwriting new test functions...\".) Otherwise, the reader is forced to\nconsult the commit message.\n\nNot a major objection; just voicing the bit of unease I feel about it.\n\n> This does not to the \"right\" thing in cases like:\n\nChanneling Dscho's inner Eric Sunshine[1]: s/to/do/\n\n[1]: https://lore.kernel.org/git/nycvar.QRO.7.76.6.2103222235150.50@tvgsbejvaqbjf.bet/\n"},{"id":"422386","messageId":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-00000000000-20210417T124424Z-avarab@gmail.com","subject":"[PATCH v3 00/12] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:51Z","receivedAt":"2021-04-20T12:22:10Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This is a \"various small fixes\" series to test-lib.sh,\ntest-lib-functions.sh.\n\nSince v2 the only changes are to 12/12, per SZEDER's comments we can\ncount on $PATH this late in test-lib.sh, so do that, and clarify the\ncommit message for that change per the discussion on v2.\n\nÆvar Arnfjörð Bjarmason (12):\n  check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: split up and deprecate test_create_repo()\n\n t/check-non-portable-shell.pl       |  2 +\n t/lib-submodule-update.sh           |  3 +-\n t/t0000-basic.sh                    |  4 --\n t/t1307-config-blob.sh              |  4 +-\n t/t1403-show-ref.sh                 |  6 +--\n t/t2030-unresolve-info.sh           |  3 +-\n t/t4006-diff-mode.sh                |  6 +--\n t/t4030-diff-textconv.sh            |  8 +---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 -\n t/t5409-colorize-remote-messages.sh |  1 -\n t/t5520-pull.sh                     | 10 +----\n t/t6120-describe.sh                 | 58 +++++++---------------------\n t/test-lib-functions.sh             | 60 ++++++++++++++++++-----------\n t/test-lib.sh                       | 39 +++++++++++--------\n 15 files changed, 88 insertions(+), 119 deletions(-)\n\nRange-diff against v2:\n -:  ---------- >  1:  a8b483bc77 check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"\n -:  ---------- >  2:  39759d00ad test-lib: bring $remove_trash out of retirement\n -:  ---------- >  3:  d669ce3196 test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n -:  ---------- >  4:  9313d35bf8 test-lib-functions: reword \"test_commit --append\" docs\n -:  ---------- >  5:  c916d648e4 test-lib-functions: document test_commit --no-tag\n -:  ---------- >  6:  9b6bf65ce1 test-lib functions: add an --annotated option to \"test_commit\"\n -:  ---------- >  7:  683b3ba3dd describe tests: convert setup to use test_commit\n -:  ---------- >  8:  dc0a863db7 test-lib functions: add --printf option to test_commit\n -:  ---------- >  9:  90bf55d2d4 submodule tests: use symbolic-ref --short to discover branch name\n -:  ---------- > 10:  e0a1e2fd52 test-lib: reformat argument list in test_create_repo()\n -:  ---------- > 11:  cedf5d383b test-lib: do not show advice about init.defaultBranch under --verbose\n 1:  a3e20ef18f ! 12:  0dc0da9490 test-lib: split up and deprecate test_create_repo()\n    @@ Commit message\n     \n         Remove various redundant or obsolete code from the test_create_repo()\n         function, and split up its use in test-lib.sh from what tests need\n    -    from it, leaving us with a pass-through wrapper for \"git init\" in\n    -    test-lib-functions.sh\n    +    from it.\n     \n    -    Reasons for why we can remove various code from test_create_repo():\n    +    This leave us with a pass-through wrapper for \"git init\" in\n    +    test-lib-functions.sh, in test-lib.sh we have the same, except for\n    +    needing to redirect stdout/stderr, and emitting an error ourselves if\n    +    it fails. We don't need to error() ourselves when test_create_repo()\n    +    is invoked, as the invocation will be a part of a test's \"&&\"-chain.\n    +\n    +    Everything below this paragraph is a detailed summary of the history\n    +    of test_create_repo() explaining why it's safe to remove the various\n    +    things it was doing:\n     \n          1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n             leading directories if needed.\n    @@ Commit message\n          5. Since we don't need to move the .git/hooks directory we don't need\n             the subshell here either.\n     \n    -        That wasn't really needed for the .git/hooks either, but was being\n    -        done for the convenience of not having to quote the path to the\n    -        repository as we moved the hooks.\n    +        See 0d314ce834 for when the subshell use got introduced for the\n    +        convenience of not having to \"cd\" back and forth while setting up\n    +        the hooks.\n     \n          6. We can drop the --template argument and instead rely on the\n             GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n             8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n     \n          7. We only needed that \">&3 2>&4\" redirection when invoked from\n    -        test-lib.sh, and the same goes for needing the full path to \"git\".\n    +        test-lib.sh.\n    +\n    +        We could still invoke test_create_repo() there, but as the\n    +        invocation is now trivial and we don't have a good reason to use\n    +        test_create_repo() elsewhere let's call \"git init\" there\n    +        ourselves.\n     \n    -        Let's move that special behavior into test-lib.sh itself.\n    +     8. We didn't need to resolve \"git\" as\n    +        \"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" in test_create_repo(),\n    +        even for the use of test-lib.sh\n     \n    -    In the end it turns out that all we needed was a plain \"git init\"\n    -    invocation.\n    +        PATH is already set up in test-lib.sh to start with\n    +        GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before\n    +        test_create_repo() (now \"git init\") is called.. So we can simply\n    +        run \"git\" and rely on the PATH lookup choosing the right\n    +        executable.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    @@ t/test-lib.sh: rm -fr \"$TRASH_DIRECTORY\" || {\n      if test -z \"$TEST_NO_CREATE_REPO\"\n      then\n     -\ttest_create_repo \"$TRASH_DIRECTORY\"\n    -+\t\"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" \\\n    -+\t\tinit \\\n    -+\t\t\"$TRASH_DIRECTORY\" >&3 2>&4 ||\n    ++\tgit init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n     +\terror \"cannot run git init\"\n      else\n      \tmkdir -p \"$TRASH_DIRECTORY\"\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422387","messageId":"patch-01.12-a8b483bc77-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:52Z","receivedAt":"2021-04-20T12:22:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a check for -a/-o in \"test\", as a follow-up to the\nCodingGuidelines having recommended against their use since\n897f964c0dc (CodingGuidelines: avoid \"test <cond> -a/-o <cond>\",\n2014-05-20).\n\nThese constructs are considered obsolescent by POSIX[1]. GNU has\nlikewise warned against them[2] for a few decades.\n\nThese will only match the simplistic forms of `test -X blah` (where\n\"-X\" is some single letter option), but will miss expressions such as\n`test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\nthings like:\n\n    test whatever && ls -a foo\n    test whatever && foo -o outfile\n\n1. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16\n2. https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/check-non-portable-shell.pl | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl\nindex fd3303552b..894aa0a4f9 100755\n--- a/t/check-non-portable-shell.pl\n+++ b/t/check-non-portable-shell.pl\n@@ -41,6 +41,8 @@ sub err {\n \t/^\\s*declare\\s+/ and err 'arrays/declare not portable';\n \t/^\\s*[^#]\\s*which\\s/ and err 'which is not portable (use type)';\n \t/\\btest\\s+[^=]*==/ and err '\"test a == b\" is not portable (use =)';\n+\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" preferred to \"test A -a B\"';\n+\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" preferred to \"test A -o B\"';\n \t/\\bwc -l.*\"\\s*=/ and err '`\"$(wc -l)\"` is not portable (use test_line_count)';\n \t/\\bhead\\s+-c\\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';\n \t/(?:\\$\\(seq|^\\s*seq\\b)/ and err 'seq is not portable (use test_seq)';\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422388","messageId":"patch-02.12-39759d00ad-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 02/12] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:53Z","receivedAt":"2021-04-20T12:22:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests. We can save\nourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\ncase.\n\nWe carry around the \"$remove_trash\" variable because if the directory\nis unexpectedly gone at test_done time we'll hit the error about it\nbeing unexpectedly gone added in df4c0d1a792 (test-lib: abort when\ncan't remove trash directory, 2017-04-20).\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 31 +++++++++++++++++--------------\n 1 file changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3dec266221..7522faf39f 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1169,7 +1169,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1334,6 +1334,21 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1341,10 +1356,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1356,15 +1368,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422389","messageId":"patch-03.12-d669ce3196-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 03/12] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:54Z","receivedAt":"2021-04-20T12:22:15Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27..2c6e34b947 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422390","messageId":"patch-05.12-c916d648e4-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 05/12] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:56Z","receivedAt":"2021-04-20T12:22:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d169fb2f59..d0f4f3885d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,8 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422391","messageId":"patch-04.12-9313d35bf8-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 04/12] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:55Z","receivedAt":"2021-04-20T12:22:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6348e8d733..d169fb2f59 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422392","messageId":"patch-06.12-9b6bf65ce1-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 06/12] test-lib functions: add an --annotated option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:57Z","receivedAt":"2021-04-20T12:22:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated option to test_commit to create annotated tags. The\ntag will share the same message as the commit, and we'll call\ntest_tick before creating it (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c..17d3cc1405 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d0f4f3885d..6e2332a324 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -179,6 +179,10 @@ debug () {\n #\tInvoke \"git commit\" with --author <author>\n #   --no-tag\n #\tDo not tag the resulting commit\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag, unless --notick\n+#\tis given.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -191,7 +195,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -219,7 +223,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -243,10 +250,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test -z \"$notick\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422394","messageId":"patch-07.12-683b3ba3dd-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 07/12] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:58Z","receivedAt":"2021-04-20T12:22:21Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotated-tag option to\ntest_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747be..88fddc9142 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422393","messageId":"patch-08.12-dc0a863db7-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 08/12] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:21:59Z","receivedAt":"2021-04-20T12:22:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 12 ++++++++++--\n 6 files changed, 18 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388..930dce06f0 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a..f691e6d903 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15..6cdee2a216 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60..a39a626664 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f..e2c0c51022 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6e2332a324..dbeb3d9262 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,10 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -191,6 +195,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -202,6 +207,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -238,9 +246,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422395","messageId":"patch-09.12-90bf55d2d4-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 09/12] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:22:00Z","receivedAt":"2021-04-20T12:22:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e9308..f7c7df0ca4 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422396","messageId":"patch-10.12-e0a1e2fd52-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 10/12] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:22:01Z","receivedAt":"2021-04-20T12:22:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex dbeb3d9262..21271020c7 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1257,8 +1257,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422397","messageId":"patch-11.12-cedf5d383b-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 11/12] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:22:02Z","receivedAt":"2021-04-20T12:22:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 21271020c7..8e75a013a4 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1258,7 +1258,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7522faf39f..9ebb595c33 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422398","messageId":"patch-12.12-0dc0da9490-20210420T121833Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v3 12/12] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:22:03Z","receivedAt":"2021-04-20T12:22:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove various redundant or obsolete code from the test_create_repo()\nfunction, and split up its use in test-lib.sh from what tests need\nfrom it.\n\nThis leave us with a pass-through wrapper for \"git init\" in\ntest-lib-functions.sh, in test-lib.sh we have the same, except for\nneeding to redirect stdout/stderr, and emitting an error ourselves if\nit fails. We don't need to error() ourselves when test_create_repo()\nis invoked, as the invocation will be a part of a test's \"&&\"-chain.\n\nEverything below this paragraph is a detailed summary of the history\nof test_create_repo() explaining why it's safe to remove the various\nthings it was doing:\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. Since we're now a simple wrapper for \"git init\" we don't need to\n    check that we have only one argument. If someone wants to run\n    \"test_create_repo --bare x\" that's OK.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n 5. Since we don't need to move the .git/hooks directory we don't need\n    the subshell here either.\n\n    See 0d314ce834 for when the subshell use got introduced for the\n    convenience of not having to \"cd\" back and forth while setting up\n    the hooks.\n\n 6. We can drop the --template argument and instead rely on the\n    GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n\n 7. We only needed that \">&3 2>&4\" redirection when invoked from\n    test-lib.sh.\n\n    We could still invoke test_create_repo() there, but as the\n    invocation is now trivial and we don't have a good reason to use\n    test_create_repo() elsewhere let's call \"git init\" there\n    ourselves.\n\n 8. We didn't need to resolve \"git\" as\n    \"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" in test_create_repo(),\n    even for the use of test-lib.sh\n\n    PATH is already set up in test-lib.sh to start with\n    GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before\n    test_create_repo() (now \"git init\") is called.. So we can simply\n    run \"git\" and rely on the PATH lookup choosing the right\n    executable.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 ++-------------\n t/test-lib.sh                       |  3 ++-\n 5 files changed, 4 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649..5c509db6fc 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4..6da8d760e2 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8e..9f1a483f42 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 8e75a013a4..bd64a15c73 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1248,21 +1248,10 @@ test_atexit () {\n \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n }\n \n-# Most tests can use the created repository, but some may need to create more.\n+# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\tgit init \"$@\"\n }\n \n # This function helps on symlink challenged file systems when it is not\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 9ebb595c33..06026bbe75 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1364,7 +1364,8 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n-\ttest_create_repo \"$TRASH_DIRECTORY\"\n+\tgit init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n+\terror \"cannot run git init\"\n else\n \tmkdir -p \"$TRASH_DIRECTORY\"\n fi\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422399","messageId":"87pmyp2led.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"CAPig+cSR_y4uqPnYt+P4EFxPrhN8LHDjLX=_5uJFWYbL1skixA@mail.gmail.com","subject":"Re: [PATCH 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:25:14Z","receivedAt":"2021-04-20T12:25:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Apr 18 2021, Eric Sunshine wrote:\n\n> On Sat, Apr 17, 2021 at 8:58 AM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>> [...]\n>> The goal here is to get rid of the verbosity of having e.g. a \"test 2\n>> -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n>> to intentionally feed the \"test\" operator too many arguments if the\n>> functions are called with too many arguments, thus piggy-backing on it\n>> to check the number of arguments we get.\n>\n> My one concern about this change is that it enters the realm of\n> \"huh?\". Although it's dead-simple to understand what this code is\n> doing:\n>\n>     test \"$#\" -ne 1 && BUG \"1 param\"\n>     if ! test -f \"$1\"\n>\n> the replacement code:\n>\n>     if ! test -f \"$@\"\n>\n> can easily lead to head-scratching, wondering why the author chose to\n> use \"$@\" rather than the more obvious \"$1\". This sort of unusual local\n> idiom might normally deserve an in-code comment explaining why the\n> more obvious code is not employed. However, adding a comment at each\n> site would be overkill, so it might be the sort of thing to explain in\n> documentation somewhere (\"In order to make -x output less noisy,\n> employ \"$@\" rather than explicitly checking function arguments when\n> writing new test functions...\".) Otherwise, the reader is forced to\n> consult the commit message.\n>\n> Not a major objection; just voicing the bit of unease I feel about it.\n\nI'm including a well-placed comment in the re-roll of this. FWIW this\nwould be much easier to follow with my rejected split-up of\ntest-lib-functions.sh, then we could group these functions into one\nfile:\nhttps://lore.kernel.org/git/20210209214159.22815-13-avarab@gmail.com/\n\n>> This does not to the \"right\" thing in cases like:\n>\n> Channeling Dscho's inner Eric Sunshine[1]: s/to/do/\n\nSunshine recursion error? :)\n\n> [1]: https://lore.kernel.org/git/nycvar.QRO.7.76.6.2103222235150.50@tvgsbejvaqbjf.bet/\n\n"},{"id":"422400","messageId":"patch-1.3-fd33f6d71f-20210420T122706Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com","subject":"[PATCH v2 1/3] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:29:28Z","receivedAt":"2021-04-20T12:29:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test_path_is_missing() to be consistent with related\nfunctions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to\ntest [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\necho-ing $* if it exists. Let's just say that it exists instead.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex bd64a15c73..0232cc9f46 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -810,12 +810,7 @@ test_path_is_missing () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \tif test -e \"$1\"\n \tthen\n-\t\techo \"Path exists:\"\n-\t\tls -ld \"$1\"\n-\t\tif test $# -ge 1\n-\t\tthen\n-\t\t\techo \"$*\"\n-\t\tfi\n+\t\techo \"Path $1 exists!\"\n \t\tfalse\n \tfi\n }\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422401","messageId":"cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com","subject":"[PATCH v2 0/3] test-lib-functions.sh: trickery to make -x less verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:29:27Z","receivedAt":"2021-04-20T12:29:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series makes the \"-x\" output less verbose for our various helper\nfunctions, mainly using the trickery of feeding \"$@\" to \"test\" to rely\non it to die when given too many arguments.\n\nSince v1 the only change is adding a comment as suggested by Eric\nSunshine, it's not ideal as noted in\n<87pmyp2led.fsf@evledraar.gmail.com> (I wish these were just in one\nfile, so we could have a comment at the top), but will aid future\nmaintenance anyway.\n\nÆvar Arnfjörð Bjarmason (3):\n  test-lib-functions: normalize test_path_is_missing() debugging\n  Revert and amend \"test-lib-functions: assert correct parameter count\"\n  test-lib-functions: remove last two parameter count assertions\n\n t/test-lib-functions.sh | 72 +++++++++++++++++------------------------\n 1 file changed, 30 insertions(+), 42 deletions(-)\n\nRange-diff against v1:\n1:  a3e20ef18f < -:  ---------- test-lib: split up and deprecate test_create_repo()\n2:  c22e3f7764 = 1:  fd33f6d71f test-lib-functions: normalize test_path_is_missing() debugging\n3:  6f9e09a201 ! 2:  67ddd821df Revert and amend \"test-lib-functions: assert correct parameter count\"\n    @@ Commit message\n     \n      ## t/test-lib-functions.sh ##\n     @@ t/test-lib-functions.sh: test_external_without_stderr () {\n    + }\n    + \n      # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n    - # The commands test the existence or non-existence of $1\n    +-# The commands test the existence or non-existence of $1\n    ++# The commands test the existence or non-existence of\n    ++# a given argument.\n    ++#\n    ++# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n    ++# are counting on \"test\" to error on too many arguments if more than\n    ++# one is given. Checking \"$#\" explicitly would lead to overly verbose\n    ++# -x output.\n      test_path_is_file () {\n     -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n     -\tif ! test -f \"$1\"\n4:  b7b11a60bc = 3:  8fd51861b5 test-lib-functions: remove last two parameter count assertions\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422402","messageId":"patch-3.3-8fd51861b5-20210420T122706Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com","subject":"[PATCH v2 3/3] test-lib-functions: remove last two parameter count assertions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:29:30Z","receivedAt":"2021-04-20T12:29:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove a couple of parameter count assertions where, unlike the\npreceding commit's migration to 'test -$x \"$@\"', we'll now silently do\nthe \"wrong\" thing if given too many parameters. The benefit is less\nverbose trace output, as noted in the preceding commit.\n\nIn the case of \"test_file_size\", the \"test-tool\" we're invoking is\nhappy to accept N parameters (it'll print out all N sizes). Let's just\nuse \"$@\" in that case anyway. There's only a few callers, and\neventually those should probably be moved to use the test-tool\ndirectly.\n\nThat only leaves test_line_count, I suppose I could leave that one\nalone, but since it's the only common function left that does this\nassertion let's remove it for the brevity of the -x output and\nconsistency with other functions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex f8f5bf9de1..e128b341ff 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -827,10 +827,7 @@ test_path_is_missing () {\n # output through when the number of lines is wrong.\n \n test_line_count () {\n-\tif test $# != 3\n-\tthen\n-\t\tBUG \"not 3 parameters to test_line_count\"\n-\telif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n+\tif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n \tthen\n \t\techo \"test_line_count: line count for $3 !$1 $2\"\n \t\tcat \"$3\"\n@@ -839,8 +836,7 @@ test_line_count () {\n }\n \n test_file_size () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest-tool path-utils file-size \"$1\"\n+\ttest-tool path-utils file-size \"$@\"\n }\n \n # Returns success if a comma separated string of keywords ($1) contains a\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422403","messageId":"patch-2.3-67ddd821df-20210420T122706Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com","subject":"[PATCH v2 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-20T12:29:29Z","receivedAt":"2021-04-20T12:29:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This reverts and amends my my own e7884b353b7 (test-lib-functions:\nassert correct parameter count, 2021-02-12) in order to improve the -x\noutput.\n\nThe goal here is to get rid of the verbosity of having e.g. a \"test 2\n-ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\nto intentionally feed the \"test\" operator too many arguments if the\nfunctions are called with too many arguments, thus piggy-backing on it\nto check the number of arguments we get.\n\nBefore this for each test_cmp invocation we'd emit:\n\n    + test_cmp expect actual\n    + test 2 -ne 2\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThat \"test 2 -ne 2\" line is new in my e7884b353b7. As noted in\n45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\nhelper param, 2021-02-12) we had buggy invocations of some of these\nfunctions with too many parameters.\n\nNow we'll get just:\n\n    + test_cmp expect actual\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThis does not to the \"right\" thing in cases like:\n\n    test_path_is_file x -a y\n\nWhich will now turn into:\n\n    test -f x -a y\n\nI consider that to be OK given the trade-off that any extra checking\nwould produce more verbose trace output. As shown in 45a2686441b we\nhad issues with these functions being invoked with multiple\nparameters (e.g. a glob) by accident, we don't need to be paranoid in\nguarding against hostile misuse from our own test suite.\n\nWhile I'm at it change a few functions that relied on a \"false\" being\nthe last statement in the function to use an explicit \"return 1\" like\nthe other functions in this file.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 59 +++++++++++++++++++----------------------\n 1 file changed, 28 insertions(+), 31 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 0232cc9f46..f8f5bf9de1 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -756,41 +756,43 @@ test_external_without_stderr () {\n }\n \n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n-# The commands test the existence or non-existence of $1\n+# The commands test the existence or non-existence of\n+# a given argument.\n+#\n+# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n+# are counting on \"test\" to error on too many arguments if more than\n+# one is given. Checking \"$#\" explicitly would lead to overly verbose\n+# -x output.\n test_path_is_file () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -f \"$1\"\n+\tif ! test -f \"$@\"\n \tthen\n-\t\techo \"File $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"File $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_dir () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -d \"$1\"\n+\tif ! test -d \"$@\"\n \tthen\n-\t\techo \"Directory $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Directory $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_exists () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -e \"$1\"\n+\tif ! test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Path $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n # Check if the directory exists and is empty as expected, barf otherwise.\n test_dir_is_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\ttest_path_is_dir \"$@\" &&\n+\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n \tthen\n-\t\techo \"Directory '$1' is not empty, it contains:\"\n+\t\techo \"Directory '$*' is not empty, it contains:\"\n \t\tls -la \"$1\"\n \t\treturn 1\n \tfi\n@@ -798,19 +800,17 @@ test_dir_is_empty () {\n \n # Check if the file exists and has a size greater than zero\n test_file_not_empty () {\n-\ttest \"$#\" = 2 && BUG \"2 param\"\n-\tif ! test -s \"$1\"\n+\tif ! test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not a non-empty file.\"\n-\t\tfalse\n+\t\techo \"'$*' is not a non-empty file.\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_missing () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif test -e \"$1\"\n+\tif test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 exists!\"\n+\t\techo \"Path $* exists!\"\n \t\tfalse\n \tfi\n }\n@@ -1012,7 +1012,6 @@ test_expect_code () {\n # - not all diff versions understand \"-u\"\n \n test_cmp () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \teval \"$GIT_TEST_CMP\" '\"$@\"'\n }\n \n@@ -1042,7 +1041,6 @@ test_cmp_config () {\n # test_cmp_bin - helper to compare binary files\n \n test_cmp_bin () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \tcmp \"$@\"\n }\n \n@@ -1103,12 +1101,11 @@ verbose () {\n # otherwise.\n \n test_must_be_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_file \"$1\" &&\n-\tif test -s \"$1\"\n+\ttest_path_is_file \"$@\" &&\n+\tif test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not empty, it contains:\"\n-\t\tcat \"$1\"\n+\t\techo \"'$*' is not empty, it contains:\"\n+\t\tcat \"$@\"\n \t\treturn 1\n \tfi\n }\n-- \n2.31.1.723.gf6bad1b9ba1\n\n"},{"id":"422440","messageId":"CAPig+cS31db=769dNZbADqCpkhR9PMuHv5x9knFvi=zSqoMF_Q@mail.gmail.com","threadId":"55480","inReplyTo":"patch-2.3-67ddd821df-20210420T122706Z-avarab@gmail.com","subject":"Re: [PATCH v2 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-20T15:07:58Z","receivedAt":"2021-04-20T15:08:12Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Apr 20, 2021 at 8:29 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> [...]\n> The goal here is to get rid of the verbosity of having e.g. a \"test 2\n> -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n> to intentionally feed the \"test\" operator too many arguments if the\n> functions are called with too many arguments, thus piggy-backing on it\n> to check the number of arguments we get.\n> [...]\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> @@ -756,41 +756,43 @@ test_external_without_stderr () {\n>  # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n> +# The commands test the existence or non-existence of\n> +# a given argument.\n> +#\n> +# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n> +# are counting on \"test\" to error on too many arguments if more than\n> +# one is given. Checking \"$#\" explicitly would lead to overly verbose\n> +# -x output.\n>  test_path_is_file () {\n> +       if ! test -f \"$@\"\n\nThanks. The new comment makes the intent of \"$@\" clear.\n\nIf you do re-roll for some reason, it might make sense to move the new\ncomment (the one starting \"The pattern of...\") into the function\nitself just before the use of \"$@\". The reasons I suggest this are:\n(1) the comment explains an implementation detail, thus is intended\nfor people who might change this function, whereas all the text above\nthe new paragraph is API documentation for callers of the function who\nneed only the black-box description; (2) it places the comment closer\nto the relevant code, thus is less likely to be overlooked by someone\nchanging the function.\n"},{"id":"422477","messageId":"xmqqfszk4pz4.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-3.3-8fd51861b5-20210420T122706Z-avarab@gmail.com","subject":"Re: [PATCH v2 3/3] test-lib-functions: remove last two parameter count assertions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-20T21:15:43Z","receivedAt":"2021-04-20T21:15:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Remove a couple of parameter count assertions where, unlike the\n> preceding commit's migration to 'test -$x \"$@\"', we'll now silently do\n> the \"wrong\" thing if given too many parameters. The benefit is less\n> verbose trace output, as noted in the preceding commit.\n>\n> In the case of \"test_file_size\", the \"test-tool\" we're invoking is\n> happy to accept N parameters (it'll print out all N sizes). Let's just\n> use \"$@\" in that case anyway. There's only a few callers, and\n> eventually those should probably be moved to use the test-tool\n> directly.\n>\n> That only leaves test_line_count, I suppose I could leave that one\n> alone, but since it's the only common function left that does this\n> assertion let's remove it for the brevity of the -x output and\n> consistency with other functions.\n\nUnlike the previous step that did not entirely sacrifice the \"test\nwriters are human and they need our help in detecting their\nmistakes\", this step feels like \"shortening '-x' output is the most\nimportant thing in the world, and helping test writers is much less\nimportant.\"\n\nIOW, I am not convinced it is a good change.\n\n\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/test-lib-functions.sh | 8 ++------\n>  1 file changed, 2 insertions(+), 6 deletions(-)\n>\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index f8f5bf9de1..e128b341ff 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -827,10 +827,7 @@ test_path_is_missing () {\n>  # output through when the number of lines is wrong.\n>  \n>  test_line_count () {\n> -\tif test $# != 3\n> -\tthen\n> -\t\tBUG \"not 3 parameters to test_line_count\"\n> -\telif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n> +\tif ! test $(wc -l <\"$3\") \"$1\" \"$2\"\n>  \tthen\n>  \t\techo \"test_line_count: line count for $3 !$1 $2\"\n>  \t\tcat \"$3\"\n> @@ -839,8 +836,7 @@ test_line_count () {\n>  }\n>  \n>  test_file_size () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\ttest-tool path-utils file-size \"$1\"\n> +\ttest-tool path-utils file-size \"$@\"\n>  }\n>  \n>  # Returns success if a comma separated string of keywords ($1) contains a\n"},{"id":"422478","messageId":"20210420212731.GY2947267@szeder.dev","threadId":"55480","inReplyTo":"87h7k41t6i.fsf@evledraar.gmail.com","subject":"Re: [PATCH v2 12/12] test-lib: split up and deprecate test_create_repo()","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-20T21:27:31Z","receivedAt":"2021-04-20T21:27:35Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sat, Apr 17, 2021 at 11:45:41PM +0200, Ævar Arnfjörð Bjarmason wrote:\n> >>  5. Since we don't need to move the .git/hooks directory\n> >\n> > Since we don't change directory anymore...\n> >\n> >> we don't need\n> >>     the subshell here either.\n> >> \n> >>     That wasn't really needed for the .git/hooks either, but was being\n> >>     done for the convenience of not having to quote the path to the\n> >>     repository as we moved the hooks.\n> >\n> > And then this dubious explanation will not be necessary.\n> \n> Why dubious? That's why we had the subshell-ing. See 0d314ce834\n> (test-lib: use subshell instead of cd $new && .. && cd $old,\n> 2010-08-30).\n\nThat commit doesn't mention hooks at all, so I'm not sure what I\nshould see there.  OTOH, you did specifically write \"use a subshell\ninstead of keeping track of the old working directory and cd-ing back\nwhen it's done\"...  which is in line with our best practices on how to\nchange directories in our tests in order to reliably change back even\nin case of an error.\n\nAnd that cd-ing back and forth was not added because of the hooks\neither, but because back in the day when 'test_create_repo' was\ncreated 'git init-db' could only create a new repository in the\ncurrent directory.\n\n> I don't mind rewording or not including some of this verbosity per-se,\n> but I wonder why you're honing in on the subshell part in\n> particular. Maybe there's something I'm missing...\n> \n> The goal of the commit messsage is to point-by-point tear apart facets\n> of the previous behavior,\n\nAgreed.\n\n> and assure the reader that e.g. the\n> subshelling isn't needed for some other subtle reason.\n\nThe role of moving the hooks with respect to the subshell is not a\nsubtlety, it is simply irrelevant.  And while you are so focused on\nthis irrevelancy you keep forgetting to mention the factor that\nactually does matter: that we won't change directories anymore.\n\n\n"},{"id":"422484","messageId":"xmqqwnsw3872.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-01.12-a8b483bc77-20210420T121833Z-avarab@gmail.com","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-20T22:25:05Z","receivedAt":"2021-04-20T22:28:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> These will only match the simplistic forms of `test -X blah` (where\n> \"-X\" is some single letter option), but will miss expressions such as\n> `test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\n> things like:\n>\n>     test whatever && ls -a foo\n>     test whatever && foo -o outfile\n\nI still do not understand why you have to insist on dashed operator\nas the first thing given to \"test\", like this:\n\n> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" ...\n> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" ...\n\nIOW, what over-matching would we get if we simplified the condition\nlike so?\n\n    /\\btest\\s+[^&|]+\\s+-a\\s/\n    /\\btest\\s+[^&|]+\\s+-o\\s/\n\nThe one in the patch would miss things like\n\n\ttest \"$a\" = \"$b\" -o \"$a\" -lt \"$b\"\n\ttest \"$n\" -a \"$n\" -lt 4\n\nbut the only thing that we care about is that a command that started\nwith \"test \" has \"-a\" or \"-o\" before we see \"&\" or \"|\", no?\n"},{"id":"422485","messageId":"xmqqsg3k381c.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-02.12-39759d00ad-20210420T121833Z-avarab@gmail.com","subject":"Re: [PATCH v3 02/12] test-lib: bring $remove_trash out of retirement","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-20T22:28:31Z","receivedAt":"2021-04-20T22:28:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> We carry around the \"$remove_trash\" variable because if the directory\n> is unexpectedly gone at test_done time we'll hit the error about it\n> being unexpectedly gone added in df4c0d1a792 (test-lib: abort when\n> can't remove trash directory, 2017-04-20).\n\nMakes sense, but then remove_trash should be initialized to a\nnon-empty string at the beginning, to avoid it leaking from end-user\nenvironment, just like the way store_arg_to and opt_required_arg are\nprotected?\n\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 3dec266221..7522faf39f 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -1169,7 +1169,7 @@ test_done () {\n>  \t\t\tesac\n>  \t\tfi\n>  \n> -\t\tif test -z \"$debug\"\n> +\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n>  \t\tthen\n>  \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n>  \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n> @@ -1334,6 +1334,21 @@ then\n>  \texit 1\n>  fi\n>  \n> +# Are we running this test at all?\n> +this_test=${0##*/}\n> +this_test=${this_test%%-*}\n> +if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n> +then\n> +\tsay_color info >&3 \"skipping test $this_test altogether\"\n> +\tskip_all=\"skip all tests in $this_test\"\n> +\ttest_done\n> +fi\n> +\n> +# Last-minute variable setup\n> +HOME=\"$TRASH_DIRECTORY\"\n> +GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n> +export HOME GNUPGHOME\n> +\n>  # Test repository\n>  rm -fr \"$TRASH_DIRECTORY\" || {\n>  \tGIT_EXIT_OK=t\n> @@ -1341,10 +1356,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n>  \texit 1\n>  }\n>  \n> -HOME=\"$TRASH_DIRECTORY\"\n> -GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n> -export HOME GNUPGHOME\n> -\n> +remove_trash=t\n>  if test -z \"$TEST_NO_CREATE_REPO\"\n>  then\n>  \ttest_create_repo \"$TRASH_DIRECTORY\"\n> @@ -1356,15 +1368,6 @@ fi\n>  # in subprocesses like git equals our $PWD (for pathname comparisons).\n>  cd -P \"$TRASH_DIRECTORY\" || exit 1\n>  \n> -this_test=${0##*/}\n> -this_test=${this_test%%-*}\n> -if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n> -then\n> -\tsay_color info >&3 \"skipping test $this_test altogether\"\n> -\tskip_all=\"skip all tests in $this_test\"\n> -\ttest_done\n> -fi\n> -\n>  if test -n \"$write_junit_xml\"\n>  then\n>  \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n"},{"id":"422545","messageId":"87wnsw2gjj.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"CAPig+cS31db=769dNZbADqCpkhR9PMuHv5x9knFvi=zSqoMF_Q@mail.gmail.com","subject":"Re: [PATCH v2 2/3] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T08:22:24Z","receivedAt":"2021-04-21T08:22:34Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Apr 20 2021, Eric Sunshine wrote:\n\n> On Tue, Apr 20, 2021 at 8:29 AM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>> [...]\n>> The goal here is to get rid of the verbosity of having e.g. a \"test 2\n>> -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n>> to intentionally feed the \"test\" operator too many arguments if the\n>> functions are called with too many arguments, thus piggy-backing on it\n>> to check the number of arguments we get.\n>> [...]\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n>> @@ -756,41 +756,43 @@ test_external_without_stderr () {\n>>  # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n>> +# The commands test the existence or non-existence of\n>> +# a given argument.\n>> +#\n>> +# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n>> +# are counting on \"test\" to error on too many arguments if more than\n>> +# one is given. Checking \"$#\" explicitly would lead to overly verbose\n>> +# -x output.\n>>  test_path_is_file () {\n>> +       if ! test -f \"$@\"\n>\n> Thanks. The new comment makes the intent of \"$@\" clear.\n>\n> If you do re-roll for some reason, it might make sense to move the new\n> comment (the one starting \"The pattern of...\") into the function\n> itself just before the use of \"$@\". The reasons I suggest this are:\n> (1) the comment explains an implementation detail, thus is intended\n> for people who might change this function, whereas all the text above\n> the new paragraph is API documentation for callers of the function who\n> need only the black-box description; (2) it places the comment closer\n> to the relevant code, thus is less likely to be overlooked by someone\n> changing the function.\n\nI think moving it would be worse / wouldn't make sense.\n\nThe comment doesn't just apply to test_path_is_file(), but the next N\nfunctions that use the \"$@\" pattern. Just like the existing\n\"debugging-friendly alternatives\" comment does. I.e. test_path_is_file\nis just the \"-f\" part of thta comment, the following test_path_is_dir is\nthe \"-d\" etc.\n"},{"id":"422547","messageId":"87r1j42ffz.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"xmqqwnsw3872.fsf@gitster.g","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T08:46:08Z","receivedAt":"2021-04-21T08:46:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Apr 21 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> These will only match the simplistic forms of `test -X blah` (where\n>> \"-X\" is some single letter option), but will miss expressions such as\n>> `test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\n>> things like:\n>>\n>>     test whatever && ls -a foo\n>>     test whatever && foo -o outfile\n>\n> I still do not understand why you have to insist on dashed operator\n> as the first thing given to \"test\", like this:\n>\n>> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" ...\n>> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" ...\n>\n> IOW, what over-matching would we get if we simplified the condition\n> like so?\n>\n>     /\\btest\\s+[^&|]+\\s+-a\\s/\n>     /\\btest\\s+[^&|]+\\s+-o\\s/\n>\n> The one in the patch would miss things like\n>\n> \ttest \"$a\" = \"$b\" -o \"$a\" -lt \"$b\"\n> \ttest \"$n\" -a \"$n\" -lt 4\n>\n> but the only thing that we care about is that a command that started\n> with \"test \" has \"-a\" or \"-o\" before we see \"&\" or \"|\", no?\n\nApplying your suggestion results in these false positives:\n\t\n\tt4038-diff-combined.sh:135: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test space change\" -a &&\n\tt4038-diff-combined.sh:147: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test other space changes\" -a &&\n\tt6400-merge-df.sh:89: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n\tt6400-merge-df.sh:91: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n\tt6400-merge-df.sh:110: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n\tt6400-merge-df.sh:112: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n\tt6402-merge-rename.sh:639: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\"\n\tt6402-merge-rename.sh:646: error: \"test A || test B\" preferred to \"test A -o B\": test 2 -eq \"$(git ls-files -o | wc -l)\"\n\tt6402-merge-rename.sh:686: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\" &&\n\tt6402-merge-rename.sh:865: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l) &&\n\tannotate-tests.sh:201: error: \"test A && test B\" preferred to \"test A -a B\": GIT_AUTHOR_NAME=\"E\" GIT_AUTHOR_EMAIL=\"E at test dot git\" git commit -a -m \"norobots\"\n\nI'll just drop this from the re-roll of this series. Maybe you/someone\nhas a better suggestion for something that's simple but still catches\nthese cases, but in any case I'd like to not have this series blocked on\nthis minor thing (which none of the rest of it needs).\n"},{"id":"422556","messageId":"patch-02.11-de7be7844e-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 02/11] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:07Z","receivedAt":"2021-04-21T10:15:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27..2c6e34b947 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422557","messageId":"patch-01.11-a76ea749bb-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 01/11] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:06Z","receivedAt":"2021-04-21T10:15:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests. We can save\nourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\ncase.\n\nWe carry around the \"$remove_trash\" variable because if the directory\nis unexpectedly gone at test_done time we'll hit the error about it\nbeing unexpectedly gone added in df4c0d1a792 (test-lib: abort when\ncan't remove trash directory, 2017-04-20).\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nLet's also fix a bug that was with us since abc5d372ec (Enable\nparallel tests, 2008-08-08): we would leak $remove_trash from the\nenvironment. We don't want this to error out, so let's reset it to the\nempty string first:\n\n     remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 32 ++++++++++++++++++--------------\n 1 file changed, 18 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3dec266221..105c424bf5 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1169,7 +1169,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1334,6 +1334,22 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+remove_trash=\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1341,10 +1357,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1356,15 +1369,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422558","messageId":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.12-0000000000-20210420T121833Z-avarab@gmail.com","subject":"[PATCH v4 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:05Z","receivedAt":"2021-04-21T10:15:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"A fast re-roll of this test topic that a few things depend on, per\nhttps://lore.kernel.org/git/xmqqk0ow1plt.fsf@gitster.g/\n\nChanges since v3:\n\n * Dropped the check-non-portable-shell change\n\n   As noted in\n   https://lore.kernel.org/git/87r1j42ffz.fsf@evledraar.gmail.com/ it\n   wasn't needed for the rest of this series, so let's not hold it up\n   for the discussion of if/how to check \"-a\" and \"-o\" invocations of\n   \"test\".\n\n * Set the remove_trash= variable so we won't leak it from the\n   environment.\n\nÆvar Arnfjörð Bjarmason (11):\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: split up and deprecate test_create_repo()\n\n t/lib-submodule-update.sh           |  3 +-\n t/t0000-basic.sh                    |  4 --\n t/t1307-config-blob.sh              |  4 +-\n t/t1403-show-ref.sh                 |  6 +--\n t/t2030-unresolve-info.sh           |  3 +-\n t/t4006-diff-mode.sh                |  6 +--\n t/t4030-diff-textconv.sh            |  8 +---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 -\n t/t5409-colorize-remote-messages.sh |  1 -\n t/t5520-pull.sh                     | 10 +----\n t/t6120-describe.sh                 | 58 +++++++---------------------\n t/test-lib-functions.sh             | 60 ++++++++++++++++++-----------\n t/test-lib.sh                       | 40 +++++++++++--------\n 14 files changed, 87 insertions(+), 119 deletions(-)\n\nRange-diff against v3:\n 1:  a8b483bc77 <  -:  ---------- check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"\n 2:  39759d00ad !  1:  a76ea749bb test-lib: bring $remove_trash out of retirement\n    @@ Commit message\n         variable, 2017-04-23) and move the decision about whether to skip all\n         tests earlier.\n     \n    +    Let's also fix a bug that was with us since abc5d372ec (Enable\n    +    parallel tests, 2008-08-08): we would leak $remove_trash from the\n    +    environment. We don't want this to error out, so let's reset it to the\n    +    empty string first:\n    +\n    +         remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh\n    +\n         I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\n         under --debug at the end of the test, 2017-04-24) for a bug we don't\n         want to re-introduce.\n    @@ t/test-lib.sh: then\n      fi\n      \n     +# Are we running this test at all?\n    ++remove_trash=\n     +this_test=${0##*/}\n     +this_test=${this_test%%-*}\n     +if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n 3:  d669ce3196 =  2:  de7be7844e test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n 4:  9313d35bf8 =  3:  709bc773fb test-lib-functions: reword \"test_commit --append\" docs\n 5:  c916d648e4 =  4:  b67654334e test-lib-functions: document test_commit --no-tag\n 6:  9b6bf65ce1 =  5:  3a166c9206 test-lib functions: add an --annotated option to \"test_commit\"\n 7:  683b3ba3dd =  6:  981fc43ee6 describe tests: convert setup to use test_commit\n 8:  dc0a863db7 =  7:  15057cdecf test-lib functions: add --printf option to test_commit\n 9:  90bf55d2d4 =  8:  5d437f53ec submodule tests: use symbolic-ref --short to discover branch name\n10:  e0a1e2fd52 =  9:  9ee13ee71b test-lib: reformat argument list in test_create_repo()\n11:  cedf5d383b = 10:  6ba568df9f test-lib: do not show advice about init.defaultBranch under --verbose\n12:  0dc0da9490 = 11:  311a9dba36 test-lib: split up and deprecate test_create_repo()\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422559","messageId":"patch-03.11-709bc773fb-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 03/11] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:08Z","receivedAt":"2021-04-21T10:15:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6348e8d733..d169fb2f59 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422560","messageId":"patch-04.11-b67654334e-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 04/11] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:09Z","receivedAt":"2021-04-21T10:15:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d169fb2f59..d0f4f3885d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,8 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422561","messageId":"patch-05.11-3a166c9206-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 05/11] test-lib functions: add an --annotated option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:10Z","receivedAt":"2021-04-21T10:15:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated option to test_commit to create annotated tags. The\ntag will share the same message as the commit, and we'll call\ntest_tick before creating it (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c..17d3cc1405 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex d0f4f3885d..6e2332a324 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -179,6 +179,10 @@ debug () {\n #\tInvoke \"git commit\" with --author <author>\n #   --no-tag\n #\tDo not tag the resulting commit\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag, unless --notick\n+#\tis given.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -191,7 +195,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -219,7 +223,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -243,10 +250,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test -z \"$notick\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422562","messageId":"patch-07.11-15057cdecf-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 07/11] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:12Z","receivedAt":"2021-04-21T10:15:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 12 ++++++++++--\n 6 files changed, 18 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388..930dce06f0 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a..f691e6d903 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15..6cdee2a216 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60..a39a626664 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f..e2c0c51022 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6e2332a324..dbeb3d9262 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,10 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -191,6 +195,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -202,6 +207,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -238,9 +246,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422563","messageId":"patch-06.11-981fc43ee6-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 06/11] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:11Z","receivedAt":"2021-04-21T10:15:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotated-tag option to\ntest_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747be..88fddc9142 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422564","messageId":"patch-08.11-5d437f53ec-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 08/11] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:13Z","receivedAt":"2021-04-21T10:15:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e9308..f7c7df0ca4 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422565","messageId":"patch-09.11-9ee13ee71b-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 09/11] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:14Z","receivedAt":"2021-04-21T10:15:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex dbeb3d9262..21271020c7 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1257,8 +1257,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422566","messageId":"patch-10.11-6ba568df9f-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 10/11] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:15Z","receivedAt":"2021-04-21T10:15:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 21271020c7..8e75a013a4 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1258,7 +1258,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 105c424bf5..ab1fe98ccc 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422567","messageId":"patch-11.11-311a9dba36-20210421T101156Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v4 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T10:15:16Z","receivedAt":"2021-04-21T10:15:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove various redundant or obsolete code from the test_create_repo()\nfunction, and split up its use in test-lib.sh from what tests need\nfrom it.\n\nThis leave us with a pass-through wrapper for \"git init\" in\ntest-lib-functions.sh, in test-lib.sh we have the same, except for\nneeding to redirect stdout/stderr, and emitting an error ourselves if\nit fails. We don't need to error() ourselves when test_create_repo()\nis invoked, as the invocation will be a part of a test's \"&&\"-chain.\n\nEverything below this paragraph is a detailed summary of the history\nof test_create_repo() explaining why it's safe to remove the various\nthings it was doing:\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. Since we're now a simple wrapper for \"git init\" we don't need to\n    check that we have only one argument. If someone wants to run\n    \"test_create_repo --bare x\" that's OK.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n 5. Since we don't need to move the .git/hooks directory we don't need\n    the subshell here either.\n\n    See 0d314ce834 for when the subshell use got introduced for the\n    convenience of not having to \"cd\" back and forth while setting up\n    the hooks.\n\n 6. We can drop the --template argument and instead rely on the\n    GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n\n 7. We only needed that \">&3 2>&4\" redirection when invoked from\n    test-lib.sh.\n\n    We could still invoke test_create_repo() there, but as the\n    invocation is now trivial and we don't have a good reason to use\n    test_create_repo() elsewhere let's call \"git init\" there\n    ourselves.\n\n 8. We didn't need to resolve \"git\" as\n    \"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" in test_create_repo(),\n    even for the use of test-lib.sh\n\n    PATH is already set up in test-lib.sh to start with\n    GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before\n    test_create_repo() (now \"git init\") is called.. So we can simply\n    run \"git\" and rely on the PATH lookup choosing the right\n    executable.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 ++-------------\n t/test-lib.sh                       |  3 ++-\n 5 files changed, 4 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649..5c509db6fc 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4..6da8d760e2 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8e..9f1a483f42 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 8e75a013a4..bd64a15c73 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1248,21 +1248,10 @@ test_atexit () {\n \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n }\n \n-# Most tests can use the created repository, but some may need to create more.\n+# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\tgit init \"$@\"\n }\n \n # This function helps on symlink challenged file systems when it is not\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ab1fe98ccc..5fd968d11b 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1365,7 +1365,8 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n-\ttest_create_repo \"$TRASH_DIRECTORY\"\n+\tgit init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n+\terror \"cannot run git init\"\n else\n \tmkdir -p \"$TRASH_DIRECTORY\"\n fi\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422571","messageId":"YIAAzJTG1UitiWyu@danh.dev","threadId":"55480","inReplyTo":"87r1j42ffz.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-21T10:39:08Z","receivedAt":"2021-04-21T10:39:14Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-21 10:46:08+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> \n> On Wed, Apr 21 2021, Junio C Hamano wrote:\n> \n> > Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n> >\n> >> These will only match the simplistic forms of `test -X blah` (where\n> >> \"-X\" is some single letter option), but will miss expressions such as\n> >> `test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\n> >> things like:\n> >>\n> >>     test whatever && ls -a foo\n> >>     test whatever && foo -o outfile\n> >\n> > I still do not understand why you have to insist on dashed operator\n> > as the first thing given to \"test\", like this:\n> >\n> >> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" ...\n> >> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" ...\n> >\n> > IOW, what over-matching would we get if we simplified the condition\n> > like so?\n> >\n> >     /\\btest\\s+[^&|]+\\s+-a\\s/\n> >     /\\btest\\s+[^&|]+\\s+-o\\s/\n> >\n> > The one in the patch would miss things like\n> >\n> > \ttest \"$a\" = \"$b\" -o \"$a\" -lt \"$b\"\n> > \ttest \"$n\" -a \"$n\" -lt 4\n> >\n> > but the only thing that we care about is that a command that started\n> > with \"test \" has \"-a\" or \"-o\" before we see \"&\" or \"|\", no?\n> \n> Applying your suggestion results in these false positives:\n> \t\n> \tt4038-diff-combined.sh:135: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test space change\" -a &&\n> \tt4038-diff-combined.sh:147: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test other space changes\" -a &&\n> \tt6400-merge-df.sh:89: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n> \tt6400-merge-df.sh:91: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n> \tt6400-merge-df.sh:110: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n> \tt6400-merge-df.sh:112: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n> \tt6402-merge-rename.sh:639: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\"\n> \tt6402-merge-rename.sh:646: error: \"test A || test B\" preferred to \"test A -o B\": test 2 -eq \"$(git ls-files -o | wc -l)\"\n> \tt6402-merge-rename.sh:686: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\" &&\n> \tt6402-merge-rename.sh:865: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l) &&\n\nWith: 7dbe8c8003, (check-non-portable-shell.pl: `wc -l` may have\nleading WS, 2017-12-21)\nUnless the situation has been changed, since.\nI think those tests with quoted \"$(.. | wc -l)\" has been deemed\nunportable and should be replaced with test_line_count anyway?\nDoes \"test -eq\" strip spaces from integer strings?\n\nAnd I think we're working on moving \"git\" command to its own commmand\ninstead of put it in the left of a pipe.\n\n2 followed patch will clean them out\n\n\n-- \nDanh\n"},{"id":"422572","messageId":"20210421104102.3409-1-congdanhqx@gmail.com","threadId":"55480","inReplyTo":"YIAAzJTG1UitiWyu@danh.dev","subject":"[PATCH 1/2] t6400: check exit status of ls-files","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-21T10:41:01Z","receivedAt":"2021-04-21T10:41:10Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"We will lose the exit status of \"git ls-files\" if it's being run in\nanywhere-but-not-final part of a pipe.\n\nLet's send the output of \"git ls-files\" to a file first,\nand adjust the expected result for \"git ls-files -o\" since a new\nuntracked file will be created as a side effect.\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/t6400-merge-df.sh | 22 ++++++++++++++--------\n 1 file changed, 14 insertions(+), 8 deletions(-)\n\ndiff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh\nindex 38700d29b5..fd99a78360 100755\n--- a/t/t6400-merge-df.sh\n+++ b/t/t6400-merge-df.sh\n@@ -82,13 +82,16 @@ test_expect_success 'modify/delete + directory/file conflict' '\n \tgit checkout delete^0 &&\n \ttest_must_fail git merge modify &&\n \n-\ttest 5 -eq $(git ls-files -s | wc -l) &&\n-\ttest 4 -eq $(git ls-files -u | wc -l) &&\n+\tgit ls-files -s >out &&\n+\ttest_line_count = 5 out &&\n+\tgit ls-files -u >out &&\n+\ttest_line_count = 4 out &&\n+\tgit ls-files -o >out &&\n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 0 -eq $(git ls-files -o | wc -l)\n+\t\ttest_line_count = 1 out\n \telse\n-\t\ttest 1 -eq $(git ls-files -o | wc -l)\n+\t\ttest_line_count = 2 out\n \tfi &&\n \n \ttest_path_is_file letters/file &&\n@@ -103,13 +106,16 @@ test_expect_success 'modify/delete + directory/file conflict; other way' '\n \n \ttest_must_fail git merge delete &&\n \n-\ttest 5 -eq $(git ls-files -s | wc -l) &&\n-\ttest 4 -eq $(git ls-files -u | wc -l) &&\n+\tgit ls-files -s >out &&\n+\ttest_line_count = 5 out &&\n+\tgit ls-files -u >out &&\n+\ttest_line_count = 4 out &&\n+\tgit ls-files -o >out &&\n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 0 -eq $(git ls-files -o | wc -l)\n+\t\ttest_line_count = 1 out\n \telse\n-\t\ttest 1 -eq $(git ls-files -o | wc -l)\n+\t\ttest_line_count = 2 out\n \tfi &&\n \n \ttest_path_is_file letters/file &&\n-- \n2.31.1.192.g0881477623\n\n"},{"id":"422573","messageId":"20210421104102.3409-2-congdanhqx@gmail.com","threadId":"55480","inReplyTo":"20210421104102.3409-1-congdanhqx@gmail.com","subject":"[PATCH 2/2] t6402: check exit status of ls-files","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-21T10:41:02Z","receivedAt":"2021-04-21T10:41:18Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"We will lose the exit status of \"git ls-files\" if it's being run in\nanywhere-but-not-final part of a pipe.\n\nLet's send the output of \"git ls-files\" to a file first,\nand adjust the expected result for \"git ls-files -o\" since a new\nuntracked file will be created as a side effect.\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/t6402-merge-rename.sh | 148 +++++++++++++++++++++++++++-------------\n 1 file changed, 101 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh\nindex 425dad97d5..d705847f26 100755\n--- a/t/t6402-merge-rename.sh\n+++ b/t/t6402-merge-rename.sh\n@@ -330,8 +330,10 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '\n \t\ttest_i18ngrep \"Adding as dir~HEAD instead\" output\n \tfi &&\n \n-\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\ttest 2 -eq \"$(git ls-files -u dir/file-in-the-way | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 3 output &&\n+\tgit ls-files -u dir/file-in-the-way >output &&\n+\ttest_line_count = 2 output &&\n \n \ttest_must_fail git diff --quiet &&\n \ttest_must_fail git diff --cached --quiet &&\n@@ -357,8 +359,10 @@ test_expect_success 'Same as previous, but merged other way' '\n \t\ttest_i18ngrep \"Adding as dir~renamed-file-has-no-conflicts instead\" output\n \tfi &&\n \n-\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\ttest 2 -eq \"$(git ls-files -u dir/file-in-the-way | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 3 output &&\n+\tgit ls-files -u dir/file-in-the-way >output &&\n+\ttest_line_count = 2 output &&\n \n \ttest_must_fail git diff --quiet &&\n \ttest_must_fail git diff --cached --quiet &&\n@@ -374,8 +378,10 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in\n \tgit checkout -q renamed-file-has-conflicts^0 &&\n \ttest_must_fail git merge --strategy=recursive dir-not-in-way &&\n \n-\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\ttest 3 -eq \"$(git ls-files -u dir | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 3 output &&\n+\tgit ls-files -u dir >output &&\n+\ttest_line_count = 3 output &&\n \n \ttest_must_fail git diff --quiet &&\n \ttest_must_fail git diff --cached --quiet &&\n@@ -409,14 +415,19 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t\n \tgit checkout -q renamed-file-has-conflicts^0 &&\n \ttest_must_fail git merge --strategy=recursive dir-in-way &&\n \n-\ttest 5 -eq \"$(git ls-files -u | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 5 output &&\n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 3 -eq \"$(git ls-files -u dir~HEAD | wc -l)\"\n+\t\tgit ls-files -u dir~HEAD >output &&\n+\t\ttest_line_count = 3 output\n \telse\n-\t\ttest 3 -eq \"$(git ls-files -u dir | grep -v file-in-the-way | wc -l)\"\n+\t\tgit ls-files -u dir >output &&\n+\t\tgrep -v file-in-the-way output >filtered\n+\t\ttest_line_count = 3 filtered\n \tfi &&\n-\ttest 2 -eq \"$(git ls-files -u dir/file-in-the-way | wc -l)\" &&\n+\tgit ls-files -u dir/file-in-the-way >output &&\n+\ttest_line_count = 2 output &&\n \n \ttest_must_fail git diff --quiet &&\n \ttest_must_fail git diff --cached --quiet &&\n@@ -432,14 +443,19 @@ test_expect_success 'Same as previous, but merged other way' '\n \tgit checkout -q dir-in-way^0 &&\n \ttest_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&\n \n-\ttest 5 -eq \"$(git ls-files -u | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 5 output &&\n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 3 -eq \"$(git ls-files -u dir~renamed-file-has-conflicts | wc -l)\"\n+\t\tgit ls-files -u dir~renamed-file-has-conflicts >output &&\n+\t\ttest_line_count = 3 output\n \telse\n-\t\ttest 3 -eq \"$(git ls-files -u dir | grep -v file-in-the-way | wc -l)\"\n+\t\tgit ls-files -u dir >output &&\n+\t\tgrep -v file-in-the-way output >filtered\n+\t\ttest_line_count = 3 filtered\n \tfi &&\n-\ttest 2 -eq \"$(git ls-files -u dir/file-in-the-way | wc -l)\" &&\n+\tgit ls-files -u dir/file-in-the-way >output &&\n+\ttest_line_count = 2 output &&\n \n \ttest_must_fail git diff --quiet &&\n \ttest_must_fail git diff --cached --quiet &&\n@@ -494,11 +510,12 @@ test_expect_success 'both rename source and destination involved in D/F conflict\n \tgit checkout -q rename-dest^0 &&\n \ttest_must_fail git merge --strategy=recursive source-conflict &&\n \n+\tgit ls-files -u >output &&\n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 2 -eq \"$(git ls-files -u | wc -l)\"\n+\t\ttest_line_count = 2 output\n \telse\n-\t\ttest 1 -eq \"$(git ls-files -u | wc -l)\"\n+\t\ttest_line_count = 1 output\n \tfi &&\n \n \ttest_must_fail git diff --quiet &&\n@@ -540,9 +557,13 @@ then\n \t\tmkdir one &&\n \t\ttest_must_fail git merge --strategy=recursive rename-two &&\n \n-\t\ttest 4 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 2 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\t\ttest 2 -eq \"$(git ls-files -u two | wc -l)\" &&\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 4 output &&\n+\t\tgit ls-files -u one >output &&\n+\t\ttest_line_count = 2 output &&\n+\t\tgit ls-files -u two >output &&\n+\t\ttest_line_count = 2 output &&\n+\t\trm -f output &&\n \n \t\ttest_must_fail git diff --quiet &&\n \n@@ -559,9 +580,13 @@ else\n \t\tmkdir one &&\n \t\ttest_must_fail git merge --strategy=recursive rename-two &&\n \n-\t\ttest 2 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u two | wc -l)\" &&\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 2 output &&\n+\t\tgit ls-files -u one >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u two >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\trm -f output &&\n \n \t\ttest_must_fail git diff --quiet &&\n \n@@ -582,14 +607,21 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta\n \n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 4 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 2 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\t\ttest 2 -eq \"$(git ls-files -u two | wc -l)\"\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 4 output &&\n+\t\tgit ls-files -u one >output &&\n+\t\ttest_line_count = 2 output &&\n+\t\tgit ls-files -u two >output &&\n+\t\ttest_line_count = 2 output\n \telse\n-\t\ttest 2 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u two | wc -l)\"\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 2 output &&\n+\t\tgit ls-files -u one >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u two >output &&\n+\t\ttest_line_count = 1 output\n \tfi &&\n+\trm -f output &&\n \n \ttest_must_fail git diff --quiet &&\n \n@@ -631,20 +663,33 @@ test_expect_success 'check handling of differently renamed file with D/F conflic\n \n \tif test \"$GIT_TEST_MERGE_ALGORITHM\" = ort\n \tthen\n-\t\ttest 5 -eq \"$(git ls-files -s | wc -l)\" &&\n-\t\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u one~HEAD | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u two~second-rename | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u original | wc -l)\" &&\n-\t\ttest 0 -eq \"$(git ls-files -o | wc -l)\"\n+\t\tgit ls-files -s >output &&\n+\t\ttest_line_count = 5 output &&\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 3 output &&\n+\t\tgit ls-files -u one~HEAD >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u two~second-rename >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u original >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -o >output &&\n+\t\ttest_line_count = 1 output\n \telse\n-\t\ttest 5 -eq \"$(git ls-files -s | wc -l)\" &&\n-\t\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u two | wc -l)\" &&\n-\t\ttest 1 -eq \"$(git ls-files -u original | wc -l)\" &&\n-\t\ttest 2 -eq \"$(git ls-files -o | wc -l)\"\n+\t\tgit ls-files -s >output &&\n+\t\ttest_line_count = 5 output &&\n+\t\tgit ls-files -u >output &&\n+\t\ttest_line_count = 3 output &&\n+\t\tgit ls-files -u one >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u two >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -u original >output &&\n+\t\ttest_line_count = 1 output &&\n+\t\tgit ls-files -o >output &&\n+\t\ttest_line_count = 3 output\n \tfi &&\n+\trm -f output &&\n \n \ttest_path_is_file one/file &&\n \ttest_path_is_file two/file &&\n@@ -679,11 +724,17 @@ test_expect_success 'check handling of differently renamed file with D/F conflic\n \tgit checkout -q first-rename-redo^0 &&\n \ttest_must_fail git merge --strategy=recursive second-rename-redo &&\n \n-\ttest 3 -eq \"$(git ls-files -u | wc -l)\" &&\n-\ttest 1 -eq \"$(git ls-files -u one | wc -l)\" &&\n-\ttest 1 -eq \"$(git ls-files -u two | wc -l)\" &&\n-\ttest 1 -eq \"$(git ls-files -u original | wc -l)\" &&\n-\ttest 0 -eq \"$(git ls-files -o | wc -l)\" &&\n+\tgit ls-files -u >output &&\n+\ttest_line_count = 3 output &&\n+\tgit ls-files -u one >output &&\n+\ttest_line_count = 1 output &&\n+\tgit ls-files -u two >output &&\n+\ttest_line_count = 1 output &&\n+\tgit ls-files -u original >output &&\n+\ttest_line_count = 1 output &&\n+\tgit ls-files -o >output &&\n+\ttest_line_count = 1 output &&\n+\trm -f output &&\n \n \ttest_path_is_file one &&\n \ttest_path_is_file two &&\n@@ -861,8 +912,11 @@ test_expect_success 'setup merge of rename + small change' '\n test_expect_success 'merge rename + small change' '\n \tgit merge rename_branch &&\n \n-\ttest 1 -eq $(git ls-files -s | wc -l) &&\n-\ttest 0 -eq $(git ls-files -o | wc -l) &&\n+\tgit ls-files -s >output &&\n+\ttest_line_count = 1 output &&\n+\tgit ls-files -o >output &&\n+\ttest_line_count = 1 output &&\n+\trm -f output &&\n \ttest $(git rev-parse HEAD:renamed_file) = $(git rev-parse HEAD~1:file)\n '\n \n-- \n2.31.1.192.g0881477623\n\n"},{"id":"422586","messageId":"87czun3en0.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"YIAAzJTG1UitiWyu@danh.dev","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:18:11Z","receivedAt":"2021-04-21T14:18:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Apr 21 2021, Đoàn Trần Công Danh wrote:\n\n> On 2021-04-21 10:46:08+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>> \n>> On Wed, Apr 21 2021, Junio C Hamano wrote:\n>> \n>> > Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>> >\n>> >> These will only match the simplistic forms of `test -X blah` (where\n>> >> \"-X\" is some single letter option), but will miss expressions such as\n>> >> `test \"$foo\" = bar`. We stop at \"&\" or \"|\" to try not to overmatch\n>> >> things like:\n>> >>\n>> >>     test whatever && ls -a foo\n>> >>     test whatever && foo -o outfile\n>> >\n>> > I still do not understand why you have to insist on dashed operator\n>> > as the first thing given to \"test\", like this:\n>> >\n>> >> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-a\\s+/ and err '\"test A && test B\" ...\n>> >> +\t/\\btest\\s+-[a-z]\\s+[^&|]+\\s+-o\\s+/ and err '\"test A || test B\" ...\n>> >\n>> > IOW, what over-matching would we get if we simplified the condition\n>> > like so?\n>> >\n>> >     /\\btest\\s+[^&|]+\\s+-a\\s/\n>> >     /\\btest\\s+[^&|]+\\s+-o\\s/\n>> >\n>> > The one in the patch would miss things like\n>> >\n>> > \ttest \"$a\" = \"$b\" -o \"$a\" -lt \"$b\"\n>> > \ttest \"$n\" -a \"$n\" -lt 4\n>> >\n>> > but the only thing that we care about is that a command that started\n>> > with \"test \" has \"-a\" or \"-o\" before we see \"&\" or \"|\", no?\n>> \n>> Applying your suggestion results in these false positives:\n>> \t\n>> \tt4038-diff-combined.sh:135: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test space change\" -a &&\n>> \tt4038-diff-combined.sh:147: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test other space changes\" -a &&\n>> \tt6400-merge-df.sh:89: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n>> \tt6400-merge-df.sh:91: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n>> \tt6400-merge-df.sh:110: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l)\n>> \tt6400-merge-df.sh:112: error: \"test A || test B\" preferred to \"test A -o B\": test 1 -eq $(git ls-files -o | wc -l)\n>> \tt6402-merge-rename.sh:639: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\"\n>> \tt6402-merge-rename.sh:646: error: \"test A || test B\" preferred to \"test A -o B\": test 2 -eq \"$(git ls-files -o | wc -l)\"\n>> \tt6402-merge-rename.sh:686: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq \"$(git ls-files -o | wc -l)\" &&\n>> \tt6402-merge-rename.sh:865: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l) &&\n>\n> With: 7dbe8c8003, (check-non-portable-shell.pl: `wc -l` may have\n> leading WS, 2017-12-21)\n> Unless the situation has been changed, since.\n> I think those tests with quoted \"$(.. | wc -l)\" has been deemed\n> unportable and should be replaced with test_line_count anyway?\n> Does \"test -eq\" strip spaces from integer strings?\n>\n> And I think we're working on moving \"git\" command to its own commmand\n> instead of put it in the left of a pipe.\n>\n> 2 followed patch will clean them out\n\nI think those patches are good in their own right, i.e. replacing things\nwith more incremental helpers and test_cmp-like functions.\n\nBut I believe the code you're changing is not non-portable. It was using\nthe output of \"wc -l\" with the \"=\" operator that wasn't portable.\n\nThese ones are all occurances that use \"-eq\".\n\nAnd:\n\n    test \"0\" -eq \" 0\"\n\netc., is true, which is why these pass on OSX and beyond.\n\n"},{"id":"422590","messageId":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com","subject":"[PATCH v2 0/5] test-lib-functions.sh: trickery to make -x less verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:33Z","receivedAt":"2021-04-21T14:58:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series makes the \"-x\" output less verbose for our various helper\nfunctions, mainly using the trickery of feeding \"$@\" to \"test\" to rely\non it to die when given too many arguments.\n\nSince v2[1] I ejected the patch to make the \"test_line_count\" function\nunsafer per Junio's feedback.\n\nThe test_file_size has lost its \"BUG\" invocation, but is now safe as\nwe do that check in the test helper, as shown in 5/5 we fixed one\nprevious mild regression while doing that.\n\nThe 3-4/5 patches are just trivial \"while we're at it\" work.\n\n1. http://lore.kernel.org/git/cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com\n\nÆvar Arnfjörð Bjarmason (5):\n  test-lib-functions: normalize test_path_is_missing() debugging\n  Revert and amend \"test-lib-functions: assert correct parameter count\"\n  test helpers: remove unused test-tool path-utils slice-tests\n  test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"\n  test-helpers: split \"file-size\" into \"file-size(s)\"\n\n t/helper/test-path-utils.c  | 44 ++++++------------------\n t/t0060-path-utils.sh       |  2 +-\n t/t1050-large.sh            |  2 +-\n t/t5319-multi-pack-index.sh |  6 ++--\n t/test-lib-functions.sh     | 67 ++++++++++++++++---------------------\n 5 files changed, 45 insertions(+), 76 deletions(-)\n\nRange-diff against v1:\n1:  fd33f6d71f0 = 1:  ba9d6251ad5 test-lib-functions: normalize test_path_is_missing() debugging\n2:  67ddd821dfa = 2:  5f8e5ad27f5 Revert and amend \"test-lib-functions: assert correct parameter count\"\n3:  8fd51861b59 < -:  ----------- test-lib-functions: remove last two parameter count assertions\n-:  ----------- > 3:  44948c6ace9 test helpers: remove unused test-tool path-utils slice-tests\n-:  ----------- > 4:  ae5dc5d03b3 test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"\n-:  ----------- > 5:  947791d9535 test-helpers: split \"file-size\" into \"file-size(s)\"\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422591","messageId":"patch-2.5-5f8e5ad27f5-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v2 2/5] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:35Z","receivedAt":"2021-04-21T14:58:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This reverts and amends my my own e7884b353b7 (test-lib-functions:\nassert correct parameter count, 2021-02-12) in order to improve the -x\noutput.\n\nThe goal here is to get rid of the verbosity of having e.g. a \"test 2\n-ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\nto intentionally feed the \"test\" operator too many arguments if the\nfunctions are called with too many arguments, thus piggy-backing on it\nto check the number of arguments we get.\n\nBefore this for each test_cmp invocation we'd emit:\n\n    + test_cmp expect actual\n    + test 2 -ne 2\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThat \"test 2 -ne 2\" line is new in my e7884b353b7. As noted in\n45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\nhelper param, 2021-02-12) we had buggy invocations of some of these\nfunctions with too many parameters.\n\nNow we'll get just:\n\n    + test_cmp expect actual\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThis does not to the \"right\" thing in cases like:\n\n    test_path_is_file x -a y\n\nWhich will now turn into:\n\n    test -f x -a y\n\nI consider that to be OK given the trade-off that any extra checking\nwould produce more verbose trace output. As shown in 45a2686441b we\nhad issues with these functions being invoked with multiple\nparameters (e.g. a glob) by accident, we don't need to be paranoid in\nguarding against hostile misuse from our own test suite.\n\nWhile I'm at it change a few functions that relied on a \"false\" being\nthe last statement in the function to use an explicit \"return 1\" like\nthe other functions in this file.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 59 +++++++++++++++++++----------------------\n 1 file changed, 28 insertions(+), 31 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 0232cc9f46d..f8f5bf9de1e 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -756,41 +756,43 @@ test_external_without_stderr () {\n }\n \n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n-# The commands test the existence or non-existence of $1\n+# The commands test the existence or non-existence of\n+# a given argument.\n+#\n+# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n+# are counting on \"test\" to error on too many arguments if more than\n+# one is given. Checking \"$#\" explicitly would lead to overly verbose\n+# -x output.\n test_path_is_file () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -f \"$1\"\n+\tif ! test -f \"$@\"\n \tthen\n-\t\techo \"File $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"File $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_dir () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -d \"$1\"\n+\tif ! test -d \"$@\"\n \tthen\n-\t\techo \"Directory $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Directory $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_exists () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -e \"$1\"\n+\tif ! test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Path $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n # Check if the directory exists and is empty as expected, barf otherwise.\n test_dir_is_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\ttest_path_is_dir \"$@\" &&\n+\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n \tthen\n-\t\techo \"Directory '$1' is not empty, it contains:\"\n+\t\techo \"Directory '$*' is not empty, it contains:\"\n \t\tls -la \"$1\"\n \t\treturn 1\n \tfi\n@@ -798,19 +800,17 @@ test_dir_is_empty () {\n \n # Check if the file exists and has a size greater than zero\n test_file_not_empty () {\n-\ttest \"$#\" = 2 && BUG \"2 param\"\n-\tif ! test -s \"$1\"\n+\tif ! test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not a non-empty file.\"\n-\t\tfalse\n+\t\techo \"'$*' is not a non-empty file.\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_missing () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif test -e \"$1\"\n+\tif test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 exists!\"\n+\t\techo \"Path $* exists!\"\n \t\tfalse\n \tfi\n }\n@@ -1012,7 +1012,6 @@ test_expect_code () {\n # - not all diff versions understand \"-u\"\n \n test_cmp () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \teval \"$GIT_TEST_CMP\" '\"$@\"'\n }\n \n@@ -1042,7 +1041,6 @@ test_cmp_config () {\n # test_cmp_bin - helper to compare binary files\n \n test_cmp_bin () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \tcmp \"$@\"\n }\n \n@@ -1103,12 +1101,11 @@ verbose () {\n # otherwise.\n \n test_must_be_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_file \"$1\" &&\n-\tif test -s \"$1\"\n+\ttest_path_is_file \"$@\" &&\n+\tif test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not empty, it contains:\"\n-\t\tcat \"$1\"\n+\t\techo \"'$*' is not empty, it contains:\"\n+\t\tcat \"$@\"\n \t\treturn 1\n \tfi\n }\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422592","messageId":"patch-1.5-ba9d6251ad5-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v2 1/5] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:34Z","receivedAt":"2021-04-21T14:58:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test_path_is_missing() to be consistent with related\nfunctions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to\ntest [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\necho-ing $* if it exists. Let's just say that it exists instead.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex bd64a15c731..0232cc9f46d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -810,12 +810,7 @@ test_path_is_missing () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \tif test -e \"$1\"\n \tthen\n-\t\techo \"Path exists:\"\n-\t\tls -ld \"$1\"\n-\t\tif test $# -ge 1\n-\t\tthen\n-\t\t\techo \"$*\"\n-\t\tfi\n+\t\techo \"Path $1 exists!\"\n \t\tfalse\n \tfi\n }\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422593","messageId":"patch-3.5-44948c6ace9-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v2 3/5] test helpers: remove unused test-tool path-utils slice-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:36Z","receivedAt":"2021-04-21T14:58:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This utility was last used in the code removed in 4c2c38e800f (ci:\nmodification of main.yml to use cmake for vs-build job,\n2020-06-26). Let's also remove this now-dead code.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-path-utils.c | 31 -------------------------------\n 1 file changed, 31 deletions(-)\n\ndiff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c\nindex 313a153209c..3d7c0f1d19d 100644\n--- a/t/helper/test-path-utils.c\n+++ b/t/helper/test-path-utils.c\n@@ -177,14 +177,6 @@ static int is_dotgitmodules(const char *path)\n \treturn is_hfs_dotgitmodules(path) || is_ntfs_dotgitmodules(path);\n }\n \n-static int cmp_by_st_size(const void *a, const void *b)\n-{\n-\tintptr_t x = (intptr_t)((struct string_list_item *)a)->util;\n-\tintptr_t y = (intptr_t)((struct string_list_item *)b)->util;\n-\n-\treturn x > y ? -1 : (x < y ? +1 : 0);\n-}\n-\n /*\n  * A very simple, reproducible pseudo-random generator. Copied from\n  * `test-genrandom.c`.\n@@ -428,29 +420,6 @@ int cmd__path_utils(int argc, const char **argv)\n \t\treturn 0;\n \t}\n \n-\tif (argc > 5 && !strcmp(argv[1], \"slice-tests\")) {\n-\t\tint res = 0;\n-\t\tlong offset, stride, i;\n-\t\tstruct string_list list = STRING_LIST_INIT_NODUP;\n-\t\tstruct stat st;\n-\n-\t\toffset = strtol(argv[2], NULL, 10);\n-\t\tstride = strtol(argv[3], NULL, 10);\n-\t\tif (stride < 1)\n-\t\t\tstride = 1;\n-\t\tfor (i = 4; i < argc; i++)\n-\t\t\tif (stat(argv[i], &st))\n-\t\t\t\tres = error_errno(\"Cannot stat '%s'\", argv[i]);\n-\t\t\telse\n-\t\t\t\tstring_list_append(&list, argv[i])->util =\n-\t\t\t\t\t(void *)(intptr_t)st.st_size;\n-\t\tQSORT(list.items, list.nr, cmp_by_st_size);\n-\t\tfor (i = offset; i < list.nr; i+= stride)\n-\t\t\tprintf(\"%s\\n\", list.items[i].string);\n-\n-\t\treturn !!res;\n-\t}\n-\n \tif (argc > 1 && !strcmp(argv[1], \"protect_ntfs_hfs\"))\n \t\treturn !!protect_ntfs_hfs_benchmark(argc - 1, argv + 1);\n \n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422594","messageId":"patch-4.5-ae5dc5d03b3-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v2 4/5] test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:37Z","receivedAt":"2021-04-21T14:58:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename this utility added in d2c84dad1c8 (mingw: refuse to access\npaths with trailing spaces or periods, 2019-09-05) to make it clear\nthat it expects N number of arguments, and for consistency with\ndc2d9ba3187 (is_{hfs,ntfs}_dotgitmodules: add tests, 2018-05-12).\n\nLet's also make it a dashed \"is-valid-paths\" instead of\n\"is_valid_path*\" to make it easier to grep the helper v.s. the C\nfunction it calls.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-path-utils.c | 2 +-\n t/t0060-path-utils.sh      | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c\nindex 3d7c0f1d19d..af7d7fd5454 100644\n--- a/t/helper/test-path-utils.c\n+++ b/t/helper/test-path-utils.c\n@@ -423,7 +423,7 @@ int cmd__path_utils(int argc, const char **argv)\n \tif (argc > 1 && !strcmp(argv[1], \"protect_ntfs_hfs\"))\n \t\treturn !!protect_ntfs_hfs_benchmark(argc - 1, argv + 1);\n \n-\tif (argc > 1 && !strcmp(argv[1], \"is_valid_path\")) {\n+\tif (argc > 1 && !strcmp(argv[1], \"is-valid-paths\")) {\n \t\tint res = 0, expect = 1, i;\n \n \t\tfor (i = 2; i < argc; i++)\ndiff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh\nindex 0ff06b5d1b3..e7fb748b19c 100755\n--- a/t/t0060-path-utils.sh\n+++ b/t/t0060-path-utils.sh\n@@ -469,7 +469,7 @@ test_expect_success 'match .gitmodules' '\n '\n \n test_expect_success MINGW 'is_valid_path() on Windows' '\n-\ttest-tool path-utils is_valid_path \\\n+\ttest-tool path-utils is-valid-paths \\\n \t\twin32 \\\n \t\t\"win32 x\" \\\n \t\t../hello.txt \\\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422595","messageId":"patch-5.5-947791d9535-20210421T144921Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v2 5/5] test-helpers: split \"file-size\" into \"file-size(s)\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T14:58:38Z","receivedAt":"2021-04-21T14:58:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Split the \"file-size\" helper into two helpers, one that takes 1\nargument, and another one that takes N.\n\nThis allows us to remove the \"BUG\" check in test-lib-functions.sh for\nbriefer -x output, and more importantly will clearly distinguish those\ncases where we expect one argument v.s. many.\n\nThe use in t1050-large.sh wants to check just one pack, we used to\ncheck that explicitly before 53b67a801bb (tests: consolidate the\n`file_size` function into `test-lib-functions.sh`, 2020-11-07), now we\ndo so again.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-path-utils.c  | 11 ++++++++++-\n t/t1050-large.sh            |  2 +-\n t/t5319-multi-pack-index.sh |  6 +++---\n t/test-lib-functions.sh     |  3 +--\n 4 files changed, 15 insertions(+), 7 deletions(-)\n\ndiff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c\nindex af7d7fd5454..23970db8183 100644\n--- a/t/helper/test-path-utils.c\n+++ b/t/helper/test-path-utils.c\n@@ -272,6 +272,8 @@ static int protect_ntfs_hfs_benchmark(int argc, const char **argv)\n \n int cmd__path_utils(int argc, const char **argv)\n {\n+\tint is_file_size, is_file_sizes;\n+\n \tif (argc == 3 && !strcmp(argv[1], \"normalize_path_copy\")) {\n \t\tchar *buf = xmallocz(strlen(argv[2]));\n \t\tint rv = normalize_path_copy(buf, argv[2]);\n@@ -387,10 +389,17 @@ int cmd__path_utils(int argc, const char **argv)\n \t\treturn !!res;\n \t}\n \n-\tif (argc > 2 && !strcmp(argv[1], \"file-size\")) {\n+\tis_file_size = !strcmp(argv[1], \"file-size\");\n+\tis_file_sizes = !strcmp(argv[1], \"file-sizes\");\n+\tif (argc > 2 && (is_file_size || is_file_sizes)) {\n \t\tint res = 0, i;\n \t\tstruct stat st;\n \n+\t\tif (is_file_size && argc > 3) {\n+\t\t\tres = error(\"too many arguments to is-file-size, use is-file-sizes?\");\n+\t\t\treturn res;\n+\t\t}\n+\n \t\tfor (i = 2; i < argc; i++)\n \t\t\tif (stat(argv[i], &st))\n \t\t\t\tres = error_errno(\"Cannot stat '%s'\", argv[i]);\ndiff --git a/t/t1050-large.sh b/t/t1050-large.sh\nindex 4bab6a513c5..0b76ab0e3f9 100755\n--- a/t/t1050-large.sh\n+++ b/t/t1050-large.sh\n@@ -23,7 +23,7 @@ do\n \ttest_expect_success \"add with $config\" '\n \t\ttest_when_finished \"rm -f .git/objects/pack/pack-*.* .git/index\" &&\n \t\tgit $config add large1 &&\n-\t\tsz=$(test_file_size .git/objects/pack/pack-*.pack) &&\n+\t\tsz=$(test-tool path-utils file-size .git/objects/pack/pack-*.pack) &&\n \t\tcase \"$expect\" in\n \t\tsmall) test \"$sz\" -le 100000 ;;\n \t\tlarge) test \"$sz\" -ge 100000 ;;\ndiff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh\nindex 5641d158dfc..baeda407b90 100755\n--- a/t/t5319-multi-pack-index.sh\n+++ b/t/t5319-multi-pack-index.sh\n@@ -648,7 +648,7 @@ test_expect_success 'repack with minimum size does not alter existing packs' '\n \t\ttest-tool chmtime =-3 .git/objects/pack/pack-B* &&\n \t\ttest-tool chmtime =-2 .git/objects/pack/pack-A* &&\n \t\tls .git/objects/pack >expect &&\n-\t\tMINSIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 1) &&\n+\t\tMINSIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | head -n 1) &&\n \t\tgit multi-pack-index repack --batch-size=$MINSIZE &&\n \t\tls .git/objects/pack >actual &&\n \t\ttest_cmp expect actual\n@@ -672,7 +672,7 @@ test_expect_success 'repack respects repack.packKeptObjects=false' '\n \t\ttest_line_count = 5 idx-list &&\n \t\ttest-tool read-midx .git/objects | grep idx >midx-list &&\n \t\ttest_line_count = 5 midx-list &&\n-\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | sed -n 3p) &&\n+\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | sed -n 3p) &&\n \t\tBATCH_SIZE=$((THIRD_SMALLEST_SIZE + 1)) &&\n \t\tgit multi-pack-index repack --batch-size=$BATCH_SIZE &&\n \t\tls .git/objects/pack/*idx >idx-list &&\n@@ -687,7 +687,7 @@ test_expect_success 'repack creates a new pack' '\n \t\tcd dup &&\n \t\tls .git/objects/pack/*idx >idx-list &&\n \t\ttest_line_count = 5 idx-list &&\n-\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&\n+\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&\n \t\tBATCH_SIZE=$(($THIRD_SMALLEST_SIZE + 1)) &&\n \t\tgit multi-pack-index repack --batch-size=$BATCH_SIZE &&\n \t\tls .git/objects/pack/*idx >idx-list &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex f8f5bf9de1e..20d1f94fd97 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -839,8 +839,7 @@ test_line_count () {\n }\n \n test_file_size () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest-tool path-utils file-size \"$1\"\n+\ttest-tool path-utils file-size \"$@\"\n }\n \n # Returns success if a comma separated string of keywords ($1) contains a\n-- \n2.31.1.721.gbeb6a21927\n\n"},{"id":"422599","messageId":"xmqqmttrzjhw.fsf@gitster.g","threadId":"55480","inReplyTo":"87czun3en0.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-21T16:32:11Z","receivedAt":"2021-04-21T16:32:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>>> \tt6402-merge-rename.sh:865: error: \"test A || test B\" preferred to \"test A -o B\": test 0 -eq $(git ls-files -o | wc -l) &&\n>>\n>> With: 7dbe8c8003, (check-non-portable-shell.pl: `wc -l` may have\n> ...\n> I think those patches are good in their own right, i.e. replacing things\n> with more incremental helpers and test_cmp-like functions.\n>\n> But I believe the code you're changing is not non-portable. It was using\n> the output of \"wc -l\" with the \"=\" operator that wasn't portable.\n\nNot necessarily.  The last one shown above\n\n\ttest 0 -eq $(git ls-files -o | wc -l) &&\n\nis still valid and correct with s/-eq/=/.  It lets shell to remove\nexcess whitespaces around output from some implementations of \"wc\",\nso textual '=' is perfectly fine.\n\n> These ones are all occurances that use \"-eq\".\n>\n> And:\n>\n>     test \"0\" -eq \" 0\"\n>\n> etc., is true, which is why these pass on OSX and beyond.\n\nPerhaps, but I am not sure how portable it is to rely on \"-eq\"\nignoring the leading whitespaces.\n\nA more conventional (read: time tested) way is to $(... | wc -l)\n*NOT* enclosed inside dq, so that the shell will strip out any\nexcess spaces around it, and use '=', i.e.\n\n    test 3 = $(... | wc -l)\n\nand that is what we end up evaluating when we write\n\n    test_line_count = 3 file\n\nThis does rely on that \"wc -l\" will run and produce _some_ output to\nbe syntactically correct, though.\n"},{"id":"422601","messageId":"20210421164357.GZ2947267@szeder.dev","threadId":"55480","inReplyTo":"patch-11.11-311a9dba36-20210421T101156Z-avarab@gmail.com","subject":"Re: [PATCH v4 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2021-04-21T16:43:57Z","receivedAt":"2021-04-21T16:44:10Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Wed, Apr 21, 2021 at 12:15:16PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>  5. Since we don't need to move the .git/hooks directory we don't need\n\nAgain: Since we don't need to change directories....\n\n>     the subshell here either.\n> \n>     See 0d314ce834 for when the subshell use got introduced for the\n>     convenience of not having to \"cd\" back and forth while setting up\n>     the hooks.\n\nI think this is worse and even more misleading than even v2 was, for\nthe reasons I mentioned earlier.\n\n"},{"id":"422602","messageId":"CAPig+cSh6VNpWbGPpTqY0rmw7zf9s-kSXSOMYvW94UHOF7t80w@mail.gmail.com","threadId":"55480","inReplyTo":"20210421104102.3409-2-congdanhqx@gmail.com","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-21T16:55:01Z","receivedAt":"2021-04-21T16:55:14Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Apr 21, 2021 at 6:41 AM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n> We will lose the exit status of \"git ls-files\" if it's being run in\n> anywhere-but-not-final part of a pipe.\n>\n> Let's send the output of \"git ls-files\" to a file first,\n> and adjust the expected result for \"git ls-files -o\" since a new\n> untracked file will be created as a side effect.\n>\n> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> ---\n> diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh\n> @@ -631,20 +663,33 @@ test_expect_success 'check handling of differently renamed file with D/F conflic\n> -               test 5 -eq \"$(git ls-files -s | wc -l)\" &&\n> -               test 3 -eq \"$(git ls-files -u | wc -l)\" &&\n> -               test 1 -eq \"$(git ls-files -u one~HEAD | wc -l)\" &&\n> +               git ls-files -s >output &&\n> +               test_line_count = 5 output &&\n> +               git ls-files -u >output &&\n> +               test_line_count = 3 output &&\n> +               git ls-files -u one~HEAD >output &&\n> +               test_line_count = 1 output &&\n\nThis idiom crops up so frequently in this test script that it almost\nbegs for the introduction of a helper function rather than applying\nthe manual transformation repeatedly. For instance, the helper might\nbe called like this:\n\n    count_ls_files 5 -s &&\n    count_ls_files 3 -u &&\n    count_ls_files 1 -u one~HEAD &&\n    ...\n\nThe nice thing about having a helper function is that it can clean up\nafter itself by not leaving a new file lying around, thus you wouldn't\nhave to make adjustments to the expected number of untracked files (as\nmentioned in the commit message). If this is the sort of thing which\ncomes up often enough (if there are more such cases beyond the two\nscripts you changed in this series), then it might make sense to\npromote the helper function to test-lib-functions.sh.\n"},{"id":"422608","messageId":"CAPig+cS4tkXZLPDEWgEytzEOCR7oGrXyg1CZVKVPSXuJOifLjQ@mail.gmail.com","threadId":"55480","inReplyTo":"CAPig+cSh6VNpWbGPpTqY0rmw7zf9s-kSXSOMYvW94UHOF7t80w@mail.gmail.com","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-21T17:32:32Z","receivedAt":"2021-04-21T17:32:46Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>     count_ls_files 5 -s &&\n>     count_ls_files 3 -u &&\n>     count_ls_files 1 -u one~HEAD &&\n>     ...\n>\n> The nice thing about having a helper function is that it can clean up\n> after itself by not leaving a new file lying around, thus you wouldn't\n> have to make adjustments to the expected number of untracked files (as\n> mentioned in the commit message). If this is the sort of thing which\n> comes up often enough (if there are more such cases beyond the two\n> scripts you changed in this series), then it might make sense to\n> promote the helper function to test-lib-functions.sh.\n\nThe frequency with which this idiom crops up with commands beyond\ngit-ls-files suggests the more general solution of supporting it\ndirectly in test-lib-functions.sh for any command. For instance:\n\n    test_cmd_line_count = 3 git ls-files -u &&\n\nOr, perhaps, a new mode of test_line_count():\n\n    test_line_count = 3 -c git ls-files -u &&\n"},{"id":"422611","messageId":"87a6pr349d.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"patch-3.5-44948c6ace9-20210421T144921Z-avarab@gmail.com","subject":"Re: [PATCH v2 3/5] test helpers: remove unused test-tool path-utils slice-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-21T18:02:22Z","receivedAt":"2021-04-21T18:02:32Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Apr 21 2021, Ævar Arnfjörð Bjarmason wrote:\n\n> This utility was last used in the code removed in 4c2c38e800f (ci:\n> modification of main.yml to use cmake for vs-build job,\n> 2020-06-26). Let's also remove this now-dead code.\n\nThis patch needs to be dropped, turns out it's used outside of t/ in\nci/, didn't think to grep for test helpers there. Will hold off on a\nre-roll for a bit pending further feedback.\n\nJunio, unless you'd like to have it sooner than later?\n"},{"id":"422621","messageId":"xmqqtunzxy95.fsf@gitster.g","threadId":"55480","inReplyTo":"87r1j42ffz.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3 01/12] check-non-portable-shell: check for \"test <cond> -a/-o <cond>\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-21T18:56:22Z","receivedAt":"2021-04-21T18:56:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Applying your suggestion results in these false positives:\n> \t\n> \tt4038-diff-combined.sh:135: error: \"test A && test B\" preferred to \"test A -a B\": git commit -m \"test space change\" -a &&\n\nThis is utterly amusing.  Consider the suggestion withdrawn.\n"},{"id":"422644","messageId":"xmqq5z0fxlgn.fsf@gitster.g","threadId":"55480","inReplyTo":"CAPig+cS4tkXZLPDEWgEytzEOCR7oGrXyg1CZVKVPSXuJOifLjQ@mail.gmail.com","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-21T23:32:40Z","receivedAt":"2021-04-21T23:32:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>>     count_ls_files 5 -s &&\n>>     count_ls_files 3 -u &&\n>>     count_ls_files 1 -u one~HEAD &&\n>>     ...\n>>\n>> The nice thing about having a helper function is that it can clean up\n>> after itself by not leaving a new file lying around, thus you wouldn't\n>> have to make adjustments to the expected number of untracked files (as\n>> mentioned in the commit message). If this is the sort of thing which\n>> comes up often enough (if there are more such cases beyond the two\n>> scripts you changed in this series), then it might make sense to\n>> promote the helper function to test-lib-functions.sh.\n>\n> The frequency with which this idiom crops up with commands beyond\n> git-ls-files suggests the more general solution of supporting it\n> directly in test-lib-functions.sh for any command. For instance:\n>\n>     test_cmd_line_count = 3 git ls-files -u &&\n>\n> Or, perhaps, a new mode of test_line_count():\n>\n>     test_line_count = 3 -c git ls-files -u &&\n\nThat looks nice on paper, but may be going too far.\n\nWe may want to count the lines in the error message, or we may want\nto count the lines after filtering the output with pipe.\n\nA test file that is dedicated to test ls-files with a file local\nhelper \"count_ls_files\" smells like a better place to stop, at least\nto me.\n"},{"id":"422677","messageId":"87v98e1oj7.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"20210421164357.GZ2947267@szeder.dev","subject":"Re: [PATCH v4 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-22T12:39:40Z","receivedAt":"2021-04-22T12:40:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Apr 21 2021, SZEDER Gábor wrote:\n\n> On Wed, Apr 21, 2021 at 12:15:16PM +0200, Ævar Arnfjörð Bjarmason wrote:\n>>  5. Since we don't need to move the .git/hooks directory we don't need\n>\n> Again: Since we don't need to change directories....\n>\n>>     the subshell here either.\n>> \n>>     See 0d314ce834 for when the subshell use got introduced for the\n>>     convenience of not having to \"cd\" back and forth while setting up\n>>     the hooks.\n>\n> I think this is worse and even more misleading than even v2 was, for\n> the reasons I mentioned earlier.\n\nBetween this & the thread at\nhttp://lore.kernel.org/git/20210420212731.GY2947267@szeder.dev I'm not\nsure what wording you'd be OK with, would you mind suggesting an\nalternative?\n\nAs far as I can see it's some subtlety of how we explain the cd-ing &\nsubshelling we did as a combination of eedf8f97e58 (Abstract\ntest_create_repo out for use in tests., 2006-02-17) and my 0d314ce834d\n(test-lib: use subshell instead of cd $new && .. && cd $old,\n2010-08-30).\n\nMaybe you'd be happy with this:\n\n    In the code being removed here we both \"cd\"'d to the repository\n    before calling \"init\", and did so in a subshell. It's not important\n    to do either, so both of those can be removed. We cd'd because this\n    code grew from test-lib.sh code where we'd have done so already, see\n    0d314ce834d, and later \"cd\"'d inside a subshell since 0d314ce834d to\n    avoid having to keep track of an \"old pwd\" variable to cd back after\n    the setup.\n\n    Being in the repository directory made moving the hooks around\n    easier (we wouldn't have to fully qualify the path), but since we're\n    not moving the hooks anymore we don't need it for that reason\n    either.\n\n?\n"},{"id":"422678","messageId":"87sg3i1o9c.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"CAPig+cSh6VNpWbGPpTqY0rmw7zf9s-kSXSOMYvW94UHOF7t80w@mail.gmail.com","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-22T12:45:35Z","receivedAt":"2021-04-22T12:45:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Apr 21 2021, Eric Sunshine wrote:\n\n> On Wed, Apr 21, 2021 at 6:41 AM Đoàn Trần Công Danh\n> <congdanhqx@gmail.com> wrote:\n>> We will lose the exit status of \"git ls-files\" if it's being run in\n>> anywhere-but-not-final part of a pipe.\n>>\n>> Let's send the output of \"git ls-files\" to a file first,\n>> and adjust the expected result for \"git ls-files -o\" since a new\n>> untracked file will be created as a side effect.\n>>\n>> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n>> ---\n>> diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh\n>> @@ -631,20 +663,33 @@ test_expect_success 'check handling of differently renamed file with D/F conflic\n>> -               test 5 -eq \"$(git ls-files -s | wc -l)\" &&\n>> -               test 3 -eq \"$(git ls-files -u | wc -l)\" &&\n>> -               test 1 -eq \"$(git ls-files -u one~HEAD | wc -l)\" &&\n>> +               git ls-files -s >output &&\n>> +               test_line_count = 5 output &&\n>> +               git ls-files -u >output &&\n>> +               test_line_count = 3 output &&\n>> +               git ls-files -u one~HEAD >output &&\n>> +               test_line_count = 1 output &&\n>\n> This idiom crops up so frequently in this test script that it almost\n> begs for the introduction of a helper function rather than applying\n> the manual transformation repeatedly. For instance, the helper might\n> be called like this:\n>\n>     count_ls_files 5 -s &&\n>     count_ls_files 3 -u &&\n>     count_ls_files 1 -u one~HEAD &&\n>     ...\n>\n> The nice thing about having a helper function is that it can clean up\n> after itself by not leaving a new file lying around, thus you wouldn't\n> have to make adjustments to the expected number of untracked files (as\n> mentioned in the commit message). If this is the sort of thing which\n> comes up often enough (if there are more such cases beyond the two\n> scripts you changed in this series), then it might make sense to\n> promote the helper function to test-lib-functions.sh.\n\nAgreed, but I'd saythat it makes more sense to have something like:\n\n\ttest_line_count = 1 -- git ls-files\n\nOr maybe another function, but in any case not something specific to\nls-files, but just a wrapper like the various \"$@\" wrappers in\ntest-lib-functions.sh to count the lines emitted by an arbitrary\ncommand.\n\nIt would also leave things open for:\n\n    test_line_count --stout=1 --stderr=2 -- git ls-files\n    test_line_count --combined=3 -- git ls-files\n\nOr whatever, to count the different output streams.\n\n"},{"id":"422680","messageId":"YIF+0BZGwpMMI1pf@danh.dev","threadId":"55480","inReplyTo":"xmqq5z0fxlgn.fsf@gitster.g","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-22T13:49:04Z","receivedAt":"2021-04-22T13:49:09Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-21 16:32:40-0700, Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n> \n> > On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> >>     count_ls_files 5 -s &&\n> >>     count_ls_files 3 -u &&\n> >>     count_ls_files 1 -u one~HEAD &&\n> >>     ...\n> >>\n> >> The nice thing about having a helper function is that it can clean up\n> >> after itself by not leaving a new file lying around, thus you wouldn't\n> >> have to make adjustments to the expected number of untracked files (as\n> >> mentioned in the commit message). If this is the sort of thing which\n> >> comes up often enough (if there are more such cases beyond the two\n> >> scripts you changed in this series), then it might make sense to\n> >> promote the helper function to test-lib-functions.sh.\n> >\n> > The frequency with which this idiom crops up with commands beyond\n> > git-ls-files suggests the more general solution of supporting it\n> > directly in test-lib-functions.sh for any command. For instance:\n> >\n> >     test_cmd_line_count = 3 git ls-files -u &&\n> >\n> > Or, perhaps, a new mode of test_line_count():\n> >\n> >     test_line_count = 3 -c git ls-files -u &&\n\nHm, I'm not sure how would we implement such mode:\n\n* Will we run such command in a subprocess and and pipe to \"wc -l\"\n  directly to avoid a temporary file, but we will lose the exit code\n  of running command in process?\n* Will we run in a separated chain? Thus, a temporary file would be\n  created, skimming over test-lib-functions.sh, I couldn't find any\n  convention for creating such files, except for specific use cases,\n  let's say \"*.config\".\n* Another clever hacks that I don't know *shrug*\n\n> \n> That looks nice on paper, but may be going too far.\n> \n> We may want to count the lines in the error message,\n\nLet's assume that we solve above puzzle.\n\nCount the lines in the error messages is not too hard to be imagined,\nlet's say by -c2 or something like that.\n\n> or we may want\n> to count the lines after filtering the output with pipe.\n\nHowever, when it involved a pipe, things becomes complicated.\n\n> A test file that is dedicated to test ls-files with a file local\n> helper \"count_ls_files\" smells like a better place to stop, at least\n> to me.\n\nHence, I'll stick with local help \"count_ls_files\" for now.\n\n-- \nDanh\n"},{"id":"422681","messageId":"87pmym1huk.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"YIF+0BZGwpMMI1pf@danh.dev","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-22T15:04:03Z","receivedAt":"2021-04-22T15:04:08Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Apr 22 2021, Đoàn Trần Công Danh wrote:\n\n> On 2021-04-21 16:32:40-0700, Junio C Hamano <gitster@pobox.com> wrote:\n>> Eric Sunshine <sunshine@sunshineco.com> writes:\n>> \n>> > On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> >>     count_ls_files 5 -s &&\n>> >>     count_ls_files 3 -u &&\n>> >>     count_ls_files 1 -u one~HEAD &&\n>> >>     ...\n>> >>\n>> >> The nice thing about having a helper function is that it can clean up\n>> >> after itself by not leaving a new file lying around, thus you wouldn't\n>> >> have to make adjustments to the expected number of untracked files (as\n>> >> mentioned in the commit message). If this is the sort of thing which\n>> >> comes up often enough (if there are more such cases beyond the two\n>> >> scripts you changed in this series), then it might make sense to\n>> >> promote the helper function to test-lib-functions.sh.\n>> >\n>> > The frequency with which this idiom crops up with commands beyond\n>> > git-ls-files suggests the more general solution of supporting it\n>> > directly in test-lib-functions.sh for any command. For instance:\n>> >\n>> >     test_cmd_line_count = 3 git ls-files -u &&\n>> >\n>> > Or, perhaps, a new mode of test_line_count():\n>> >\n>> >     test_line_count = 3 -c git ls-files -u &&\n>\n> Hm, I'm not sure how would we implement such mode:\n>\n> * Will we run such command in a subprocess and and pipe to \"wc -l\"\n>   directly to avoid a temporary file, but we will lose the exit code\n>   of running command in process?\n\nJust use a tempfile.\n\n> * Will we run in a separated chain? Thus, a temporary file would be\n>   created, skimming over test-lib-functions.sh, I couldn't find any\n>   convention for creating such files, except for specific use cases,\n>   let's say \"*.config\".\n\nYeah we happen not to have one of those in test-lib-functions.sh, but a\nbunch of helpers create those.\n\n> * Another clever hacks that I don't know *shrug*\n\n>> \n>> That looks nice on paper, but may be going too far.\n>> \n>> We may want to count the lines in the error message,\n>\n> Let's assume that we solve above puzzle.\n>\n> Count the lines in the error messages is not too hard to be imagined,\n> let's say by -c2 or something like that.\n>\n>> or we may want\n>> to count the lines after filtering the output with pipe.\n>\n> However, when it involved a pipe, things becomes complicated.\n\nYes, there's no portable way to both stream stdout/stderr in the correct\norder and to intercept it. You'd need a mkfifo. See also how the \"--tee\"\nmode works (i.e. they're squashed).\n\n>> A test file that is dedicated to test ls-files with a file local\n>> helper \"count_ls_files\" smells like a better place to stop, at least\n>> to me.\n>\n> Hence, I'll stick with local help \"count_ls_files\" for now.\n\nHere's an implementation that works, sans the fancy opts parsing etc. I\njust use -1 for \"don't care\". You can see \"test_commit\" etc. for how to\ndo that.\n\nIt doesn't emit output, but that's just a matter of re-cat-ing the\nrelevant files.\n\nYes we wouldn't have combined output when you do that, but I don't think\nwe care, you can chain this thing, and most thing that would do so would\nonly care about piping stdout/stderr to their own files anyway, and not\nthat we emit one line of stdout, then another of stderr, another of\nstdout etc.\n\ndiff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh\nindex 425dad97d54..c7251102a3d 100755\n--- a/t/t6402-merge-rename.sh\n+++ b/t/t6402-merge-rename.sh\n@@ -154,14 +154,10 @@ test_expect_success 'pull conflicting renames' \\\n \tgit reset --hard &&\n \tgit show-branch &&\n \ttest_expect_code 1 git pull . blue &&\n-\tgit ls-files -u A >a.stages &&\n-\ttest_line_count = 1 a.stages &&\n-\tgit ls-files -u B >b.stages &&\n-\ttest_line_count = 1 b.stages &&\n-\tgit ls-files -u C >c.stages &&\n-\ttest_line_count = 1 c.stages &&\n-\tgit ls-files -s N >n.stages &&\n-\ttest_line_count = 1 n.stages &&\n+\ttest_line_count_command = 1 0 git ls-files -u A &&\n+\ttest_line_count_command = 1 0 git ls-files -u B &&\n+\ttest_line_count_command = 1 0 git ls-files -u C &&\n+\ttest_line_count_command = 1 0 git ls-files -s N &&\n \tsed -ne \"/^g/{\n \tp\n \tq\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex b823c140271..10e3cbe0d47 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -817,6 +817,24 @@ test_line_count () {\n \tfi\n }\n \n+test_line_count_command () {\n+\tlocal op=$1\n+\tlocal ocnt=$2\n+\tlocal ecnt=$3\n+\tshift 3\n+\t\"$@\" 2>cnt.err >cnt.out\n+\tlocal exit_code=$?\n+\tif test \"$ocnt\" -gt -1\n+\tthen\n+\t\ttest_line_count \"$op\" \"$ocnt\" cnt.out\n+\tfi &&\n+\tif test \"$ecnt\" -gt -1\n+\tthen\n+\t\ttest_line_count \"$op\" \"$ecnt\" cnt.err\n+\tfi &&\n+\treturn \"$exit_code\"\n+}\n+\n test_file_size () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \ttest-tool path-utils file-size \"$1\"\n"},{"id":"422682","messageId":"YIGROPXmNp/0wvWH@danh.dev","threadId":"55480","inReplyTo":"YIF+0BZGwpMMI1pf@danh.dev","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-04-22T15:07:36Z","receivedAt":"2021-04-22T15:07:42Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-22 20:49:04+0700, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n> On 2021-04-21 16:32:40-0700, Junio C Hamano <gitster@pobox.com> wrote:\n> > Eric Sunshine <sunshine@sunshineco.com> writes:\n> > \n> > > On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> > >>     count_ls_files 5 -s &&\n> > >>     count_ls_files 3 -u &&\n> > >>     count_ls_files 1 -u one~HEAD &&\n> > >>     ...\n> > >>\n> > >> The nice thing about having a helper function is that it can clean up\n> > >> after itself by not leaving a new file lying around, thus you wouldn't\n> > >> have to make adjustments to the expected number of untracked files (as\n> > >> mentioned in the commit message). If this is the sort of thing which\n> > >> comes up often enough (if there are more such cases beyond the two\n> > >> scripts you changed in this series), then it might make sense to\n> > >> promote the helper function to test-lib-functions.sh.\n> > >\n> > > The frequency with which this idiom crops up with commands beyond\n> > > git-ls-files suggests the more general solution of supporting it\n> > > directly in test-lib-functions.sh for any command. For instance:\n> > >\n> > >     test_cmd_line_count = 3 git ls-files -u &&\n> > >\n> > > Or, perhaps, a new mode of test_line_count():\n> > >\n> > >     test_line_count = 3 -c git ls-files -u &&\n> \n> Hm, I'm not sure how would we implement such mode:\n> \n> * Will we run such command in a subprocess and and pipe to \"wc -l\"\n>   directly to avoid a temporary file, but we will lose the exit code\n>   of running command in process?\n> * Will we run in a separated chain? Thus, a temporary file would be\n>   created, skimming over test-lib-functions.sh, I couldn't find any\n>   convention for creating such files, except for specific use cases,\n>   let's say \"*.config\".\n> * Another clever hacks that I don't know *shrug*\n\nHm, I figured out, just a bit insane for reviewing.\n-----8<--------\nSubject: [PATCH] test-lib-functions: add test_line_count_in helper\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/t0000-basic.sh        |  7 +++++\n t/test-lib-functions.sh | 62 +++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 69 insertions(+)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27..2ddb50e919 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -60,6 +60,13 @@ test_expect_success '.git/objects should have 3 subdirectories' '\n \ttest_line_count = 3 full-of-directories\n '\n \n+test_expect_success 'check test_line_count_in' '\n+\ttest_line_count_in --stdout = 4 --stderr = 3 -- sh -c \"\n+\t\tprintf \\\"%s\\\\n\\\" 1 2 3 4\n+\t\tprintf >&2 \\\"%s\\\\n\\\" a b c\n+\t\t\"\n+'\n+\n ################################################################\n # Test harness\n test_expect_success 'success is reported like this' '\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 6348e8d733..3b3dc3020a 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -817,6 +817,68 @@ test_line_count () {\n \tfi\n }\n \n+# test_line_count_in checks if stdout and/or stderr has the number of lines it\n+# ought to. E.g.\n+#\n+# \ttest_expect_success 'product 1 line in stdout and 2 lines in stderr' '\n+# \t\ttest_line_count_in --stdout = 1 --stderr = 3 do_something\n+# \t'\n+test_line_count_in () {\n+\tlocal out_ops=-ge\n+\tlocal out_val=0\n+\tlocal err_ops=-ge\n+\tlocal err_val=0\n+\tlocal opt_set=\n+\n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--stdout)\n+\t\t\tif test $# -lt 3\n+\t\t\tthen\n+\t\t\t\tBUG \"need ops and value for --stdout\"\n+\t\t\tfi\n+\t\t\tout_ops=$2\n+\t\t\tout_val=$3\n+\t\t\topt_set=yes\n+\t\t\tshift 3\n+\t\t\t;;\n+\t\t--stderr)\n+\t\t\tif test $# -lt 3\n+\t\t\tthen\n+\t\t\t\tBUG \"need ops and value for --stderr\"\n+\t\t\tfi\n+\t\t\terr_ops=$2\n+\t\t\terr_val=$3\n+\t\t\topt_set=yes\n+\t\t\tshift 3\n+\t\t\t;;\n+\t\t--)\n+\t\t\tshift\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n+\tif test -z \"$opt_set\"\n+\tthen\n+\t\tBUG \"need check ops for test_line_count_in\"\n+\telse\n+\t\t! (\n+\t\ttest $(\n+\t\t\t(\n+\t\t\ttest $(\n+\t\t\t\t( \"$@\" || echo \"'$*' run into failure\" >&3) |\n+\t\t\t\twc -l\n+\t\t\t\t) \"$out_ops\" \"$out_val\" ||\n+\t\t\techo \"test_line_count_in --stdout: !$out_ops $out_val '$*'\" >&3\n+\t\t\t) 2>&1 | wc -l\n+\t\t) \"$err_ops\" \"$err_val\" ||\n+\t\techo \"test_line_count_in --stderr: !$out_ops $out_val '$*'\" >&3\n+\t\t) 3>&1 | grep .\n+\tfi\n+}\n+\n test_file_size () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \ttest-tool path-utils file-size \"$1\"\n-- \n2.31.1.500.gbc6bbdd36b\n\n"},{"id":"422691","messageId":"CAPig+cR7wvPRrWiTS+_AFSSWqHvnSP0oK-joOo9_Pa4+nWR0qg@mail.gmail.com","threadId":"55480","inReplyTo":"87pmym1huk.fsf@evledraar.gmail.com","subject":"Re: [PATCH 2/2] t6402: check exit status of ls-files","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-04-22T15:30:15Z","receivedAt":"2021-04-22T15:30:30Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Apr 22, 2021 at 11:04 AM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> On Thu, Apr 22 2021, Đoàn Trần Công Danh wrote:\n> > Hm, I'm not sure how would we implement such mode:\n> >\n> > * Will we run such command in a subprocess and and pipe to \"wc -l\"\n> >   directly to avoid a temporary file, but we will lose the exit code\n> >   of running command in process?\n>\n> Just use a tempfile.\n\nThat's what I had in mind when I suggested the function. The function\nwould remove the tempfile if the check succeeded.\n\n> Here's an implementation that works, sans the fancy opts parsing etc. I\n> just use -1 for \"don't care\". You can see \"test_commit\" etc. for how to\n> do that.\n>\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> @@ -817,6 +817,24 @@ test_line_count () {\n> +test_line_count_command () {\n> +       local op=$1\n> +       local ocnt=$2\n> +       local ecnt=$3\n> +       shift 3\n> +       \"$@\" 2>cnt.err >cnt.out\n> +       local exit_code=$?\n> +       if test \"$ocnt\" -gt -1\n> +       then\n> +               test_line_count \"$op\" \"$ocnt\" cnt.out\n> +       fi &&\n> +       if test \"$ecnt\" -gt -1\n> +       then\n> +               test_line_count \"$op\" \"$ecnt\" cnt.err\n> +       fi &&\n> +       return \"$exit_code\"\n> +}\n\nIt's not clear why you manually catch the exit code of the command\nbeing run but then use &&-chain for the other parts.\n\nAn important reason I suggested creating a function was because the\nfunction could clean up after itself thus freeing the test author from\nworrying about adjusting counts in later tests (or later in the same\ntest). So, just before this function returns, I'd expect to see:\n\n    rm -f cnt.out cnt.err &&\n"},{"id":"422714","messageId":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-0000000000-20210421T101156Z-avarab@gmail.com","subject":"[PATCH v5 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:04Z","receivedAt":"2021-04-23T07:21:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Changes since v4: Only a commit message change/re-wording per\n<87v98e1oj7.fsf@evledraar.gmail.com>.\n\nÆvar Arnfjörð Bjarmason (11):\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: split up and deprecate test_create_repo()\n\n t/lib-submodule-update.sh           |  3 +-\n t/t0000-basic.sh                    |  4 --\n t/t1307-config-blob.sh              |  4 +-\n t/t1403-show-ref.sh                 |  6 +--\n t/t2030-unresolve-info.sh           |  3 +-\n t/t4006-diff-mode.sh                |  6 +--\n t/t4030-diff-textconv.sh            |  8 +---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 -\n t/t5409-colorize-remote-messages.sh |  1 -\n t/t5520-pull.sh                     | 10 +----\n t/t6120-describe.sh                 | 58 +++++++---------------------\n t/test-lib-functions.sh             | 60 ++++++++++++++++++-----------\n t/test-lib.sh                       | 40 +++++++++++--------\n 14 files changed, 87 insertions(+), 119 deletions(-)\n\nRange-diff against v4:\n 1:  a76ea749bb6 =  1:  75667f98f3a test-lib: bring $remove_trash out of retirement\n 2:  de7be7844ea =  2:  55c9413f9cd test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n 3:  709bc773fb0 =  3:  361e34654e9 test-lib-functions: reword \"test_commit --append\" docs\n 4:  b67654334e6 =  4:  2db68a4ac7c test-lib-functions: document test_commit --no-tag\n 5:  3a166c92063 =  5:  4ceba3d404b test-lib functions: add an --annotated option to \"test_commit\"\n 6:  981fc43ee69 =  6:  589eaf7a078 describe tests: convert setup to use test_commit\n 7:  15057cdecfe =  7:  a0fe0640148 test-lib functions: add --printf option to test_commit\n 8:  5d437f53ec8 =  8:  7fb8849ce66 submodule tests: use symbolic-ref --short to discover branch name\n 9:  9ee13ee71bc =  9:  f67245ba40d test-lib: reformat argument list in test_create_repo()\n10:  6ba568df9f4 = 10:  37338c88300 test-lib: do not show advice about init.defaultBranch under --verbose\n11:  311a9dba36b ! 11:  7793311e5f1 test-lib: split up and deprecate test_create_repo()\n    @@ Commit message\n             from \"mkdir .git/hooks\" changes various tests needed to re-setup\n             that directory. Now they no longer do.\n     \n    -     5. Since we don't need to move the .git/hooks directory we don't need\n    -        the subshell here either.\n    -\n    -        See 0d314ce834 for when the subshell use got introduced for the\n    -        convenience of not having to \"cd\" back and forth while setting up\n    -        the hooks.\n    +        This makes us implicitly depend on the default hooks being\n    +        disabled, which is a good thing. If and when we'd have any\n    +        on-by-default hooks (I see no reason we ever would) we'd want to\n    +        see the subtle and not so subtle ways that would break the test\n    +        suite.\n    +\n    +     5. We don't need to \"cd\" to the \"$repo\" directory at all anymore.\n    +\n    +        In the code being removed here we both \"cd\"'d to the repository\n    +        before calling \"init\", and did so in a subshell.\n    +\n    +        It's not important to do either, so both of those can be\n    +        removed. We cd'd because this code grew from test-lib.sh code\n    +        where we'd have done so already, see eedf8f97e58 (Abstract\n    +        test_create_repo out for use in tests., 2006-02-17), and later\n    +        \"cd\"'d inside a subshell since 0d314ce834d to avoid having to keep\n    +        track of an \"old pwd\" variable to cd back after the setup.\n    +\n    +        Being in the repository directory made moving the hooks around\n    +        easier (we wouldn't have to fully qualify the path). Since we're\n    +        not moving the hooks per #4 above we don't need to \"cd\" for that\n    +        reason either.\n     \n          6. We can drop the --template argument and instead rely on the\n             GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422715","messageId":"patch-01.11-75667f98f3a-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 01/11] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:05Z","receivedAt":"2021-04-23T07:21:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests. We can save\nourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\ncase.\n\nWe carry around the \"$remove_trash\" variable because if the directory\nis unexpectedly gone at test_done time we'll hit the error about it\nbeing unexpectedly gone added in df4c0d1a792 (test-lib: abort when\ncan't remove trash directory, 2017-04-20).\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nLet's also fix a bug that was with us since abc5d372ec (Enable\nparallel tests, 2008-08-08): we would leak $remove_trash from the\nenvironment. We don't want this to error out, so let's reset it to the\nempty string first:\n\n     remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 32 ++++++++++++++++++--------------\n 1 file changed, 18 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3dec266221c..105c424bf56 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1169,7 +1169,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1334,6 +1334,22 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+remove_trash=\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1341,10 +1357,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1356,15 +1369,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422716","messageId":"patch-02.11-55c9413f9cd-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 02/11] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:06Z","receivedAt":"2021-04-23T07:21:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27a..2c6e34b9478 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422717","messageId":"patch-03.11-361e34654e9-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 03/11] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:07Z","receivedAt":"2021-04-23T07:21:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex b823c140271..1f787ff0726 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422718","messageId":"patch-04.11-2db68a4ac7c-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 04/11] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:08Z","receivedAt":"2021-04-23T07:21:33Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 1f787ff0726..c6d07f4ce32 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,8 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422719","messageId":"patch-05.11-4ceba3d404b-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 05/11] test-lib functions: add an --annotated option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:09Z","receivedAt":"2021-04-23T07:21:34Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated option to test_commit to create annotated tags. The\ntag will share the same message as the commit, and we'll call\ntest_tick before creating it (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c3..17d3cc14050 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c6d07f4ce32..827c8502b10 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -179,6 +179,10 @@ debug () {\n #\tInvoke \"git commit\" with --author <author>\n #   --no-tag\n #\tDo not tag the resulting commit\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag, unless --notick\n+#\tis given.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -191,7 +195,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -219,7 +223,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -243,10 +250,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test -z \"$notick\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422720","messageId":"patch-06.11-589eaf7a078-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 06/11] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:10Z","receivedAt":"2021-04-23T07:21:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotated-tag option to\ntest_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747bee..88fddc91424 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422721","messageId":"patch-07.11-a0fe0640148-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 07/11] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:11Z","receivedAt":"2021-04-23T07:21:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 12 ++++++++++--\n 6 files changed, 18 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388e..930dce06f0f 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a2..f691e6d9032 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15b..6cdee2a2164 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60d..a39a626664d 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f9..e2c0c510222 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 827c8502b10..701518f5fd3 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,10 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -191,6 +195,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -202,6 +207,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -238,9 +246,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422722","messageId":"patch-08.11-7fb8849ce66-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 08/11] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:12Z","receivedAt":"2021-04-23T07:21:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e93083..f7c7df0ca42 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422723","messageId":"patch-09.11-f67245ba40d-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 09/11] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:13Z","receivedAt":"2021-04-23T07:21:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 701518f5fd3..7101030f042 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1250,8 +1250,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422724","messageId":"patch-10.11-37338c88300-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 10/11] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:14Z","receivedAt":"2021-04-23T07:21:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 7101030f042..c9f33b79151 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1251,7 +1251,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 105c424bf56..ab1fe98ccce 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422725","messageId":"patch-11.11-7793311e5f1-20210423T072006Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v5 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:21:15Z","receivedAt":"2021-04-23T07:21:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove various redundant or obsolete code from the test_create_repo()\nfunction, and split up its use in test-lib.sh from what tests need\nfrom it.\n\nThis leave us with a pass-through wrapper for \"git init\" in\ntest-lib-functions.sh, in test-lib.sh we have the same, except for\nneeding to redirect stdout/stderr, and emitting an error ourselves if\nit fails. We don't need to error() ourselves when test_create_repo()\nis invoked, as the invocation will be a part of a test's \"&&\"-chain.\n\nEverything below this paragraph is a detailed summary of the history\nof test_create_repo() explaining why it's safe to remove the various\nthings it was doing:\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. Since we're now a simple wrapper for \"git init\" we don't need to\n    check that we have only one argument. If someone wants to run\n    \"test_create_repo --bare x\" that's OK.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n    This makes us implicitly depend on the default hooks being\n    disabled, which is a good thing. If and when we'd have any\n    on-by-default hooks (I see no reason we ever would) we'd want to\n    see the subtle and not so subtle ways that would break the test\n    suite.\n\n 5. We don't need to \"cd\" to the \"$repo\" directory at all anymore.\n\n    In the code being removed here we both \"cd\"'d to the repository\n    before calling \"init\", and did so in a subshell.\n\n    It's not important to do either, so both of those can be\n    removed. We cd'd because this code grew from test-lib.sh code\n    where we'd have done so already, see eedf8f97e58 (Abstract\n    test_create_repo out for use in tests., 2006-02-17), and later\n    \"cd\"'d inside a subshell since 0d314ce834d to avoid having to keep\n    track of an \"old pwd\" variable to cd back after the setup.\n\n    Being in the repository directory made moving the hooks around\n    easier (we wouldn't have to fully qualify the path). Since we're\n    not moving the hooks per #4 above we don't need to \"cd\" for that\n    reason either.\n\n 6. We can drop the --template argument and instead rely on the\n    GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n\n 7. We only needed that \">&3 2>&4\" redirection when invoked from\n    test-lib.sh.\n\n    We could still invoke test_create_repo() there, but as the\n    invocation is now trivial and we don't have a good reason to use\n    test_create_repo() elsewhere let's call \"git init\" there\n    ourselves.\n\n 8. We didn't need to resolve \"git\" as\n    \"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" in test_create_repo(),\n    even for the use of test-lib.sh\n\n    PATH is already set up in test-lib.sh to start with\n    GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before\n    test_create_repo() (now \"git init\") is called.. So we can simply\n    run \"git\" and rely on the PATH lookup choosing the right\n    executable.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 ++-------------\n t/test-lib.sh                       |  3 ++-\n 5 files changed, 4 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649e..5c509db6fc3 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4e..6da8d760e28 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8ec..9f1a483f426 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c9f33b79151..213b1988aa4 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1241,21 +1241,10 @@ test_atexit () {\n \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n }\n \n-# Most tests can use the created repository, but some may need to create more.\n+# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\tgit init \"$@\"\n }\n \n # This function helps on symlink challenged file systems when it is not\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ab1fe98ccce..5fd968d11b2 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1365,7 +1365,8 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n-\ttest_create_repo \"$TRASH_DIRECTORY\"\n+\tgit init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n+\terror \"cannot run git init\"\n else\n \tmkdir -p \"$TRASH_DIRECTORY\"\n fi\n-- \n2.31.1.737.g98b508eba36\n\n"},{"id":"422726","messageId":"patch-1.4-26a3d552d88-20210423T072824Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.4-00000000000-20210423T072824Z-avarab@gmail.com","subject":"[PATCH v3 1/4] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:29:43Z","receivedAt":"2021-04-23T07:29:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test_path_is_missing() to be consistent with related\nfunctions. Since 2caf20c52b7 (test-lib: user-friendly alternatives to\ntest [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\necho-ing $* if it exists. Let's just say that it exists instead.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 213b1988aa4..2914b398470 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -810,12 +810,7 @@ test_path_is_missing () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \tif test -e \"$1\"\n \tthen\n-\t\techo \"Path exists:\"\n-\t\tls -ld \"$1\"\n-\t\tif test $# -ge 1\n-\t\tthen\n-\t\t\techo \"$*\"\n-\t\tfi\n+\t\techo \"Path $1 exists!\"\n \t\tfalse\n \tfi\n }\n-- \n2.31.1.734.gdef39492517\n\n"},{"id":"422727","messageId":"cover-0.4-00000000000-20210423T072824Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com","subject":"[PATCH v3 0/4] test-lib-functions.sh: trickery to make -x less verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:29:42Z","receivedAt":"2021-04-23T07:29:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series makes the \"-x\" output less verbose for our various helper\nfunctions, mainly using the trickery of feeding \"$@\" to \"test\" to rely\non it to die when given too many arguments.\n\nSince v2[1] I ejected the 3rd patch. I thought some test-lib code was\nremoved, but was only grepping t/, turned out it was used in ci/.\n\nhttps://lore.kernel.org/git/cover-0.5-00000000000-20210421T144921Z-avarab@gmail.com\n\nÆvar Arnfjörð Bjarmason (4):\n  test-lib-functions: normalize test_path_is_missing() debugging\n  Revert and amend \"test-lib-functions: assert correct parameter count\"\n  test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"\n  test-helpers: split \"file-size\" into \"file-size(s)\"\n\n t/helper/test-path-utils.c  | 13 +++++--\n t/t0060-path-utils.sh       |  2 +-\n t/t1050-large.sh            |  2 +-\n t/t5319-multi-pack-index.sh |  6 ++--\n t/test-lib-functions.sh     | 67 ++++++++++++++++---------------------\n 5 files changed, 45 insertions(+), 45 deletions(-)\n\nRange-diff against v2:\n1:  ba9d6251ad5 = 1:  26a3d552d88 test-lib-functions: normalize test_path_is_missing() debugging\n2:  5f8e5ad27f5 = 2:  3a570321770 Revert and amend \"test-lib-functions: assert correct parameter count\"\n3:  44948c6ace9 < -:  ----------- test helpers: remove unused test-tool path-utils slice-tests\n4:  ae5dc5d03b3 = 3:  bf35091a112 test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"\n5:  947791d9535 = 4:  ac0b920c041 test-helpers: split \"file-size\" into \"file-size(s)\"\n-- \n2.31.1.734.gdef39492517\n\n"},{"id":"422728","messageId":"patch-2.4-3a570321770-20210423T072824Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.4-00000000000-20210423T072824Z-avarab@gmail.com","subject":"[PATCH v3 2/4] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:29:44Z","receivedAt":"2021-04-23T07:29:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This reverts and amends my my own e7884b353b7 (test-lib-functions:\nassert correct parameter count, 2021-02-12) in order to improve the -x\noutput.\n\nThe goal here is to get rid of the verbosity of having e.g. a \"test 2\n-ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\nto intentionally feed the \"test\" operator too many arguments if the\nfunctions are called with too many arguments, thus piggy-backing on it\nto check the number of arguments we get.\n\nBefore this for each test_cmp invocation we'd emit:\n\n    + test_cmp expect actual\n    + test 2 -ne 2\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThat \"test 2 -ne 2\" line is new in my e7884b353b7. As noted in\n45a2686441b (test-lib-functions: remove bug-inducing \"diagnostics\"\nhelper param, 2021-02-12) we had buggy invocations of some of these\nfunctions with too many parameters.\n\nNow we'll get just:\n\n    + test_cmp expect actual\n    + eval diff -u \"$@\"\n    + diff -u expect actual\n\nThis does not to the \"right\" thing in cases like:\n\n    test_path_is_file x -a y\n\nWhich will now turn into:\n\n    test -f x -a y\n\nI consider that to be OK given the trade-off that any extra checking\nwould produce more verbose trace output. As shown in 45a2686441b we\nhad issues with these functions being invoked with multiple\nparameters (e.g. a glob) by accident, we don't need to be paranoid in\nguarding against hostile misuse from our own test suite.\n\nWhile I'm at it change a few functions that relied on a \"false\" being\nthe last statement in the function to use an explicit \"return 1\" like\nthe other functions in this file.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 59 +++++++++++++++++++----------------------\n 1 file changed, 28 insertions(+), 31 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2914b398470..0adb9fd124d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -756,41 +756,43 @@ test_external_without_stderr () {\n }\n \n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n-# The commands test the existence or non-existence of $1\n+# The commands test the existence or non-existence of\n+# a given argument.\n+#\n+# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n+# are counting on \"test\" to error on too many arguments if more than\n+# one is given. Checking \"$#\" explicitly would lead to overly verbose\n+# -x output.\n test_path_is_file () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -f \"$1\"\n+\tif ! test -f \"$@\"\n \tthen\n-\t\techo \"File $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"File $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_dir () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -d \"$1\"\n+\tif ! test -d \"$@\"\n \tthen\n-\t\techo \"Directory $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Directory $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_exists () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif ! test -e \"$1\"\n+\tif ! test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 doesn't exist\"\n-\t\tfalse\n+\t\techo \"Path $* doesn't exist\"\n+\t\treturn 1\n \tfi\n }\n \n # Check if the directory exists and is empty as expected, barf otherwise.\n test_dir_is_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\ttest_path_is_dir \"$@\" &&\n+\tif test -n \"$(ls -a1 \"$@\" | egrep -v '^\\.\\.?$')\"\n \tthen\n-\t\techo \"Directory '$1' is not empty, it contains:\"\n+\t\techo \"Directory '$*' is not empty, it contains:\"\n \t\tls -la \"$1\"\n \t\treturn 1\n \tfi\n@@ -798,19 +800,17 @@ test_dir_is_empty () {\n \n # Check if the file exists and has a size greater than zero\n test_file_not_empty () {\n-\ttest \"$#\" = 2 && BUG \"2 param\"\n-\tif ! test -s \"$1\"\n+\tif ! test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not a non-empty file.\"\n-\t\tfalse\n+\t\techo \"'$*' is not a non-empty file.\"\n+\t\treturn 1\n \tfi\n }\n \n test_path_is_missing () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\tif test -e \"$1\"\n+\tif test -e \"$@\"\n \tthen\n-\t\techo \"Path $1 exists!\"\n+\t\techo \"Path $* exists!\"\n \t\tfalse\n \tfi\n }\n@@ -1012,7 +1012,6 @@ test_expect_code () {\n # - not all diff versions understand \"-u\"\n \n test_cmp () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \teval \"$GIT_TEST_CMP\" '\"$@\"'\n }\n \n@@ -1042,7 +1041,6 @@ test_cmp_config () {\n # test_cmp_bin - helper to compare binary files\n \n test_cmp_bin () {\n-\ttest \"$#\" -ne 2 && BUG \"2 param\"\n \tcmp \"$@\"\n }\n \n@@ -1096,12 +1094,11 @@ verbose () {\n # otherwise.\n \n test_must_be_empty () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest_path_is_file \"$1\" &&\n-\tif test -s \"$1\"\n+\ttest_path_is_file \"$@\" &&\n+\tif test -s \"$@\"\n \tthen\n-\t\techo \"'$1' is not empty, it contains:\"\n-\t\tcat \"$1\"\n+\t\techo \"'$*' is not empty, it contains:\"\n+\t\tcat \"$@\"\n \t\treturn 1\n \tfi\n }\n-- \n2.31.1.734.gdef39492517\n\n"},{"id":"422729","messageId":"patch-4.4-ac0b920c041-20210423T072824Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.4-00000000000-20210423T072824Z-avarab@gmail.com","subject":"[PATCH v3 4/4] test-helpers: split \"file-size\" into \"file-size(s)\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:29:46Z","receivedAt":"2021-04-23T07:29:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Split the \"file-size\" helper into two helpers, one that takes 1\nargument, and another one that takes N.\n\nThis allows us to remove the \"BUG\" check in test-lib-functions.sh for\nbriefer -x output, and more importantly will clearly distinguish those\ncases where we expect one argument v.s. many.\n\nThe use in t1050-large.sh wants to check just one pack, we used to\ncheck that explicitly before 53b67a801bb (tests: consolidate the\n`file_size` function into `test-lib-functions.sh`, 2020-11-07), now we\ndo so again.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-path-utils.c  | 11 ++++++++++-\n t/t1050-large.sh            |  2 +-\n t/t5319-multi-pack-index.sh |  6 +++---\n t/test-lib-functions.sh     |  3 +--\n 4 files changed, 15 insertions(+), 7 deletions(-)\n\ndiff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c\nindex eed3068ffb7..17645da4a1c 100644\n--- a/t/helper/test-path-utils.c\n+++ b/t/helper/test-path-utils.c\n@@ -280,6 +280,8 @@ static int protect_ntfs_hfs_benchmark(int argc, const char **argv)\n \n int cmd__path_utils(int argc, const char **argv)\n {\n+\tint is_file_size, is_file_sizes;\n+\n \tif (argc == 3 && !strcmp(argv[1], \"normalize_path_copy\")) {\n \t\tchar *buf = xmallocz(strlen(argv[2]));\n \t\tint rv = normalize_path_copy(buf, argv[2]);\n@@ -395,10 +397,17 @@ int cmd__path_utils(int argc, const char **argv)\n \t\treturn !!res;\n \t}\n \n-\tif (argc > 2 && !strcmp(argv[1], \"file-size\")) {\n+\tis_file_size = !strcmp(argv[1], \"file-size\");\n+\tis_file_sizes = !strcmp(argv[1], \"file-sizes\");\n+\tif (argc > 2 && (is_file_size || is_file_sizes)) {\n \t\tint res = 0, i;\n \t\tstruct stat st;\n \n+\t\tif (is_file_size && argc > 3) {\n+\t\t\tres = error(\"too many arguments to is-file-size, use is-file-sizes?\");\n+\t\t\treturn res;\n+\t\t}\n+\n \t\tfor (i = 2; i < argc; i++)\n \t\t\tif (stat(argv[i], &st))\n \t\t\t\tres = error_errno(\"Cannot stat '%s'\", argv[i]);\ndiff --git a/t/t1050-large.sh b/t/t1050-large.sh\nindex 4bab6a513c5..0b76ab0e3f9 100755\n--- a/t/t1050-large.sh\n+++ b/t/t1050-large.sh\n@@ -23,7 +23,7 @@ do\n \ttest_expect_success \"add with $config\" '\n \t\ttest_when_finished \"rm -f .git/objects/pack/pack-*.* .git/index\" &&\n \t\tgit $config add large1 &&\n-\t\tsz=$(test_file_size .git/objects/pack/pack-*.pack) &&\n+\t\tsz=$(test-tool path-utils file-size .git/objects/pack/pack-*.pack) &&\n \t\tcase \"$expect\" in\n \t\tsmall) test \"$sz\" -le 100000 ;;\n \t\tlarge) test \"$sz\" -ge 100000 ;;\ndiff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh\nindex 5641d158dfc..baeda407b90 100755\n--- a/t/t5319-multi-pack-index.sh\n+++ b/t/t5319-multi-pack-index.sh\n@@ -648,7 +648,7 @@ test_expect_success 'repack with minimum size does not alter existing packs' '\n \t\ttest-tool chmtime =-3 .git/objects/pack/pack-B* &&\n \t\ttest-tool chmtime =-2 .git/objects/pack/pack-A* &&\n \t\tls .git/objects/pack >expect &&\n-\t\tMINSIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 1) &&\n+\t\tMINSIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | head -n 1) &&\n \t\tgit multi-pack-index repack --batch-size=$MINSIZE &&\n \t\tls .git/objects/pack >actual &&\n \t\ttest_cmp expect actual\n@@ -672,7 +672,7 @@ test_expect_success 'repack respects repack.packKeptObjects=false' '\n \t\ttest_line_count = 5 idx-list &&\n \t\ttest-tool read-midx .git/objects | grep idx >midx-list &&\n \t\ttest_line_count = 5 midx-list &&\n-\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | sed -n 3p) &&\n+\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | sed -n 3p) &&\n \t\tBATCH_SIZE=$((THIRD_SMALLEST_SIZE + 1)) &&\n \t\tgit multi-pack-index repack --batch-size=$BATCH_SIZE &&\n \t\tls .git/objects/pack/*idx >idx-list &&\n@@ -687,7 +687,7 @@ test_expect_success 'repack creates a new pack' '\n \t\tcd dup &&\n \t\tls .git/objects/pack/*idx >idx-list &&\n \t\ttest_line_count = 5 idx-list &&\n-\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&\n+\t\tTHIRD_SMALLEST_SIZE=$(test-tool path-utils file-sizes .git/objects/pack/*pack | sort -n | head -n 3 | tail -n 1) &&\n \t\tBATCH_SIZE=$(($THIRD_SMALLEST_SIZE + 1)) &&\n \t\tgit multi-pack-index repack --batch-size=$BATCH_SIZE &&\n \t\tls .git/objects/pack/*idx >idx-list &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 0adb9fd124d..602d77dee37 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -839,8 +839,7 @@ test_line_count () {\n }\n \n test_file_size () {\n-\ttest \"$#\" -ne 1 && BUG \"1 param\"\n-\ttest-tool path-utils file-size \"$1\"\n+\ttest-tool path-utils file-size \"$@\"\n }\n \n # Returns success if a comma separated string of keywords ($1) contains a\n-- \n2.31.1.734.gdef39492517\n\n"},{"id":"422730","messageId":"patch-3.4-bf35091a112-20210423T072824Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-0.4-00000000000-20210423T072824Z-avarab@gmail.com","subject":"[PATCH v3 3/4] test-helpers: rename \"path-utils is_valid_path\" to \"is-valid-paths\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-04-23T07:29:45Z","receivedAt":"2021-04-23T07:29:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename this utility added in d2c84dad1c8 (mingw: refuse to access\npaths with trailing spaces or periods, 2019-09-05) to make it clear\nthat it expects N number of arguments, and for consistency with\ndc2d9ba3187 (is_{hfs,ntfs}_dotgitmodules: add tests, 2018-05-12).\n\nLet's also make it a dashed \"is-valid-paths\" instead of\n\"is_valid_path*\" to make it easier to grep the helper v.s. the C\nfunction it calls.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-path-utils.c | 2 +-\n t/t0060-path-utils.sh      | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c\nindex 313a153209c..eed3068ffb7 100644\n--- a/t/helper/test-path-utils.c\n+++ b/t/helper/test-path-utils.c\n@@ -454,7 +454,7 @@ int cmd__path_utils(int argc, const char **argv)\n \tif (argc > 1 && !strcmp(argv[1], \"protect_ntfs_hfs\"))\n \t\treturn !!protect_ntfs_hfs_benchmark(argc - 1, argv + 1);\n \n-\tif (argc > 1 && !strcmp(argv[1], \"is_valid_path\")) {\n+\tif (argc > 1 && !strcmp(argv[1], \"is-valid-paths\")) {\n \t\tint res = 0, expect = 1, i;\n \n \t\tfor (i = 2; i < argc; i++)\ndiff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh\nindex 0ff06b5d1b3..e7fb748b19c 100755\n--- a/t/t0060-path-utils.sh\n+++ b/t/t0060-path-utils.sh\n@@ -469,7 +469,7 @@ test_expect_success 'match .gitmodules' '\n '\n \n test_expect_success MINGW 'is_valid_path() on Windows' '\n-\ttest-tool path-utils is_valid_path \\\n+\ttest-tool path-utils is-valid-paths \\\n \t\twin32 \\\n \t\t\"win32 x\" \\\n \t\t../hello.txt \\\n-- \n2.31.1.734.gdef39492517\n\n"},{"id":"423233","messageId":"xmqqr1it92da.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-1.4-26a3d552d88-20210423T072824Z-avarab@gmail.com","subject":"Re: [PATCH v3 1/4] test-lib-functions: normalize test_path_is_missing() debugging","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-29T03:49:21Z","receivedAt":"2021-04-29T03:49:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Change the test_path_is_missing() to be consistent with related\n> functions.\n\nNot very helpful to readers.  It is totally unclear what kind of\nconsistency is being sought by this patch.\n\n> Since 2caf20c52b7 (test-lib: user-friendly alternatives to\n> test [-d|-f|-e], 2010-08-10) we've been ls -ld-ing the bad path and\n> echo-ing $* if it exists.\n\nYes, and it does not explain what's wrong with that behaviour.\n\nIf there were something like \"... but no invocation of the shell\nfunction passes $2 and subsequent arguments\" (I didn't check if that\nis the case) after the above, it might have been more\nunderstandable, though.\n\n> Let's just say that it exists instead.\n\nAs the earlier parts of the proposed log message are so weak, this\nconclusion does not sound convincing.\n\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/test-lib-functions.sh | 7 +------\n>  1 file changed, 1 insertion(+), 6 deletions(-)\n>\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 213b1988aa4..2914b398470 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -810,12 +810,7 @@ test_path_is_missing () {\n>  \ttest \"$#\" -ne 1 && BUG \"1 param\"\n>  \tif test -e \"$1\"\n>  \tthen\n> -\t\techo \"Path exists:\"\n> -\t\tls -ld \"$1\"\n> -\t\tif test $# -ge 1\n> -\t\tthen\n> -\t\t\techo \"$*\"\n> -\t\tfi\n> +\t\techo \"Path $1 exists!\"\n>  \t\tfalse\n>  \tfi\n>  }\n"},{"id":"423235","messageId":"xmqqmtth91wx.fsf@gitster.g","threadId":"55480","inReplyTo":"patch-2.4-3a570321770-20210423T072824Z-avarab@gmail.com","subject":"Re: [PATCH v3 2/4] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-29T03:59:10Z","receivedAt":"2021-04-29T03:59:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> The goal here is to get rid of the verbosity of having e.g. a \"test 2\n> -ne 2\" line for every \"test_cmp\". We use \"$@\" as an argument to \"test\"\n> to intentionally feed the \"test\" operator too many arguments if the\n> functions are called with too many arguments, thus piggy-backing on it\n> to check the number of arguments we get.\n>\n> Before this for each test_cmp invocation we'd emit:\n>\n>     + test_cmp expect actual\n>     + test 2 -ne 2\n>     + eval diff -u \"$@\"\n>     + diff -u expect actual\n\nQuite honestly, I do not see what's bad about that and am not all\nthat sympathetic to the cause behind this series.\n\nThe developer is asking to debug the test script by passing '-x',\nand see where the test script is broken.  Especially since ...\n\n> Now we'll get just:\n>\n>     + test_cmp expect actual\n>     + eval diff -u \"$@\"\n>     + diff -u expect actual\n\n... we are not removing the 'eval diff -u \"$@\"' line, I do not think\nhow a few extra trace output lines coming from sanity check hurts\nall that much.  It is worth paying for to have such basic sanity\nchecks expressed in a more natural way (than \"oh, this hack would\nnot work when 'one -a two' is used as a path\"), I would think.\n\nThanks.\n"},{"id":"423236","messageId":"608a2fbe5e70e_ac4020821@natae.notmuch","threadId":"55480","inReplyTo":"patch-2.4-3a570321770-20210423T072824Z-avarab@gmail.com","subject":"RE: [PATCH v3 2/4] Revert and amend \"test-lib-functions: assert correct parameter count\"","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-04-29T04:02:06Z","receivedAt":"2021-04-29T04:02:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 2914b398470..0adb9fd124d 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -756,41 +756,43 @@ test_external_without_stderr () {\n>  }\n>  \n>  # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n> -# The commands test the existence or non-existence of $1\n> +# The commands test the existence or non-existence of\n> +# a given argument.\n> +#\n> +# The pattern of using \"$@\" to \"test\" instead of \"$1\" is not a bug. We\n> +# are counting on \"test\" to error on too many arguments if more than\n> +# one is given. Checking \"$#\" explicitly would lead to overly verbose\n> +# -x output.\n\nI would consider adding an extra line. In my mind a comment without a\nline is for the next function, one with a line is for the section.\n\n  # function comment\n  function_1 ()\n\nVersus:\n\n  # section comment\n\n  function_1 ()\n  function_2 ()\n\nBut I agree with the other comments that it's better inside the\nfunction. It's an implementation detail.\n\nWhile I think git tries to follow the self-documenting code style,\nsometimes it's better to just write the comment.\n\n>  test_path_is_file () {\n> -\ttest \"$#\" -ne 1 && BUG \"1 param\"\n> -\tif ! test -f \"$1\"\n> +\tif ! test -f \"$@\"\n\n  if ! test -f \"$@\" # Rely on test to ensure 1 param\n\n>  \tthen\n> -\t\techo \"File $1 doesn't exist\"\n> -\t\tfalse\n> +\t\techo \"File $* doesn't exist\"\n> +\t\treturn 1\n>  \tfi\n>  }\n\nAnd yes, I would add that comment to every instance where this trick is\nused. That way people reading the second or third function don't have to\nscratch their heads, or miraculously read a comment far above.\n\nCheers.\n\n-- \nFelipe Contreras"},{"id":"423244","messageId":"xmqqo8dx7dv4.fsf@gitster.g","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"Re: [PATCH v5 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-29T07:23:59Z","receivedAt":"2021-04-29T07:25:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Changes since v4: Only a commit message change/re-wording per\n> <87v98e1oj7.fsf@evledraar.gmail.com>.\n>\n> Ævar Arnfjörð Bjarmason (11):\n>   test-lib: bring $remove_trash out of retirement\n>   test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n>   test-lib-functions: reword \"test_commit --append\" docs\n>   test-lib-functions: document test_commit --no-tag\n>   test-lib functions: add an --annotated option to \"test_commit\"\n>   describe tests: convert setup to use test_commit\n>   test-lib functions: add --printf option to test_commit\n>   submodule tests: use symbolic-ref --short to discover branch name\n>   test-lib: reformat argument list in test_create_repo()\n>   test-lib: do not show advice about init.defaultBranch under --verbose\n>   test-lib: split up and deprecate test_create_repo()\n\nI wasn't paying much attention to this series, and didn't look at\nthe last step at all (as I saw somebody else is already deeply\nbiting into it), but the earlier parts looked good to me.\n\nIt was painful to come back to the pile of topics after a week's\ninterruption, though.  While juggling ~50 topics, it is unfair to\nexpect the maintainer to remember that a topic that is still going\nthrough iterations are depended on two other topics in flight (it is\neasier for contributors, who will be juggling far fewer number of\ntopics at one time).\n\nBut I think I've sorted out the duplicates caused by forgetting that\nI had to rebase ab/pickaxe-pcre2 and ab/describe-tests-fix on top of\nthis topic.  Will be pushing out the result of today's integration\nsometime this evening, which is far from complete as I am still in\nthe \"catch up with what happened during my absense\" mode.\n\nThanks.\n\n\n\n"},{"id":"423791","messageId":"87eeejvpuy.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"Re: [PATCH v5 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-06T15:32:01Z","receivedAt":"2021-05-06T15:35:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Apr 23 2021, Ævar Arnfjörð Bjarmason wrote:\n\n> Changes since v4: Only a commit message change/re-wording per\n> <87v98e1oj7.fsf@evledraar.gmail.com>.\n\nSZEDER, Eric, Đoàn et al: does this v5 look good to you? Junio's\nsuggested in [1] that this needs some final review feedback before\nadvancing to 'next'. If you could take a look that would be great!\n\n1. https://lore.kernel.org/git/xmqqsg30zdql.fsf@gitster.g/\n\n> Ævar Arnfjörð Bjarmason (11):\n>   test-lib: bring $remove_trash out of retirement\n>   test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n>   test-lib-functions: reword \"test_commit --append\" docs\n>   test-lib-functions: document test_commit --no-tag\n>   test-lib functions: add an --annotated option to \"test_commit\"\n>   describe tests: convert setup to use test_commit\n>   test-lib functions: add --printf option to test_commit\n>   submodule tests: use symbolic-ref --short to discover branch name\n>   test-lib: reformat argument list in test_create_repo()\n>   test-lib: do not show advice about init.defaultBranch under --verbose\n>   test-lib: split up and deprecate test_create_repo()\n>\n>  t/lib-submodule-update.sh           |  3 +-\n>  t/t0000-basic.sh                    |  4 --\n>  t/t1307-config-blob.sh              |  4 +-\n>  t/t1403-show-ref.sh                 |  6 +--\n>  t/t2030-unresolve-info.sh           |  3 +-\n>  t/t4006-diff-mode.sh                |  6 +--\n>  t/t4030-diff-textconv.sh            |  8 +---\n>  t/t5406-remote-rejects.sh           |  1 -\n>  t/t5407-post-rewrite-hook.sh        |  2 -\n>  t/t5409-colorize-remote-messages.sh |  1 -\n>  t/t5520-pull.sh                     | 10 +----\n>  t/t6120-describe.sh                 | 58 +++++++---------------------\n>  t/test-lib-functions.sh             | 60 ++++++++++++++++++-----------\n>  t/test-lib.sh                       | 40 +++++++++++--------\n>  14 files changed, 87 insertions(+), 119 deletions(-)\n>\n> Range-diff against v4:\n>  1:  a76ea749bb6 =  1:  75667f98f3a test-lib: bring $remove_trash out of retirement\n>  2:  de7be7844ea =  2:  55c9413f9cd test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n>  3:  709bc773fb0 =  3:  361e34654e9 test-lib-functions: reword \"test_commit --append\" docs\n>  4:  b67654334e6 =  4:  2db68a4ac7c test-lib-functions: document test_commit --no-tag\n>  5:  3a166c92063 =  5:  4ceba3d404b test-lib functions: add an --annotated option to \"test_commit\"\n>  6:  981fc43ee69 =  6:  589eaf7a078 describe tests: convert setup to use test_commit\n>  7:  15057cdecfe =  7:  a0fe0640148 test-lib functions: add --printf option to test_commit\n>  8:  5d437f53ec8 =  8:  7fb8849ce66 submodule tests: use symbolic-ref --short to discover branch name\n>  9:  9ee13ee71bc =  9:  f67245ba40d test-lib: reformat argument list in test_create_repo()\n> 10:  6ba568df9f4 = 10:  37338c88300 test-lib: do not show advice about init.defaultBranch under --verbose\n> 11:  311a9dba36b ! 11:  7793311e5f1 test-lib: split up and deprecate test_create_repo()\n>     @@ Commit message\n>              from \"mkdir .git/hooks\" changes various tests needed to re-setup\n>              that directory. Now they no longer do.\n>      \n>     -     5. Since we don't need to move the .git/hooks directory we don't need\n>     -        the subshell here either.\n>     -\n>     -        See 0d314ce834 for when the subshell use got introduced for the\n>     -        convenience of not having to \"cd\" back and forth while setting up\n>     -        the hooks.\n>     +        This makes us implicitly depend on the default hooks being\n>     +        disabled, which is a good thing. If and when we'd have any\n>     +        on-by-default hooks (I see no reason we ever would) we'd want to\n>     +        see the subtle and not so subtle ways that would break the test\n>     +        suite.\n>     +\n>     +     5. We don't need to \"cd\" to the \"$repo\" directory at all anymore.\n>     +\n>     +        In the code being removed here we both \"cd\"'d to the repository\n>     +        before calling \"init\", and did so in a subshell.\n>     +\n>     +        It's not important to do either, so both of those can be\n>     +        removed. We cd'd because this code grew from test-lib.sh code\n>     +        where we'd have done so already, see eedf8f97e58 (Abstract\n>     +        test_create_repo out for use in tests., 2006-02-17), and later\n>     +        \"cd\"'d inside a subshell since 0d314ce834d to avoid having to keep\n>     +        track of an \"old pwd\" variable to cd back after the setup.\n>     +\n>     +        Being in the repository directory made moving the hooks around\n>     +        easier (we wouldn't have to fully qualify the path). Since we're\n>     +        not moving the hooks per #4 above we don't need to \"cd\" for that\n>     +        reason either.\n>      \n>           6. We can drop the --template argument and instead rely on the\n>              GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n\n"},{"id":"423793","messageId":"YJQPW7r20jfSW28k@danh.dev","threadId":"55480","inReplyTo":"patch-01.11-75667f98f3a-20210423T072006Z-avarab@gmail.com","subject":"Re: [PATCH v5 01/11] test-lib: bring $remove_trash out of retirement","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-05-06T15:46:35Z","receivedAt":"2021-05-06T15:46:40Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-23 09:21:05+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> There's no point in creating a repository or directory only to decide\n> right afterwards that we're skipping all the tests. We can save\n> ourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\n> case.\n> \n> We carry around the \"$remove_trash\" variable because if the directory\n> is unexpectedly gone at test_done time we'll hit the error about it\n> being unexpectedly gone added in df4c0d1a792 (test-lib: abort when\n> can't remove trash directory, 2017-04-20).\n\ns/test_done time/&,/ perhaps?\n\nI guess it maybe only me (I'm not a native speaker of any Indo-European\nlanguages). But \"because if\" sounds weird to me. In my native tongue,\nI would say something like:\n\n\tWe carry around ... variable because we'll hit the error ...\n\tif the directory is expectedly gone ...\n\n> So let's partially revert 06478dab4c (test-lib: retire $remove_trash\n> variable, 2017-04-23) and move the decision about whether to skip all\n> tests earlier.\n> \n> Let's also fix a bug that was with us since abc5d372ec (Enable\n> parallel tests, 2008-08-08): we would leak $remove_trash from the\n> environment. We don't want this to error out, so let's reset it to the\n> empty string first:\n> \n>      remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh\n> \n> I tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\n> under --debug at the end of the test, 2017-04-24) for a bug we don't\n> want to re-introduce.\n> \n> While I'm at it let's move the HOME assignment to just before\n\ns/at it/&,/ too?\n\n> test_create_repo, it could be lower, but it seems better to set it\n> before calling anything in test-lib-functions.sh\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/test-lib.sh | 32 ++++++++++++++++++--------------\n>  1 file changed, 18 insertions(+), 14 deletions(-)\n> \n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 3dec266221c..105c424bf56 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -1169,7 +1169,7 @@ test_done () {\n>  \t\t\tesac\n>  \t\tfi\n>  \n> -\t\tif test -z \"$debug\"\n> +\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n>  \t\tthen\n>  \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n>  \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n> @@ -1334,6 +1334,22 @@ then\n>  \texit 1\n>  fi\n>  \n> +# Are we running this test at all?\n> +remove_trash=\n> +this_test=${0##*/}\n> +this_test=${this_test%%-*}\n> +if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n> +then\n> +\tsay_color info >&3 \"skipping test $this_test altogether\"\n> +\tskip_all=\"skip all tests in $this_test\"\n> +\ttest_done\n> +fi\n> +\n> +# Last-minute variable setup\n> +HOME=\"$TRASH_DIRECTORY\"\n> +GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n> +export HOME GNUPGHOME\n> +\n>  # Test repository\n>  rm -fr \"$TRASH_DIRECTORY\" || {\n>  \tGIT_EXIT_OK=t\n> @@ -1341,10 +1357,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n>  \texit 1\n>  }\n>  \n> -HOME=\"$TRASH_DIRECTORY\"\n> -GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n> -export HOME GNUPGHOME\n> -\n> +remove_trash=t\n>  if test -z \"$TEST_NO_CREATE_REPO\"\n>  then\n>  \ttest_create_repo \"$TRASH_DIRECTORY\"\n> @@ -1356,15 +1369,6 @@ fi\n>  # in subprocesses like git equals our $PWD (for pathname comparisons).\n>  cd -P \"$TRASH_DIRECTORY\" || exit 1\n>  \n> -this_test=${0##*/}\n> -this_test=${this_test%%-*}\n> -if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n> -then\n> -\tsay_color info >&3 \"skipping test $this_test altogether\"\n> -\tskip_all=\"skip all tests in $this_test\"\n> -\ttest_done\n> -fi\n> -\n>  if test -n \"$write_junit_xml\"\n>  then\n>  \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n> -- \n> 2.31.1.737.g98b508eba36\n> \n\n-- \nDanh\n"},{"id":"423794","messageId":"YJQSCKlS5bZixZ5z@danh.dev","threadId":"55480","inReplyTo":"patch-06.11-589eaf7a078-20210423T072006Z-avarab@gmail.com","subject":"Re: [PATCH v5 06/11] describe tests: convert setup to use test_commit","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-05-06T15:58:00Z","receivedAt":"2021-05-06T15:58:09Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-23 09:21:10+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> Convert the setup of the describe tests to use test_commit when\n> possible. This makes use of the new --annotated-tag option to\n\ns/--annotated-tag/--annotate/\n\nOtherwise, looks correct.\n\n> test_commit.\n> \n> Some of the setup here could simply be removed since the data being\n> created wasn't important to any of the subsequent tests, so I've done\n> so. E.g. assigning to the \"one\" variable was always useless, and just\n> checking that we can describe HEAD after the first commit wasn't\n> useful.\n> \n> In the case of the \"two\" variable we could instead use the tag we just\n> created. See 5312ab11fbf (Add describe test., 2007-01-13) for the\n> initial version of this code. There's other cases here like redundant\n> \"test_tick\" invocations, or the simplification of not echoing \"X\" to a\n> file we're about to tag as \"x\", now we just use \"x\" in both cases.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\n-- \nDanh\n"},{"id":"423795","messageId":"YJQUZfbJXuWm+7Yf@danh.dev","threadId":"55480","inReplyTo":"patch-07.11-a0fe0640148-20210423T072006Z-avarab@gmail.com","subject":"Re: [PATCH v5 07/11] test-lib functions: add --printf option to test_commit","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-05-06T16:08:05Z","receivedAt":"2021-05-06T16:08:11Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-04-23 09:21:11+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 827c8502b10..701518f5fd3 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -173,6 +173,10 @@ debug () {\n>  #\tDo not call test_tick before making a commit\n>  #   --append\n>  #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n> +#   --printf\n> +#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n> +#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n> +#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n\nThis is the second appearance of \"You\" in this file, and it's the\nfirst in the usage of test_commit\nPerhaps:\n\n\tTrailing \"\\n\" won't be added automatically. This option\n\tsupports nothing but the FORMAT of printf(1),\n\tnot even its ARGUMENT(s).\n\nOr something along the line.\n\n>  #   --signoff\n>  #\tInvoke \"git commit\" with --signoff\n>  #   --author <author>\n\n-- \nDanh\n"},{"id":"423796","messageId":"YJQXbVYOYPHb5Kd7@danh.dev","threadId":"55480","inReplyTo":"87eeejvpuy.fsf@evledraar.gmail.com","subject":"Re: [PATCH v5 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-05-06T16:21:01Z","receivedAt":"2021-05-06T16:21:05Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-05-06 17:32:01+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> \n> On Fri, Apr 23 2021, Ævar Arnfjörð Bjarmason wrote:\n> \n> > Changes since v4: Only a commit message change/re-wording per\n> > <87v98e1oj7.fsf@evledraar.gmail.com>.\n> \n> SZEDER, Eric, Đoàn et al: does this v5 look good to you? Junio's\n> suggested in [1] that this needs some final review feedback before\n> advancing to 'next'. If you could take a look that would be great!\n\nI have some minor nit-picks here and there, I didn't look into 11/11.\nOtherwise, I think the series is fine, now.\n\n-- \nDanh\n"},{"id":"424032","messageId":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com","subject":"[PATCH v6 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:18:59Z","receivedAt":"2021-05-10T15:12:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Changes since v5 only trivial commit message / comment fixes suggested\nby Đoàn Trần Công Danh. Thanks! Link to v5:\nhttp://lore.kernel.org/git/cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com\n\nÆvar Arnfjörð Bjarmason (11):\n  test-lib: bring $remove_trash out of retirement\n  test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n  test-lib-functions: reword \"test_commit --append\" docs\n  test-lib-functions: document test_commit --no-tag\n  test-lib functions: add an --annotated option to \"test_commit\"\n  describe tests: convert setup to use test_commit\n  test-lib functions: add --printf option to test_commit\n  submodule tests: use symbolic-ref --short to discover branch name\n  test-lib: reformat argument list in test_create_repo()\n  test-lib: do not show advice about init.defaultBranch under --verbose\n  test-lib: split up and deprecate test_create_repo()\n\n t/lib-submodule-update.sh           |  3 +-\n t/t0000-basic.sh                    |  4 --\n t/t1307-config-blob.sh              |  4 +-\n t/t1403-show-ref.sh                 |  6 +--\n t/t2030-unresolve-info.sh           |  3 +-\n t/t4006-diff-mode.sh                |  6 +--\n t/t4030-diff-textconv.sh            |  8 +---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 -\n t/t5409-colorize-remote-messages.sh |  1 -\n t/t5520-pull.sh                     | 10 +----\n t/t6120-describe.sh                 | 58 ++++++---------------------\n t/test-lib-functions.sh             | 62 ++++++++++++++++++-----------\n t/test-lib.sh                       | 40 ++++++++++++-------\n 14 files changed, 89 insertions(+), 119 deletions(-)\n\nRange-diff against v5:\n 1:  75667f98f3a !  1:  febf98e87a1 test-lib: bring $remove_trash out of retirement\n    @@ Commit message\n         case.\n     \n         We carry around the \"$remove_trash\" variable because if the directory\n    -    is unexpectedly gone at test_done time we'll hit the error about it\n    -    being unexpectedly gone added in df4c0d1a792 (test-lib: abort when\n    -    can't remove trash directory, 2017-04-20).\n    +    is unexpectedly gone at test_done time we'll still want to hit the\n    +    \"trash directory already removed\" error, but not if we never created\n    +    the trash directory. See df4c0d1a792 (test-lib: abort when can't\n    +    remove trash directory, 2017-04-20) for the addition of that error.\n     \n         So let's partially revert 06478dab4c (test-lib: retire $remove_trash\n         variable, 2017-04-23) and move the decision about whether to skip all\n    @@ Commit message\n         under --debug at the end of the test, 2017-04-24) for a bug we don't\n         want to re-introduce.\n     \n    -    While I'm at it let's move the HOME assignment to just before\n    +    While I'm at it, let's move the HOME assignment to just before\n         test_create_repo, it could be lower, but it seems better to set it\n         before calling anything in test-lib-functions.sh\n     \n 2:  55c9413f9cd =  2:  6f360e37e84 test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable\n 3:  361e34654e9 =  3:  c2a0140fcd9 test-lib-functions: reword \"test_commit --append\" docs\n 4:  2db68a4ac7c =  4:  1a675a6cfe5 test-lib-functions: document test_commit --no-tag\n 5:  4ceba3d404b =  5:  2e0d69209e9 test-lib functions: add an --annotated option to \"test_commit\"\n 6:  589eaf7a078 !  6:  07e8b63596b describe tests: convert setup to use test_commit\n    @@ Commit message\n         describe tests: convert setup to use test_commit\n     \n         Convert the setup of the describe tests to use test_commit when\n    -    possible. This makes use of the new --annotated-tag option to\n    -    test_commit.\n    +    possible. This makes use of the new --annotate option to test_commit.\n     \n         Some of the setup here could simply be removed since the data being\n         created wasn't important to any of the subsequent tests, so I've done\n 7:  a0fe0640148 !  7:  5aaeadf01ff test-lib functions: add --printf option to test_commit\n    @@ t/test-lib-functions.sh: debug () {\n      #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n     +#   --printf\n     +#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n    -+#       \"<file>\". You will need to provide your own trailing \"\\n\". You\n    -+#       can only supply the FORMAT for the printf(1), not its ARGUMENT(s).\n    ++#       \"<file>\", use this to write escape sequences such as \"\\0\", a\n    ++#       trailing \"\\n\" won't be added automatically. This option\n    ++#       supports nothing but the FORMAT of printf(1), i.e. no custom\n    ++#       ARGUMENT(s).\n      #   --signoff\n      #\tInvoke \"git commit\" with --signoff\n      #   --author <author>\n 8:  7fb8849ce66 =  8:  0b31b1ffeff submodule tests: use symbolic-ref --short to discover branch name\n 9:  f67245ba40d =  9:  c806f3888c5 test-lib: reformat argument list in test_create_repo()\n10:  37338c88300 = 10:  105a95fb7a0 test-lib: do not show advice about init.defaultBranch under --verbose\n11:  7793311e5f1 = 11:  217c5aed491 test-lib: split up and deprecate test_create_repo()\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424033","messageId":"patch-01.11-febf98e87a1-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 01/11] test-lib: bring $remove_trash out of retirement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:00Z","receivedAt":"2021-05-10T15:12:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There's no point in creating a repository or directory only to decide\nright afterwards that we're skipping all the tests. We can save\nourselves the redundant \"git init\" or \"mkdir\" and \"rm -rf\" in this\ncase.\n\nWe carry around the \"$remove_trash\" variable because if the directory\nis unexpectedly gone at test_done time we'll still want to hit the\n\"trash directory already removed\" error, but not if we never created\nthe trash directory. See df4c0d1a792 (test-lib: abort when can't\nremove trash directory, 2017-04-20) for the addition of that error.\n\nSo let's partially revert 06478dab4c (test-lib: retire $remove_trash\nvariable, 2017-04-23) and move the decision about whether to skip all\ntests earlier.\n\nLet's also fix a bug that was with us since abc5d372ec (Enable\nparallel tests, 2008-08-08): we would leak $remove_trash from the\nenvironment. We don't want this to error out, so let's reset it to the\nempty string first:\n\n     remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh\n\nI tested this with --debug, see 4d0912a206 (test-lib.sh: do not barf\nunder --debug at the end of the test, 2017-04-24) for a bug we don't\nwant to re-introduce.\n\nWhile I'm at it, let's move the HOME assignment to just before\ntest_create_repo, it could be lower, but it seems better to set it\nbefore calling anything in test-lib-functions.sh\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 32 ++++++++++++++++++--------------\n 1 file changed, 18 insertions(+), 14 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex adaa2db6014..7647afcfd0a 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1169,7 +1169,7 @@ test_done () {\n \t\t\tesac\n \t\tfi\n \n-\t\tif test -z \"$debug\"\n+\t\tif test -z \"$debug\" && test -n \"$remove_trash\"\n \t\tthen\n \t\t\ttest -d \"$TRASH_DIRECTORY\" ||\n \t\t\terror \"Tests passed but trash directory already removed before test cleanup; aborting\"\n@@ -1334,6 +1334,22 @@ then\n \texit 1\n fi\n \n+# Are we running this test at all?\n+remove_trash=\n+this_test=${0##*/}\n+this_test=${this_test%%-*}\n+if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n+then\n+\tsay_color info >&3 \"skipping test $this_test altogether\"\n+\tskip_all=\"skip all tests in $this_test\"\n+\ttest_done\n+fi\n+\n+# Last-minute variable setup\n+HOME=\"$TRASH_DIRECTORY\"\n+GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n+export HOME GNUPGHOME\n+\n # Test repository\n rm -fr \"$TRASH_DIRECTORY\" || {\n \tGIT_EXIT_OK=t\n@@ -1341,10 +1357,7 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n \texit 1\n }\n \n-HOME=\"$TRASH_DIRECTORY\"\n-GNUPGHOME=\"$HOME/gnupg-home-not-used\"\n-export HOME GNUPGHOME\n-\n+remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n \ttest_create_repo \"$TRASH_DIRECTORY\"\n@@ -1356,15 +1369,6 @@ fi\n # in subprocesses like git equals our $PWD (for pathname comparisons).\n cd -P \"$TRASH_DIRECTORY\" || exit 1\n \n-this_test=${0##*/}\n-this_test=${this_test%%-*}\n-if match_pattern_list \"$this_test\" $GIT_SKIP_TESTS\n-then\n-\tsay_color info >&3 \"skipping test $this_test altogether\"\n-\tskip_all=\"skip all tests in $this_test\"\n-\ttest_done\n-fi\n-\n if test -n \"$write_junit_xml\"\n then\n \tjunit_xml_dir=\"$TEST_OUTPUT_DIRECTORY/out\"\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424034","messageId":"patch-02.11-6f360e37e84-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 02/11] test-lib tests: remove dead GIT_TEST_FRAMEWORK_SELFTEST variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:01Z","receivedAt":"2021-05-10T15:12:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop setting the GIT_TEST_FRAMEWORK_SELFTEST variable. This was originally needed\nback in 4231d1ba99 (t0000: do not get self-test disrupted by\nenvironment warnings, 2018-09-20).\n\nIt hasn't been needed since I deleted the relevant code in test-lib.sh\nin c0eedbc009 (test-lib: remove check_var_migration, 2021-02-09), I\njust didn't notice that it was set here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 705d62cc27a..2c6e34b9478 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -84,10 +84,6 @@ _run_sub_test_lib_test_common () {\n \t\tpassing metrics\n \t\t'\n \n-\t\t# Tell the framework that we are self-testing to make sure\n-\t\t# it yields a stable result.\n-\t\tGIT_TEST_FRAMEWORK_SELFTEST=t &&\n-\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424035","messageId":"patch-03.11-c2a0140fcd9-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 03/11] test-lib-functions: reword \"test_commit --append\" docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:02Z","receivedAt":"2021-05-10T15:14:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword the documentation for \"test_commit --append\" added in my\n3373518cc8 (test-lib functions: add an --append option to test_commit,\n2021-01-12).\n\nA follow-up commit will make the \"echo\" part of this configurable, and\nin any case saying \"echo >>\" rather than \">>\" was redundant.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex b823c140271..1f787ff0726 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -172,8 +172,7 @@ debug () {\n #   --notick\n #\tDo not call test_tick before making a commit\n #   --append\n-#\tUse \"echo >>\" instead of \"echo >\" when writing \"<contents>\" to\n-#\t\"<file>\"\n+#\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424036","messageId":"patch-04.11-1a675a6cfe5-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 04/11] test-lib-functions: document test_commit --no-tag","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:03Z","receivedAt":"2021-05-10T15:15:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 76b8b8d05c (test-lib functions: document arguments to test_commit,\n2021-01-12) I added missing documentation to test_commit, but in less\nthan a month later in 3803a3a099 (t: add --no-tag option to\ntest_commit, 2021-02-09) we got another undocumented option. Let's fix\nthat.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 1f787ff0726..c6d07f4ce32 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -177,6 +177,8 @@ debug () {\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n #\tInvoke \"git commit\" with --author <author>\n+#   --no-tag\n+#\tDo not tag the resulting commit\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424037","messageId":"patch-05.11-2e0d69209e9-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 05/11] test-lib functions: add an --annotated option to \"test_commit\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:04Z","receivedAt":"2021-05-10T15:15:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an --annotated option to test_commit to create annotated tags. The\ntag will share the same message as the commit, and we'll call\ntest_tick before creating it (unless --notick) is provided.\n\nThere's quite a few tests that could be simplified with this\nconstruct. I've picked one to convert in this change as a\ndemonstration.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1403-show-ref.sh     |  6 ++----\n t/test-lib-functions.sh | 27 ++++++++++++++++++++++-----\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex 6ce62f878c3..17d3cc14050 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . ./test-lib.sh\n \n test_expect_success setup '\n-\ttest_commit A &&\n-\tgit tag -f -a -m \"annotated A\" A &&\n+\ttest_commit --annotate A &&\n \tgit checkout -b side &&\n-\ttest_commit B &&\n-\tgit tag -f -a -m \"annotated B\" B &&\n+\ttest_commit --annotate B &&\n \tgit checkout main &&\n \ttest_commit C &&\n \tgit branch B A^0\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c6d07f4ce32..827c8502b10 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -179,6 +179,10 @@ debug () {\n #\tInvoke \"git commit\" with --author <author>\n #   --no-tag\n #\tDo not tag the resulting commit\n+#   --annotate\n+#\tCreate an annotated tag with \"--annotate -m <message>\". Calls\n+#\ttest_tick between making the commit and tag, unless --notick\n+#\tis given.\n #\n # This will commit a file with the given contents and the given commit\n # message, and tag the resulting commit with the given tag name.\n@@ -191,7 +195,7 @@ test_commit () {\n \tauthor= &&\n \tsignoff= &&\n \tindir= &&\n-\tno_tag= &&\n+\ttag=light &&\n \twhile test $# != 0\n \tdo\n \t\tcase \"$1\" in\n@@ -219,7 +223,10 @@ test_commit () {\n \t\t\tshift\n \t\t\t;;\n \t\t--no-tag)\n-\t\t\tno_tag=yes\n+\t\t\ttag=none\n+\t\t\t;;\n+\t\t--annotate)\n+\t\t\ttag=annotate\n \t\t\t;;\n \t\t*)\n \t\t\tbreak\n@@ -243,10 +250,20 @@ test_commit () {\n \tgit ${indir:+ -C \"$indir\"} commit \\\n \t    ${author:+ --author \"$author\"} \\\n \t    $signoff -m \"$1\" &&\n-\tif test -z \"$no_tag\"\n-\tthen\n+\tcase \"$tag\" in\n+\tnone)\n+\t\t;;\n+\tlight)\n \t\tgit ${indir:+ -C \"$indir\"} tag \"${4:-$1}\"\n-\tfi\n+\t\t;;\n+\tannotate)\n+\t\tif test -z \"$notick\"\n+\t\tthen\n+\t\t\ttest_tick\n+\t\tfi &&\n+\t\tgit ${indir:+ -C \"$indir\"} tag -a -m \"$1\" \"${4:-$1}\"\n+\t\t;;\n+\tesac\n }\n \n # Call test_merge with the arguments \"<message> <commit>\", where <commit>\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424039","messageId":"patch-06.11-07e8b63596b-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 06/11] describe tests: convert setup to use test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:05Z","receivedAt":"2021-05-10T15:15:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Convert the setup of the describe tests to use test_commit when\npossible. This makes use of the new --annotate option to test_commit.\n\nSome of the setup here could simply be removed since the data being\ncreated wasn't important to any of the subsequent tests, so I've done\nso. E.g. assigning to the \"one\" variable was always useless, and just\nchecking that we can describe HEAD after the first commit wasn't\nuseful.\n\nIn the case of the \"two\" variable we could instead use the tag we just\ncreated. See 5312ab11fbf (Add describe test., 2007-01-13) for the\ninitial version of this code. There's other cases here like redundant\n\"test_tick\" invocations, or the simplification of not echoing \"X\" to a\nfile we're about to tag as \"x\", now we just use \"x\" in both cases.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t6120-describe.sh | 58 ++++++++++-----------------------------------\n 1 file changed, 13 insertions(+), 45 deletions(-)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex e89b6747bee..88fddc91424 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -31,64 +31,32 @@ check_describe () {\n }\n \n test_expect_success setup '\n+\ttest_commit initial file one &&\n+\ttest_commit second file two &&\n+\ttest_commit third file three &&\n+\ttest_commit --annotate A file A &&\n+\ttest_commit c file c &&\n \n-\ttest_tick &&\n-\techo one >file && git add file && git commit -m initial &&\n-\tone=$(git rev-parse HEAD) &&\n-\n-\tgit describe --always HEAD &&\n-\n-\ttest_tick &&\n-\techo two >file && git add file && git commit -m second &&\n-\ttwo=$(git rev-parse HEAD) &&\n-\n-\ttest_tick &&\n-\techo three >file && git add file && git commit -m third &&\n-\n-\ttest_tick &&\n-\techo A >file && git add file && git commit -m A &&\n-\ttest_tick &&\n-\tgit tag -a -m A A &&\n-\n-\ttest_tick &&\n-\techo c >file && git add file && git commit -m c &&\n-\ttest_tick &&\n-\tgit tag c &&\n-\n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo B >side && git add side && git commit -m B &&\n-\ttest_tick &&\n-\tgit tag -a -m B B &&\n+\tgit reset --hard second &&\n+\ttest_commit --annotate B side B &&\n \n \ttest_tick &&\n \tgit merge -m Merged c &&\n \tmerged=$(git rev-parse HEAD) &&\n \n-\tgit reset --hard $two &&\n-\ttest_tick &&\n-\techo D >another && git add another && git commit -m D &&\n-\ttest_tick &&\n-\tgit tag -a -m D D &&\n-\ttest_tick &&\n-\tgit tag -a -m R R &&\n-\n-\ttest_tick &&\n-\techo DD >another && git commit -a -m another &&\n+\tgit reset --hard second &&\n+\ttest_commit --no-tag D another D &&\n \n \ttest_tick &&\n-\tgit tag e &&\n+\tgit tag -a -m R R &&\n \n-\ttest_tick &&\n-\techo DDD >another && git commit -a -m \"yet another\" &&\n+\ttest_commit e another DD &&\n+\ttest_commit --no-tag \"yet another\" another DDD &&\n \n \ttest_tick &&\n \tgit merge -m Merged $merged &&\n \n-\ttest_tick &&\n-\techo X >file && echo X >side && git add file side &&\n-\tgit commit -m x\n-\n+\ttest_commit --no-tag x file\n '\n \n check_describe A-* HEAD\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424038","messageId":"patch-07.11-5aaeadf01ff-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 07/11] test-lib functions: add --printf option to test_commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:06Z","receivedAt":"2021-05-10T15:15:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --printf option to test_commit to allow writing to the file with\n\"printf\" instead of \"echo\".\n\nThis is useful for writing \"\\n\", \"\\0\" etc., in particular in\ncombination with the --append option added in 3373518cc8 (test-lib\nfunctions: add an --append option to test_commit, 2021-01-12).\n\nI'm converting a few tests to use the new option rather than a manual\nprintf/add/commit combination to demonstrate its usefulness. While I'm\nat it use \"test_create_repo\" where appropriate, and give the\nfirst/second commit a meaningful/more conventional log message in\ncases where no test cared about that message.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t1307-config-blob.sh    |  4 +---\n t/t2030-unresolve-info.sh |  3 +--\n t/t4006-diff-mode.sh      |  6 ++----\n t/t4030-diff-textconv.sh  |  8 ++------\n t/t5520-pull.sh           | 10 ++--------\n t/test-lib-functions.sh   | 14 ++++++++++++--\n 6 files changed, 20 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t1307-config-blob.sh b/t/t1307-config-blob.sh\nindex 002e6d3388e..930dce06f0f 100755\n--- a/t/t1307-config-blob.sh\n+++ b/t/t1307-config-blob.sh\n@@ -65,9 +65,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '\n '\n \n test_expect_success 'can parse blob ending with CR' '\n-\tprintf \"[some]key = value\\\\r\" >config &&\n-\tgit add config &&\n-\tgit commit -m CR &&\n+\ttest_commit --printf CR config \"[some]key = value\\\\r\" &&\n \techo value >expect &&\n \tgit config --blob=HEAD:config some.key >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh\nindex be6c84c52a2..f691e6d9032 100755\n--- a/t/t2030-unresolve-info.sh\n+++ b/t/t2030-unresolve-info.sh\n@@ -179,8 +179,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' '\n \n test_expect_success 'rerere forget (binary)' '\n \tgit checkout -f side &&\n-\tprintf \"a\\0c\" >binary &&\n-\tgit commit -a -m binary &&\n+\ttest_commit --printf binary binary \"a\\0c\" &&\n \ttest_must_fail git merge second &&\n \tgit rerere forget binary\n '\ndiff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh\nindex 275ce5fa15b..6cdee2a2164 100755\n--- a/t/t4006-diff-mode.sh\n+++ b/t/t4006-diff-mode.sh\n@@ -26,10 +26,8 @@ test_expect_success 'chmod' '\n '\n \n test_expect_success 'prepare binary file' '\n-\tgit commit -m rezrov &&\n-\tprintf \"\\00\\01\\02\\03\\04\\05\\06\" >binbin &&\n-\tgit add binbin &&\n-\tgit commit -m binbin\n+\tgit commit -m one &&\n+\ttest_commit --printf two binbin \"\\00\\01\\02\\03\\04\\05\\06\"\n '\n \n test_expect_success '--stat output after text chmod' '\ndiff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh\nindex c906320b60d..a39a626664d 100755\n--- a/t/t4030-diff-textconv.sh\n+++ b/t/t4030-diff-textconv.sh\n@@ -26,12 +26,8 @@ EOF\n chmod +x hexdump\n \n test_expect_success 'setup binary file with history' '\n-\tprintf \"\\\\0\\\\n\" >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\tprintf \"\\\\01\\\\n\" >>file &&\n-\tgit add file &&\n-\tgit commit -m two\n+\ttest_commit --printf one file \"\\\\0\\\\n\" &&\n+\ttest_commit --printf --append two file \"\\\\01\\\\n\"\n '\n \n test_expect_success 'file is considered binary by porcelain' '\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex a09411327f9..e2c0c510222 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -746,14 +746,8 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '\n '\n \n test_expect_success 'setup for detecting upstreamed changes' '\n-\tmkdir src &&\n-\t(\n-\t\tcd src &&\n-\t\tgit init &&\n-\t\tprintf \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" > stuff &&\n-\t\tgit add stuff &&\n-\t\tgit commit -m \"Initial revision\"\n-\t) &&\n+\ttest_create_repo src &&\n+\ttest_commit -C src --printf one stuff \"1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n\" &&\n \tgit clone src dst &&\n \t(\n \t\tcd src &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 827c8502b10..b242ecf5cd2 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -173,6 +173,12 @@ debug () {\n #\tDo not call test_tick before making a commit\n #   --append\n #\tUse \">>\" instead of \">\" when writing \"<contents>\" to \"<file>\"\n+#   --printf\n+#       Use \"printf\" instead of \"echo\" when writing \"<contents>\" to\n+#       \"<file>\", use this to write escape sequences such as \"\\0\", a\n+#       trailing \"\\n\" won't be added automatically. This option\n+#       supports nothing but the FORMAT of printf(1), i.e. no custom\n+#       ARGUMENT(s).\n #   --signoff\n #\tInvoke \"git commit\" with --signoff\n #   --author <author>\n@@ -191,6 +197,7 @@ debug () {\n \n test_commit () {\n \tnotick= &&\n+\techo=echo &&\n \tappend= &&\n \tauthor= &&\n \tsignoff= &&\n@@ -202,6 +209,9 @@ test_commit () {\n \t\t--notick)\n \t\t\tnotick=yes\n \t\t\t;;\n+\t\t--printf)\n+\t\t\techo=printf\n+\t\t\t;;\n \t\t--append)\n \t\t\tappend=yes\n \t\t\t;;\n@@ -238,9 +248,9 @@ test_commit () {\n \tfile=${2:-\"$1.t\"} &&\n \tif test -n \"$append\"\n \tthen\n-\t\techo \"${3-$1}\" >>\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >>\"$indir$file\"\n \telse\n-\t\techo \"${3-$1}\" >\"$indir$file\"\n+\t\t$echo \"${3-$1}\" >\"$indir$file\"\n \tfi &&\n \tgit ${indir:+ -C \"$indir\"} add \"$file\" &&\n \tif test -z \"$notick\"\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424040","messageId":"patch-08.11-0b31b1ffeff-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 08/11] submodule tests: use symbolic-ref --short to discover branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:07Z","receivedAt":"2021-05-10T15:15:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a use of $GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME added in\n704fed9ea22 (tests: start moving to a different default main branch\nname, 2020-10-23) to simply discover the initial branch name of a\nrepository set up in this function with \"symbolic-ref --short\".\n\nThat's something done in another test in 704fed9ea22, so doing it like\nthis seems like an omission, or rather an overly eager\nsearch/replacement instead of fixing the test logic.\n\nThere are only three uses of the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\nvariable in the test suite, this gets rid of one of those.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-submodule-update.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 4b714e93083..f7c7df0ca42 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -63,6 +63,7 @@ create_lib_submodule_repo () {\n \tgit init submodule_update_repo &&\n \t(\n \t\tcd submodule_update_repo &&\n+\t\tbranch=$(git symbolic-ref --short HEAD) &&\n \t\techo \"expect\" >>.gitignore &&\n \t\techo \"actual\" >>.gitignore &&\n \t\techo \"x\" >file1 &&\n@@ -144,7 +145,7 @@ create_lib_submodule_repo () {\n \t\tgit checkout -b valid_sub1 &&\n \t\tgit revert HEAD &&\n \n-\t\tgit checkout \"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\"\n+\t\tgit checkout \"$branch\"\n \t)\n }\n \n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424041","messageId":"patch-10.11-105a95fb7a0-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 10/11] test-lib: do not show advice about init.defaultBranch under --verbose","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:09Z","receivedAt":"2021-05-10T15:15:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Arrange for the advice about naming the initial branch not to be shown\nin the --verbose output of the test suite.\n\nSince 675704c74dd (init: provide useful advice about\ninit.defaultBranch, 2020-12-11) some tests have been very chatty with\nrepeated occurrences of this multi-line advice. Having it be this\nverbose isn't helpful for anyone in the context of git's own test\nsuite, and it makes debugging tests that use their own \"git init\"\ninvocations needlessly distracting.\n\nBy setting the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable early in\ntest-lib.sh itself we'll squash the warning not only for\ntest_create_repo(), as 675704c74dd explicitly intended, but also for\nother \"git init\" invocations.\n\nAnd once we'd like to have this configuration set for all \"git init\"\ninvocations in the test suite we can get rid of the init.defaultBranch\nconfiguration setting in test_create_repo(), as\nrepo_default_branch_name() in refs.c will take the GIT_TEST_* variable\nover it being set.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 1 -\n t/test-lib.sh           | 5 +++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 661597e9192..669645a812f 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1253,7 +1253,6 @@ test_create_repo () {\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n \t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7647afcfd0a..f3671b1766d 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -64,6 +64,11 @@ then\n \texport GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS\n fi\n \n+# Explicitly set the default branch name for testing, to avoid the\n+# transitory \"git init\" warning under --verbose.\n+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n ################################################################\n # It appears that people try to run tests without building...\n \"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X\" >/dev/null\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424042","messageId":"patch-09.11-c806f3888c5-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 09/11] test-lib: reformat argument list in test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:08Z","receivedAt":"2021-05-10T15:15:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reformat an argument list changed in 675704c74dd (init: provide useful\nadvice about init.defaultBranch, 2020-12-11) to have the \"-c\" on the\nsame line as the argument it sets. This whitespace-only change makes\nit easier to review a subsequent commit.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib-functions.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex b242ecf5cd2..661597e9192 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1252,8 +1252,8 @@ test_create_repo () {\n \tmkdir -p \"$repo\"\n \t(\n \t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" -c \\\n-\t\t\tinit.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n+\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n+\t\t\t-c init.defaultBranch=\"${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}\" \\\n \t\t\tinit \\\n \t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n \t\terror \"cannot run git init -- have you built things yet?\"\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424043","messageId":"patch-11.11-217c5aed491-20210510T141055Z-avarab@gmail.com","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"[PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-10T14:19:10Z","receivedAt":"2021-05-10T15:15:24Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove various redundant or obsolete code from the test_create_repo()\nfunction, and split up its use in test-lib.sh from what tests need\nfrom it.\n\nThis leave us with a pass-through wrapper for \"git init\" in\ntest-lib-functions.sh, in test-lib.sh we have the same, except for\nneeding to redirect stdout/stderr, and emitting an error ourselves if\nit fails. We don't need to error() ourselves when test_create_repo()\nis invoked, as the invocation will be a part of a test's \"&&\"-chain.\n\nEverything below this paragraph is a detailed summary of the history\nof test_create_repo() explaining why it's safe to remove the various\nthings it was doing:\n\n 1. \"mkdir -p\" isn't needed because \"git init\" itself will create\n    leading directories if needed.\n\n 2. Since we're now a simple wrapper for \"git init\" we don't need to\n    check that we have only one argument. If someone wants to run\n    \"test_create_repo --bare x\" that's OK.\n\n 3. We won't ever hit that \"Cannot setup test environment\"\n    error.\n\n    Checking the test environment sanity when doing \"git init\" dates\n    back to eea420693be (t0000: catch trivial pilot errors.,\n    2005-12-10) and 2ccd2027b01 (trivial: check, if t/trash directory\n    was successfully created, 2006-01-05).\n\n    We can also see it in another form a bit later in my own\n    0d314ce834d (test-lib: use subshell instead of cd $new && .. && cd\n    $old, 2010-08-30).\n\n    But since 2006f0adaee (t/test-lib: make sure Git has already been\n    built, 2012-09-17) we already check if we have a built git\n    earlier.\n\n    The one thing this was testing after that 2012 change was that\n    we'd just built \"git\", but not \"git-init\", but since\n    3af4c7156c4 (tests: respect GIT_TEST_INSTALLED when initializing\n    repositories, 2018-11-12) we invoke \"git\", not \"git-init\".\n\n    So all of that's been checked already, and we don't need to\n    re-check it here.\n\n 4. We don't need to move .git/hooks out of the way.\n\n    That dates back to c09a69a83e3 (Disable hooks during tests.,\n    2005-10-16), since then hooks became disabled by default in\n    f98f8cbac01 (Ship sample hooks with .sample suffix, 2008-06-24).\n\n    So the hooks were already disabled by default, but as can be seen\n    from \"mkdir .git/hooks\" changes various tests needed to re-setup\n    that directory. Now they no longer do.\n\n    This makes us implicitly depend on the default hooks being\n    disabled, which is a good thing. If and when we'd have any\n    on-by-default hooks (I see no reason we ever would) we'd want to\n    see the subtle and not so subtle ways that would break the test\n    suite.\n\n 5. We don't need to \"cd\" to the \"$repo\" directory at all anymore.\n\n    In the code being removed here we both \"cd\"'d to the repository\n    before calling \"init\", and did so in a subshell.\n\n    It's not important to do either, so both of those can be\n    removed. We cd'd because this code grew from test-lib.sh code\n    where we'd have done so already, see eedf8f97e58 (Abstract\n    test_create_repo out for use in tests., 2006-02-17), and later\n    \"cd\"'d inside a subshell since 0d314ce834d to avoid having to keep\n    track of an \"old pwd\" variable to cd back after the setup.\n\n    Being in the repository directory made moving the hooks around\n    easier (we wouldn't have to fully qualify the path). Since we're\n    not moving the hooks per #4 above we don't need to \"cd\" for that\n    reason either.\n\n 6. We can drop the --template argument and instead rely on the\n    GIT_TEMPLATE_DIR set to the same path earlier in test-lib.sh. See\n    8683a45d669 (Introduce GIT_TEMPLATE_DIR, 2006-12-19)\n\n 7. We only needed that \">&3 2>&4\" redirection when invoked from\n    test-lib.sh.\n\n    We could still invoke test_create_repo() there, but as the\n    invocation is now trivial and we don't have a good reason to use\n    test_create_repo() elsewhere let's call \"git init\" there\n    ourselves.\n\n 8. We didn't need to resolve \"git\" as\n    \"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" in test_create_repo(),\n    even for the use of test-lib.sh\n\n    PATH is already set up in test-lib.sh to start with\n    GIT_TEST_INSTALLED and/or GIT_EXEC_PATH before\n    test_create_repo() (now \"git init\") is called.. So we can simply\n    run \"git\" and rely on the PATH lookup choosing the right\n    executable.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5406-remote-rejects.sh           |  1 -\n t/t5407-post-rewrite-hook.sh        |  2 --\n t/t5409-colorize-remote-messages.sh |  1 -\n t/test-lib-functions.sh             | 15 ++-------------\n t/test-lib.sh                       |  3 ++-\n 5 files changed, 4 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh\nindex ff06f99649e..5c509db6fc3 100755\n--- a/t/t5406-remote-rejects.sh\n+++ b/t/t5406-remote-rejects.sh\n@@ -5,7 +5,6 @@ test_description='remote push rejects are reported by client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \texit 1\n \tEOF\ndiff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh\nindex 5bb23cc3a4e..6da8d760e28 100755\n--- a/t/t5407-post-rewrite-hook.sh\n+++ b/t/t5407-post-rewrite-hook.sh\n@@ -20,8 +20,6 @@ test_expect_success 'setup' '\n \tgit checkout main\n '\n \n-mkdir .git/hooks\n-\n cat >.git/hooks/post-rewrite <<EOF\n #!/bin/sh\n echo \\$@ > \"$TRASH_DIRECTORY\"/post-rewrite.args\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5d8f401d8ec..9f1a483f426 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -5,7 +5,6 @@ test_description='remote messages are colorized on the client'\n . ./test-lib.sh\n \n test_expect_success 'setup' '\n-\tmkdir .git/hooks &&\n \twrite_script .git/hooks/update <<-\\EOF &&\n \techo error: error\n \techo ERROR: also highlighted\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 669645a812f..f0448daa74b 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1243,21 +1243,10 @@ test_atexit () {\n \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n }\n \n-# Most tests can use the created repository, but some may need to create more.\n+# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n # Usage: test_create_repo <directory>\n test_create_repo () {\n-\ttest \"$#\" = 1 ||\n-\tBUG \"not 1 parameter to test-create-repo\"\n-\trepo=\"$1\"\n-\tmkdir -p \"$repo\"\n-\t(\n-\t\tcd \"$repo\" || error \"Cannot setup test environment\"\n-\t\t\"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X\" \\\n-\t\t\tinit \\\n-\t\t\t\"--template=$GIT_BUILD_DIR/templates/blt/\" >&3 2>&4 ||\n-\t\terror \"cannot run git init -- have you built things yet?\"\n-\t\tmv .git/hooks .git/hooks-disabled\n-\t) || exit\n+\tgit init \"$@\"\n }\n \n # This function helps on symlink challenged file systems when it is not\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex f3671b1766d..e6ca7a22826 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1365,7 +1365,8 @@ rm -fr \"$TRASH_DIRECTORY\" || {\n remove_trash=t\n if test -z \"$TEST_NO_CREATE_REPO\"\n then\n-\ttest_create_repo \"$TRASH_DIRECTORY\"\n+\tgit init \"$TRASH_DIRECTORY\" >&3 2>&4 ||\n+\terror \"cannot run git init\"\n else\n \tmkdir -p \"$TRASH_DIRECTORY\"\n fi\n-- \n2.31.1.838.g924d365b763\n\n"},{"id":"424320","messageId":"YJvH78MxAWy+Xg6e@danh.dev","threadId":"55480","inReplyTo":"cover-00.11-00000000000-20210510T141055Z-avarab@gmail.com","subject":"Re: [PATCH v6 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-05-12T12:19:59Z","receivedAt":"2021-05-12T12:20:04Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2021-05-10 16:18:59+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n> Changes since v5 only trivial commit message / comment fixes suggested\n> by Đoàn Trần Công Danh. Thanks! Link to v5:\n> http://lore.kernel.org/git/cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com\n\nI skimmed over this series and I think it's in a good shape now.\nSo, FWIW.\n\nAcked-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n\n-- \nDanh\n"},{"id":"424399","messageId":"xmqqbl9feds1.fsf@gitster.g","threadId":"55480","inReplyTo":"YJvH78MxAWy+Xg6e@danh.dev","subject":"Re: [PATCH v6 00/11] test-lib.sh: new test_commit args, simplification & fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-12T23:24:46Z","receivedAt":"2021-05-12T23:32:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n> On 2021-05-10 16:18:59+0200, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>> Changes since v5 only trivial commit message / comment fixes suggested\n>> by Đoàn Trần Công Danh. Thanks! Link to v5:\n>> http://lore.kernel.org/git/cover-00.11-00000000000-20210423T072006Z-avarab@gmail.com\n>\n> I skimmed over this series and I think it's in a good shape now.\n> So, FWIW.\n>\n> Acked-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n\nThanks.\n"},{"id":"424427","messageId":"609ccaf67710b_3293208be@natae.notmuch","threadId":"55480","inReplyTo":"patch-11.11-217c5aed491-20210510T141055Z-avarab@gmail.com","subject":"RE: [PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-13T06:45:10Z","receivedAt":"2021-05-13T06:45:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1243,21 +1243,10 @@ test_atexit () {\n>  \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n>  }\n>  \n> -# Most tests can use the created repository, but some may need to create more.\n> +# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n>  # Usage: test_create_repo <directory>\n>  test_create_repo () {\n\nIf this is deprecated why not add a warning?\n\n  echo \"warning: test_create_repo is deprecated in favor of git init\" >&2\n\n-- \nFelipe Contreras"},{"id":"424438","messageId":"87pmxvrs73.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"609ccaf67710b_3293208be@natae.notmuch","subject":"Re: [PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-13T07:45:18Z","receivedAt":"2021-05-13T07:47:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, May 13 2021, Felipe Contreras wrote:\n\n> Ævar Arnfjörð Bjarmason wrote:\n>> --- a/t/test-lib-functions.sh\n>> +++ b/t/test-lib-functions.sh\n>> @@ -1243,21 +1243,10 @@ test_atexit () {\n>>  \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n>>  }\n>>  \n>> -# Most tests can use the created repository, but some may need to create more.\n>> +# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n>>  # Usage: test_create_repo <directory>\n>>  test_create_repo () {\n>\n> If this is deprecated why not add a warning?\n>\n>   echo \"warning: test_create_repo is deprecated in favor of git init\" >&2\n\nBecause like test_i18ncmp, test_i18ngrep or whatever this is in the\nstate of \"don't use this for new code\", but annoying everyone who runs\nthe test suite with loads of this output under -v would be too\ndistracting.\n\nThe attention of the developer community is much better spent on one\nperson doing a s/test_create_repo/git init/ patch than having everyone\nsee this warning until somebody does that.\n"},{"id":"424446","messageId":"609ce1fd6b614_5a8208e3@natae.notmuch","threadId":"55480","inReplyTo":"87pmxvrs73.fsf@evledraar.gmail.com","subject":"Re: [PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-13T08:23:25Z","receivedAt":"2021-05-13T08:23:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n> \n> On Thu, May 13 2021, Felipe Contreras wrote:\n> \n> > Ævar Arnfjörð Bjarmason wrote:\n> >> --- a/t/test-lib-functions.sh\n> >> +++ b/t/test-lib-functions.sh\n> >> @@ -1243,21 +1243,10 @@ test_atexit () {\n> >>  \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n> >>  }\n> >>  \n> >> -# Most tests can use the created repository, but some may need to create more.\n> >> +# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n> >>  # Usage: test_create_repo <directory>\n> >>  test_create_repo () {\n> >\n> > If this is deprecated why not add a warning?\n> >\n> >   echo \"warning: test_create_repo is deprecated in favor of git init\" >&2\n> \n> Because like test_i18ncmp, test_i18ngrep or whatever this is in the\n> state of \"don't use this for new code\", but annoying everyone who runs\n> the test suite with loads of this output under -v would be too\n> distracting.\n> \n> The attention of the developer community is much better spent on one\n> person doing a s/test_create_repo/git init/ patch than having everyone\n> see this warning until somebody does that.\n\nThen it's not really deprecated; it's merely disfavored.\n\nTo deprecate means to express disapproval of. If we are not going to\nexpress disapproval (i.e. annoy the users of the test suite), then it's\nnot really deprecated. You can't eat your cake and have it too.\n\nI agree we shouldn't throw a warning right now, but at some point in the\nfuture we should, *then* it will be deprecated.\n\nCheers.\n\n-- \nFelipe Contreras"},{"id":"424464","messageId":"87eeeasumj.fsf@evledraar.gmail.com","threadId":"55480","inReplyTo":"609ce1fd6b614_5a8208e3@natae.notmuch","subject":"Re: [PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-05-13T12:05:36Z","receivedAt":"2021-05-13T12:11:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, May 13 2021, Felipe Contreras wrote:\n\n> Ævar Arnfjörð Bjarmason wrote:\n>> \n>> On Thu, May 13 2021, Felipe Contreras wrote:\n>> \n>> > Ævar Arnfjörð Bjarmason wrote:\n>> >> --- a/t/test-lib-functions.sh\n>> >> +++ b/t/test-lib-functions.sh\n>> >> @@ -1243,21 +1243,10 @@ test_atexit () {\n>> >>  \t\t} && (exit \\\"\\$eval_ret\\\"); eval_ret=\\$?; $test_atexit_cleanup\"\n>> >>  }\n>> >>  \n>> >> -# Most tests can use the created repository, but some may need to create more.\n>> >> +# Deprecated wrapper for \"git init\", use \"git init\" directly instead\n>> >>  # Usage: test_create_repo <directory>\n>> >>  test_create_repo () {\n>> >\n>> > If this is deprecated why not add a warning?\n>> >\n>> >   echo \"warning: test_create_repo is deprecated in favor of git init\" >&2\n>> \n>> Because like test_i18ncmp, test_i18ngrep or whatever this is in the\n>> state of \"don't use this for new code\", but annoying everyone who runs\n>> the test suite with loads of this output under -v would be too\n>> distracting.\n>> \n>> The attention of the developer community is much better spent on one\n>> person doing a s/test_create_repo/git init/ patch than having everyone\n>> see this warning until somebody does that.\n>\n> Then it's not really deprecated; it's merely disfavored.\n>\n> To deprecate means to express disapproval of. If we are not going to\n> express disapproval (i.e. annoy the users of the test suite), then it's\n> not really deprecated. You can't eat your cake and have it too.\n>\n> I agree we shouldn't throw a warning right now, but at some point in the\n> future we should, *then* it will be deprecated.\n\nI don't feel strongly about either term, as long as it's consistent.\n\nI do think that \"deprecated\" is consistent in the way I'm using it\nwithin the git project. If you grep various things we've \"deprecated\" we\nusually just do so by noting so in the docs. In this case the docs are\nthe comments in test-lib.sh.\n\nWe do also have things like git rebase --preserve-merges which emit a\nwarning, but we use \"deprecated\" for both. By contrast we don't have a\nsingle git for \"git grep -i disfavor\".\n\nAnyway, for now I'd prefer to just have this land as-is and sort out\nsuch minor things later, given the v6 and having two other topics\nwaiting on this...\n"},{"id":"424503","messageId":"609d87d457433_80a220856@natae.notmuch","threadId":"55480","inReplyTo":"87eeeasumj.fsf@evledraar.gmail.com","subject":"Re: [PATCH v6 11/11] test-lib: split up and deprecate test_create_repo()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-13T20:11:00Z","receivedAt":"2021-05-13T20:11:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n> On Thu, May 13 2021, Felipe Contreras wrote:\n\n> > Then it's not really deprecated; it's merely disfavored.\n> >\n> > To deprecate means to express disapproval of. If we are not going to\n> > express disapproval (i.e. annoy the users of the test suite), then it's\n> > not really deprecated. You can't eat your cake and have it too.\n> >\n> > I agree we shouldn't throw a warning right now, but at some point in the\n> > future we should, *then* it will be deprecated.\n> \n> I don't feel strongly about either term, as long as it's consistent.\n> \n> I do think that \"deprecated\" is consistent in the way I'm using it\n> within the git project. If you grep various things we've \"deprecated\" we\n> usually just do so by noting so in the docs. In this case the docs are\n> the comments in test-lib.sh.\n> \n> We do also have things like git rebase --preserve-merges which emit a\n> warning, but we use \"deprecated\" for both. By contrast we don't have a\n> single git for \"git grep -i disfavor\".\n> \n> Anyway, for now I'd prefer to just have this land as-is and sort out\n> such minor things later, given the v6 and having two other topics\n> waiting on this...\n\nFair enough.\n\n-- \nFelipe Contreras"}]}