{"thread":{"id":"49250","subject":"[PATCH v3 00/11] Hash-independent tests (part 3)","startedAt":"2018-08-29T00:57:05Z","lastAt":"2018-09-01T15:33:20Z","messageCount":19,"participants":["brian m. carlson","Jonathan Nieder","Derrick Stolee","Torsten Bögershausen","Eric Sunshine"],"isPatch":true,"patchVersion":3,"patchTotal":11},"messages":[{"id":"356783","messageId":"20180829005642.980617-1-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":null,"subject":"[PATCH v3 00/11] Hash-independent tests (part 3)","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:31Z","receivedAt":"2018-08-29T00:57:05Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is the next in the series of improvements to make tests\nhash-independent.\n\nA range-diff is below.\n\nChanges from v2:\n* Fix a typo in \"zero_2\".\n* Provide better matching of expected output.\n* Add and use test_oid_init instead of filename-based test_oid_cache.\n* Add test_set_hash.\n* Provide better error checking in newly added test functions.\n* Move t0000 constants into the test, removing the separate file.\n* Switch to using a differently named temporary file in t0027.\n\nChanges from v1:\n* Adopt pure shell approach for helper.\n* Add tests for the helpers.\n* Explicitly refer to SHA-256 now that we know it will be NewHash.\n* Updated t0000 to remove SHA1 prerequisite.\n* Change name of helper from test_translate to test_oid.\n* Add helper to cache information in the shell.\n* Simplified lookup of HEAD in t0002.\n* Switched to using existing helper function in t0027.\n* Simplified handling of IDs in t0064.\n\nbrian m. carlson (11):\n  t: add tool to translate hash-related values\n  t0000: use hash translation table\n  t0000: update tests for SHA-256\n  t0002: abstract away SHA-1 specific constants\n  t0027: make hash size independent\n  t0064: make hash size independent\n  t1006: make hash size independent\n  t1400: switch hard-coded object ID to variable\n  t1405: make hash size independent\n  t1406: make hash-size independent\n  t1407: make hash size independent\n\n t/oid-info/hash-info           |   8 ++\n t/oid-info/oid                 |  29 +++++\n t/t0000-basic.sh               | 211 ++++++++++++++++++++++-----------\n t/t0002-gitfile.sh             |  27 +++--\n t/t0027-auto-crlf.sh           |   6 +-\n t/t0064-sha1-array.sh          |  49 ++++----\n t/t1006-cat-file.sh            |   6 +-\n t/t1400-update-ref.sh          |   2 +-\n t/t1405-main-ref-store.sh      |   4 +-\n t/t1406-submodule-ref-store.sh |   6 +-\n t/t1407-worktree-ref-store.sh  |   4 +-\n t/test-lib-functions.sh        |  44 +++++++\n 12 files changed, 283 insertions(+), 113 deletions(-)\n create mode 100644 t/oid-info/hash-info\n create mode 100644 t/oid-info/oid\n\nrange-diff:\n\n1:  fb66b1ff7d !  1:  a897533a90 t: add tool to translate hash-related values\n   @@ -3,19 +3,19 @@\n        t: add tool to translate hash-related values\n    \n        Add a test function helper, test_oid, that produces output that varies\n   -    depending on the hash in use.  Add an additional helper, test_oid_cache,\n   -    that can be used to load data for test_oid, either through a list of\n   -    filenames or on standard input.  Check that these functions work in\n   +    depending on the hash in use.  Add two additional helpers,\n   +    test_oid_cache, which can be used to load data for test_oid from\n   +    standard input, and test_oid_init, which can be used to load certain\n   +    fixed values from lookup charts.  Check that these functions work in\n        t0000, as the rest of the testsuite will soon come to depend on them.\n    \n        Implement two basic lookup charts, one for common invalid or synthesized\n        object IDs, and one for various facts about the hash function in use.\n   -    Individual tests can use their own translation files to map object IDs\n   -    or other data that needs to vary across hash functions.  Provide\n   -    versions for both SHA-1 and SHA-256.\n   +    Provide versions for both SHA-1 and SHA-256.\n    \n   -    Note that due to the implementation used, keys cannot be anything but\n   -    shell identifier characters.\n   +    Note that due to the implementation used, names used for lookup can\n   +    currently consist only of shell identifier characters.  If this is a\n   +    problem in the future, we can hash the names before use.\n    \n        Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>\n        Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n   @@ -56,7 +56,7 @@\n    +007\tsha256:0000000000000000000000000000000000000000000000000000000000000007\n    +# All zeros or Fs missing one or two hex segments.\n    +zero_1\t\tsha1:000000000000000000000000000000000000000\n   -+zero_2\t\tsha256:000000000000000000000000000000000000000000000000000000000000000\n   ++zero_1\t\tsha256:000000000000000000000000000000000000000000000000000000000000000\n    +zero_2\t\tsha1:00000000000000000000000000000000000000\n    +zero_2\t\tsha256:00000000000000000000000000000000000000000000000000000000000000\n    +ff_1\t\tsha1:fffffffffffffffffffffffffffffffffffffff\n   @@ -76,33 +76,39 @@\n       EOF\n     \"\n     \n   -+test_oid_cache hash-info oid\n   ++test_oid_init\n    +\n   -+test_expect_success 'test_oid_info provides sane info by default' '\n   -+\ttest_oid zero &&\n   ++test_expect_success 'test_oid provides sane info by default' '\n    +\ttest_oid zero >actual &&\n   -+\tgrep \"00*\" actual &&\n   -+\ttest \"$(test_oid hexsz)\" -eq $(wc -c <actual) &&\n   -+\ttest $(( $(test_oid rawsz) * 2)) -eq \"$(test_oid hexsz)\"\n   ++\tgrep \"^00*$\" actual &&\n   ++\trawsz=\"$(test_oid rawsz)\" &&\n   ++\thexsz=\"$(test_oid hexsz)\" &&\n   ++\ttest \"$hexsz\" -eq $(wc -c <actual) &&\n   ++\ttest $(( $rawsz * 2)) -eq \"$hexsz\"\n    +'\n    +\n   -+test_expect_success 'test_oid_info can look up data for SHA-1' '\n   -+\ttest_detect_hash sha1 &&\n   -+\ttest_oid zero >actual &&\n   -+\tgrep \"00*\" actual &&\n   -+\ttest $(wc -c <actual) -eq 40 &&\n   -+\ttest \"$(test_oid rawsz)\" -eq 20 &&\n   -+\ttest \"$(test_oid hexsz)\" -eq 40\n   -+'\n   -+\n   -+test_expect_success 'test_oid_info can look up data for SHA-256' '\n   ++test_expect_success 'test_oid can look up data for SHA-1' '\n    +\ttest_when_finished \"test_detect_hash\" &&\n   -+\ttest_detect_hash sha256 &&\n   ++\ttest_set_hash sha1 &&\n    +\ttest_oid zero >actual &&\n   -+\tgrep \"00*\" actual &&\n   ++\tgrep \"^00*$\" actual &&\n   ++\trawsz=\"$(test_oid rawsz)\" &&\n   ++\thexsz=\"$(test_oid hexsz)\" &&\n   ++\ttest $(wc -c <actual) -eq 40 &&\n   ++\ttest \"$rawsz\" -eq 20 &&\n   ++\ttest \"$hexsz\" -eq 40\n   ++'\n   ++\n   ++test_expect_success 'test_oid can look up data for SHA-256' '\n   ++\ttest_when_finished \"test_detect_hash\" &&\n   ++\ttest_set_hash sha256 &&\n   ++\ttest_oid zero >actual &&\n   ++\tgrep \"^00*$\" actual &&\n   ++\trawsz=\"$(test_oid rawsz)\" &&\n   ++\thexsz=\"$(test_oid hexsz)\" &&\n    +\ttest $(wc -c <actual) -eq 64 &&\n   -+\ttest \"$(test_oid rawsz)\" -eq 32 &&\n   -+\ttest \"$(test_oid hexsz)\" -eq 64\n   ++\ttest \"$rawsz\" -eq 32 &&\n   ++\ttest \"$hexsz\" -eq 64\n    +'\n    +\n     ################################################################\n   @@ -117,38 +123,46 @@\n       '\n     }\n    +\n   ++test_set_hash () {\n   ++\ttest_hash_algo=\"$1\"\n   ++}\n   ++\n    +test_detect_hash () {\n   -+\tif test -n \"$1\"\n   -+\tthen\n   -+\t\ttest_hash_algo=\"$1\"\n   -+\telse\n   -+\t\ttest_hash_algo='sha1'\n   -+\tfi\n   ++\ttest_hash_algo='sha1'\n   ++}\n   ++\n   ++test_oid_init () {\n   ++\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/hash-info\" &&\n   ++\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/oid\"\n    +}\n    +\n    +test_oid_cache () {\n    +\ttest -n \"$test_hash_algo\" || test_detect_hash\n   -+\tif test -n \"$1\"\n   -+\tthen\n   -+\t\twhile test -n \"$1\"\n   -+\t\tdo\n   -+\t\t\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/$1\"\n   -+\t\t\tshift\n   -+\t\tdone\n   -+\t\treturn $?\n   -+\tfi\n    +\twhile read _tag _rest\n    +\tdo\n   -+\t\tcase $_tag in \\#*)\n   ++\t\tcase $_tag in\n   ++\t\t\\#*)\n   ++\t\t\tcontinue;;\n   ++\t\t?*)\n   ++\t\t\t# non-empty\n   ++\t\t\t;;\n   ++\t\t*)\n   ++\t\t\t# blank line\n    +\t\t\tcontinue;;\n   -+\t\tesac\n    +\n   -+\t\t_k=\"${_rest%:*}\"\n   -+\t\t_v=\"${_rest#*:}\"\n   -+\t\teval \"test_oid_${_k}_$_tag=\\\"$_v\\\"\"\n   ++\t\tesac &&\n   ++\n   ++\t\t_k=\"${_rest%:*}\" &&\n   ++\t\t_v=\"${_rest#*:}\" &&\n   ++\t\t{ echo \"$_k\" | egrep '^[a-z0-9]+$' >/dev/null ||\n   ++\t\t\terror 'bug in the test script: bad hash algorithm'; } &&\n   ++\t\teval \"test_oid_${_k}_$_tag=\\\"\\$_v\\\"\" || return 1\n    +\tdone\n    +}\n    +\n    +test_oid () {\n   -+\teval \"printf '%s' \\\"\\${test_oid_${test_hash_algo}_$1}\\\"\"\n   ++\teval \"\n   ++\t\ttest -n \\\"\\${test_oid_${test_hash_algo}_$1+set}\\\" &&\n   ++\t\tprintf '%s' \\\"\\${test_oid_${test_hash_algo}_$1}\\\"\n   ++\t\"\n    +}\n2:  7b87aac814 =  2:  d63dc976f4 t0000: use hash translation table\n3:  39464fb0cc !  3:  9e55529efd t0000: update tests for SHA-256\n   @@ -16,11 +16,14 @@\n    \n        Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n    \n   -diff --git a/t/oid-info/t0000 b/t/oid-info/t0000\n   -new file mode 100644\n   ---- /dev/null\n   -+++ b/t/oid-info/t0000\n   +diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\n   +--- a/t/t0000-basic.sh\n   ++++ b/t/t0000-basic.sh\n    @@\n   + ################################################################\n   + # Basics of the basics\n   + \n   ++test_oid_cache <<\\EOF\n    +path0f sha1:f87290f8eb2cbbea7857214459a0739927eab154\n    +path0f sha256:638106af7c38be056f3212cbd7ac65bc1bac74f420ca5a436ff006a9d025d17d\n    +\n   @@ -59,15 +62,7 @@\n    +\n    +simpletree sha1:7bb943559a305bdd6bdee2cef6e5df2413c3d30a\n    +simpletree sha256:1710c07a6c86f9a3c7376364df04c47ee39e5a5e221fcdd84b743bc9bb7e2bc5\n   -\n   -diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\n   ---- a/t/t0000-basic.sh\n   -+++ b/t/t0000-basic.sh\n   -@@\n   - ################################################################\n   - # Basics of the basics\n   - \n   -+test_oid_cache t0000\n   ++EOF\n    +\n     # updating a new file without --add should fail.\n     test_expect_success 'git update-index without --add should fail adding' '\n   @@ -79,8 +74,7 @@\n    -test_expect_success SHA1 'validate object ID of a known tree' '\n    -\ttest \"$tree\" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a\n    +test_expect_success 'validate object ID of a known tree' '\n   -+echo $tree &&\n   -+\ttest \"$tree\" = $(test_oid simpletree)\n   ++\ttest \"$tree\" = \"$(test_oid simpletree)\"\n         '\n     \n     # Removing paths.\n   @@ -109,10 +103,8 @@\n    +\t100644 $(test_oid subp3f) 0\tpath3/subp3/file3\n    +\t120000 $(test_oid subp3s) 0\tpath3/subp3/file3sym\n       EOF\n   -+\tcat expected &&\n       test_cmp expected current\n     '\n   - \n    @@\n       tree=$(git write-tree)\n     '\n   @@ -120,7 +112,7 @@\n    -test_expect_success SHA1 'validate object ID for a known tree' '\n    -\ttest \"$tree\" = 087704a96baf1c2d1c869a8b084481e121c88b5b\n    +test_expect_success 'validate object ID for a known tree' '\n   -+\ttest \"$tree\" = $(test_oid root)\n   ++\ttest \"$tree\" = \"$(test_oid root)\"\n     '\n     \n     test_expect_success 'showing tree with git ls-tree' '\n4:  27fdff34e3 !  4:  4d5b8d4025 t0002: abstract away SHA-1 specific constants\n   @@ -28,8 +28,10 @@\n       test_cmp expected actual\n     '\n    @@\n   + \t\tcd enter_repo &&\n           git worktree add  ../foo refs/tags/foo\n       ) &&\n   ++\thead=$(git -C enter_repo rev-parse HEAD) &&\n       git ls-remote foo >actual &&\n    -\tcat >expected <<-\\EOF &&\n    -\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n   @@ -44,6 +46,7 @@\n     '\n     \n     test_expect_success 'enter_repo strict mode' '\n   ++\thead=$(git -C enter_repo rev-parse HEAD) &&\n       git ls-remote --upload-pack=\"git upload-pack --strict\" foo/.git >actual &&\n    -\tcat >expected <<-\\EOF &&\n    -\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n5:  bd31663386 <  -:  ---------- t0027: make hash size independent\n-:  ---------- >  5:  6037c4d10a t0027: make hash size independent\n6:  5d638b82ad =  6:  dfad561965 t0064: make hash size independent\n7:  e147833d05 !  7:  8a860a7492 t1006: make hash size independent\n   @@ -15,7 +15,7 @@\n       test_cmp expect actual\n     '\n     \n   -+test_oid_cache hash-info\n   ++test_oid_init\n    +\n     tree_sha1=$(git write-tree)\n    -tree_size=33\n8:  78529a19b2 =  8:  1baaf8374a t1400: switch hard-coded object ID to variable\n9:  a3c4726386 =  9:  232c043ed7 t1405: make hash size independent\n10:  e35b54a199 = 10:  9d0207bc52 t1406: make hash-size independent\n11:  2d4a478d0e = 11:  d292c6311f t1407: make hash size independent\n\n"},{"id":"356784","messageId":"20180829005642.980617-2-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 01/11] t: add tool to translate hash-related values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:32Z","receivedAt":"2018-08-29T00:57:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Add a test function helper, test_oid, that produces output that varies\ndepending on the hash in use.  Add two additional helpers,\ntest_oid_cache, which can be used to load data for test_oid from\nstandard input, and test_oid_init, which can be used to load certain\nfixed values from lookup charts.  Check that these functions work in\nt0000, as the rest of the testsuite will soon come to depend on them.\n\nImplement two basic lookup charts, one for common invalid or synthesized\nobject IDs, and one for various facts about the hash function in use.\nProvide versions for both SHA-1 and SHA-256.\n\nNote that due to the implementation used, names used for lookup can\ncurrently consist only of shell identifier characters.  If this is a\nproblem in the future, we can hash the names before use.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/oid-info/hash-info    |  8 ++++++++\n t/oid-info/oid          | 29 +++++++++++++++++++++++++++\n t/t0000-basic.sh        | 35 ++++++++++++++++++++++++++++++++\n t/test-lib-functions.sh | 44 +++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 116 insertions(+)\n create mode 100644 t/oid-info/hash-info\n create mode 100644 t/oid-info/oid\n\ndiff --git a/t/oid-info/hash-info b/t/oid-info/hash-info\nnew file mode 100644\nindex 0000000000..ccdbfdf974\n--- /dev/null\n+++ b/t/oid-info/hash-info\n@@ -0,0 +1,8 @@\n+rawsz sha1:20\n+rawsz sha256:32\n+\n+hexsz sha1:40\n+hexsz sha256:64\n+\n+zero sha1:0000000000000000000000000000000000000000\n+zero sha256:0000000000000000000000000000000000000000000000000000000000000000\ndiff --git a/t/oid-info/oid b/t/oid-info/oid\nnew file mode 100644\nindex 0000000000..a754970523\n--- /dev/null\n+++ b/t/oid-info/oid\n@@ -0,0 +1,29 @@\n+# These are some common invalid and partial object IDs used in tests.\n+001\tsha1:0000000000000000000000000000000000000001\n+001\tsha256:0000000000000000000000000000000000000000000000000000000000000001\n+002\tsha1:0000000000000000000000000000000000000002\n+002\tsha256:0000000000000000000000000000000000000000000000000000000000000002\n+003\tsha1:0000000000000000000000000000000000000003\n+003\tsha256:0000000000000000000000000000000000000000000000000000000000000003\n+004\tsha1:0000000000000000000000000000000000000004\n+004\tsha256:0000000000000000000000000000000000000000000000000000000000000004\n+005\tsha1:0000000000000000000000000000000000000005\n+005\tsha256:0000000000000000000000000000000000000000000000000000000000000005\n+006\tsha1:0000000000000000000000000000000000000006\n+006\tsha256:0000000000000000000000000000000000000000000000000000000000000006\n+007\tsha1:0000000000000000000000000000000000000007\n+007\tsha256:0000000000000000000000000000000000000000000000000000000000000007\n+# All zeros or Fs missing one or two hex segments.\n+zero_1\t\tsha1:000000000000000000000000000000000000000\n+zero_1\t\tsha256:000000000000000000000000000000000000000000000000000000000000000\n+zero_2\t\tsha1:00000000000000000000000000000000000000\n+zero_2\t\tsha256:00000000000000000000000000000000000000000000000000000000000000\n+ff_1\t\tsha1:fffffffffffffffffffffffffffffffffffffff\n+ff_1\t\tsha256:fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n+ff_2\t\tsha1:ffffffffffffffffffffffffffffffffffffff\n+ff_2\t\tsha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n+# More various invalid OIDs.\n+numeric\t\tsha1:0123456789012345678901234567890123456789\n+numeric\t\tsha256:0123456789012345678901234567890123456789012345678901234567890123\n+deadbeef\tsha1:deadbeefdeadbeefdeadbeefdeadbeefdeadbeef\n+deadbeef\tsha256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 850f651e4e..e3cace299e 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -821,6 +821,41 @@ test_expect_success 'tests clean up even on failures' \"\n \tEOF\n \"\n \n+test_oid_init\n+\n+test_expect_success 'test_oid provides sane info by default' '\n+\ttest_oid zero >actual &&\n+\tgrep \"^00*$\" actual &&\n+\trawsz=\"$(test_oid rawsz)\" &&\n+\thexsz=\"$(test_oid hexsz)\" &&\n+\ttest \"$hexsz\" -eq $(wc -c <actual) &&\n+\ttest $(( $rawsz * 2)) -eq \"$hexsz\"\n+'\n+\n+test_expect_success 'test_oid can look up data for SHA-1' '\n+\ttest_when_finished \"test_detect_hash\" &&\n+\ttest_set_hash sha1 &&\n+\ttest_oid zero >actual &&\n+\tgrep \"^00*$\" actual &&\n+\trawsz=\"$(test_oid rawsz)\" &&\n+\thexsz=\"$(test_oid hexsz)\" &&\n+\ttest $(wc -c <actual) -eq 40 &&\n+\ttest \"$rawsz\" -eq 20 &&\n+\ttest \"$hexsz\" -eq 40\n+'\n+\n+test_expect_success 'test_oid can look up data for SHA-256' '\n+\ttest_when_finished \"test_detect_hash\" &&\n+\ttest_set_hash sha256 &&\n+\ttest_oid zero >actual &&\n+\tgrep \"^00*$\" actual &&\n+\trawsz=\"$(test_oid rawsz)\" &&\n+\thexsz=\"$(test_oid hexsz)\" &&\n+\ttest $(wc -c <actual) -eq 64 &&\n+\ttest \"$rawsz\" -eq 32 &&\n+\ttest \"$hexsz\" -eq 64\n+'\n+\n ################################################################\n # Basics of the basics\n \ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 4207af4077..2300ec49dd 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1155,3 +1155,47 @@ depacketize () {\n \t\t}\n \t'\n }\n+\n+test_set_hash () {\n+\ttest_hash_algo=\"$1\"\n+}\n+\n+test_detect_hash () {\n+\ttest_hash_algo='sha1'\n+}\n+\n+test_oid_init () {\n+\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/hash-info\" &&\n+\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/oid\"\n+}\n+\n+test_oid_cache () {\n+\ttest -n \"$test_hash_algo\" || test_detect_hash\n+\twhile read _tag _rest\n+\tdo\n+\t\tcase $_tag in\n+\t\t\\#*)\n+\t\t\tcontinue;;\n+\t\t?*)\n+\t\t\t# non-empty\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# blank line\n+\t\t\tcontinue;;\n+\n+\t\tesac &&\n+\n+\t\t_k=\"${_rest%:*}\" &&\n+\t\t_v=\"${_rest#*:}\" &&\n+\t\t{ echo \"$_k\" | egrep '^[a-z0-9]+$' >/dev/null ||\n+\t\t\terror 'bug in the test script: bad hash algorithm'; } &&\n+\t\teval \"test_oid_${_k}_$_tag=\\\"\\$_v\\\"\" || return 1\n+\tdone\n+}\n+\n+test_oid () {\n+\teval \"\n+\t\ttest -n \\\"\\${test_oid_${test_hash_algo}_$1+set}\\\" &&\n+\t\tprintf '%s' \\\"\\${test_oid_${test_hash_algo}_$1}\\\"\n+\t\"\n+}\n"},{"id":"356786","messageId":"20180829005642.980617-3-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 02/11] t0000: use hash translation table","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:33Z","receivedAt":"2018-08-29T00:57:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"If the hash we're using is 32 bytes in size, attempting to insert a\n20-byte object name won't work.  Since these are synthesized objects\nthat are almost all zeros, look them up in a translation table.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0000-basic.sh | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex e3cace299e..b7f57ea052 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -1013,12 +1013,13 @@ test_expect_success SHA1 'validate object ID for a known tree' '\n \n test_expect_success 'put invalid objects into the index' '\n \trm -f .git/index &&\n-\tcat >badobjects <<-\\EOF &&\n-\t100644 blob 1000000000000000000000000000000000000000\tdir/file1\n-\t100644 blob 2000000000000000000000000000000000000000\tdir/file2\n-\t100644 blob 3000000000000000000000000000000000000000\tdir/file3\n-\t100644 blob 4000000000000000000000000000000000000000\tdir/file4\n-\t100644 blob 5000000000000000000000000000000000000000\tdir/file5\n+\tsuffix=$(echo $ZERO_OID | sed -e \"s/^.//\") &&\n+\tcat >badobjects <<-EOF &&\n+\t100644 blob $(test_oid 001)\tdir/file1\n+\t100644 blob $(test_oid 002)\tdir/file2\n+\t100644 blob $(test_oid 003)\tdir/file3\n+\t100644 blob $(test_oid 004)\tdir/file4\n+\t100644 blob $(test_oid 005)\tdir/file5\n \tEOF\n \tgit update-index --index-info <badobjects\n '\n"},{"id":"356785","messageId":"20180829005642.980617-4-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 03/11] t0000: update tests for SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:34Z","receivedAt":"2018-08-29T00:57:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Test t0000 tests the \"basics of the basics\" and as such, checks that we\nhave various fixed hard-coded object IDs.  The tests relying on these\nassertions have been marked with the SHA1 prerequisite, as they will\nobviously not function in their current form with SHA-256.\n\nUse the test_oid helper to update these assertions and provide values\nfor both SHA-1 and SHA-256.\n\nThese object IDs were synthesized using a set of scripts that created\nthe objects for both SHA-1 and SHA-256 using the same method to ensure\nthat they are indeed the correct values.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0000-basic.sh | 163 +++++++++++++++++++++++++++++------------------\n 1 file changed, 102 insertions(+), 61 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex b7f57ea052..72cf6bcb12 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -859,6 +859,47 @@ test_expect_success 'test_oid can look up data for SHA-256' '\n ################################################################\n # Basics of the basics\n \n+test_oid_cache <<\\EOF\n+path0f sha1:f87290f8eb2cbbea7857214459a0739927eab154\n+path0f sha256:638106af7c38be056f3212cbd7ac65bc1bac74f420ca5a436ff006a9d025d17d\n+\n+path0s sha1:15a98433ae33114b085f3eb3bb03b832b3180a01\n+path0s sha256:3a24cc53cf68edddac490bbf94a418a52932130541361f685df685e41dd6c363\n+\n+path2f sha1:3feff949ed00a62d9f7af97c15cd8a30595e7ac7\n+path2f sha256:2a7f36571c6fdbaf0e3f62751a0b25a3f4c54d2d1137b3f4af9cb794bb498e5f\n+\n+path2s sha1:d8ce161addc5173867a3c3c730924388daedbc38\n+path2s sha256:18fd611b787c2e938ddcc248fabe4d66a150f9364763e9ec133dd01d5bb7c65a\n+\n+path2d sha1:58a09c23e2ca152193f2786e06986b7b6712bdbe\n+path2d sha256:00e4b32b96e7e3d65d79112dcbea53238a22715f896933a62b811377e2650c17\n+\n+path3f sha1:0aa34cae68d0878578ad119c86ca2b5ed5b28376\n+path3f sha256:09f58616b951bd571b8cb9dc76d372fbb09ab99db2393f5ab3189d26c45099ad\n+\n+path3s sha1:8599103969b43aff7e430efea79ca4636466794f\n+path3s sha256:fce1aed087c053306f3f74c32c1a838c662bbc4551a7ac2420f5d6eb061374d0\n+\n+path3d sha1:21ae8269cacbe57ae09138dcc3a2887f904d02b3\n+path3d sha256:9b60497be959cb830bf3f0dc82bcc9ad9e925a24e480837ade46b2295e47efe1\n+\n+subp3f sha1:00fb5908cb97c2564a9783c0c64087333b3b464f\n+subp3f sha256:a1a9e16998c988453f18313d10375ee1d0ddefe757e710dcae0d66aa1e0c58b3\n+\n+subp3s sha1:6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c\n+subp3s sha256:81759d9f5e93c6546ecfcadb560c1ff057314b09f93fe8ec06e2d8610d34ef10\n+\n+subp3d sha1:3c5e5399f3a333eddecce7a9b9465b63f65f51e2\n+subp3d sha256:76b4ef482d4fa1c754390344cf3851c7f883b27cf9bc999c6547928c46aeafb7\n+\n+root sha1:087704a96baf1c2d1c869a8b084481e121c88b5b\n+root sha256:9481b52abab1b2ffeedbf9de63ce422b929f179c1b98ff7bee5f8f1bc0710751\n+\n+simpletree sha1:7bb943559a305bdd6bdee2cef6e5df2413c3d30a\n+simpletree sha256:1710c07a6c86f9a3c7376364df04c47ee39e5a5e221fcdd84b743bc9bb7e2bc5\n+EOF\n+\n # updating a new file without --add should fail.\n test_expect_success 'git update-index without --add should fail adding' '\n \ttest_must_fail git update-index should-be-empty\n@@ -874,8 +915,8 @@ test_expect_success 'writing tree out with git write-tree' '\n '\n \n # we know the shape and contents of the tree and know the object ID for it.\n-test_expect_success SHA1 'validate object ID of a known tree' '\n-\ttest \"$tree\" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a\n+test_expect_success 'validate object ID of a known tree' '\n+\ttest \"$tree\" = \"$(test_oid simpletree)\"\n     '\n \n # Removing paths.\n@@ -917,16 +958,16 @@ test_expect_success 'showing stage with git ls-files --stage' '\n \tgit ls-files --stage >current\n '\n \n-test_expect_success SHA1 'validate git ls-files output for a known tree' '\n-\tcat >expected <<-\\EOF &&\n-\t100644 f87290f8eb2cbbea7857214459a0739927eab154 0\tpath0\n-\t120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0\tpath0sym\n-\t100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0\tpath2/file2\n-\t120000 d8ce161addc5173867a3c3c730924388daedbc38 0\tpath2/file2sym\n-\t100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0\tpath3/file3\n-\t120000 8599103969b43aff7e430efea79ca4636466794f 0\tpath3/file3sym\n-\t100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0\tpath3/subp3/file3\n-\t120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0\tpath3/subp3/file3sym\n+test_expect_success 'validate git ls-files output for a known tree' '\n+\tcat >expected <<-EOF &&\n+\t100644 $(test_oid path0f) 0\tpath0\n+\t120000 $(test_oid path0s) 0\tpath0sym\n+\t100644 $(test_oid path2f) 0\tpath2/file2\n+\t120000 $(test_oid path2s) 0\tpath2/file2sym\n+\t100644 $(test_oid path3f) 0\tpath3/file3\n+\t120000 $(test_oid path3s) 0\tpath3/file3sym\n+\t100644 $(test_oid subp3f) 0\tpath3/subp3/file3\n+\t120000 $(test_oid subp3s) 0\tpath3/subp3/file3sym\n \tEOF\n \ttest_cmp expected current\n '\n@@ -935,20 +976,20 @@ test_expect_success 'writing tree out with git write-tree' '\n \ttree=$(git write-tree)\n '\n \n-test_expect_success SHA1 'validate object ID for a known tree' '\n-\ttest \"$tree\" = 087704a96baf1c2d1c869a8b084481e121c88b5b\n+test_expect_success 'validate object ID for a known tree' '\n+\ttest \"$tree\" = \"$(test_oid root)\"\n '\n \n test_expect_success 'showing tree with git ls-tree' '\n     git ls-tree $tree >current\n '\n \n-test_expect_success SHA1 'git ls-tree output for a known tree' '\n-\tcat >expected <<-\\EOF &&\n-\t100644 blob f87290f8eb2cbbea7857214459a0739927eab154\tpath0\n-\t120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01\tpath0sym\n-\t040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe\tpath2\n-\t040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3\tpath3\n+test_expect_success 'git ls-tree output for a known tree' '\n+\tcat >expected <<-EOF &&\n+\t100644 blob $(test_oid path0f)\tpath0\n+\t120000 blob $(test_oid path0s)\tpath0sym\n+\t040000 tree $(test_oid path2d)\tpath2\n+\t040000 tree $(test_oid path3d)\tpath3\n \tEOF\n \ttest_cmp expected current\n '\n@@ -959,16 +1000,16 @@ test_expect_success 'showing tree with git ls-tree -r' '\n \tgit ls-tree -r $tree >current\n '\n \n-test_expect_success SHA1 'git ls-tree -r output for a known tree' '\n-\tcat >expected <<-\\EOF &&\n-\t100644 blob f87290f8eb2cbbea7857214459a0739927eab154\tpath0\n-\t120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01\tpath0sym\n-\t100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7\tpath2/file2\n-\t120000 blob d8ce161addc5173867a3c3c730924388daedbc38\tpath2/file2sym\n-\t100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376\tpath3/file3\n-\t120000 blob 8599103969b43aff7e430efea79ca4636466794f\tpath3/file3sym\n-\t100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f\tpath3/subp3/file3\n-\t120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c\tpath3/subp3/file3sym\n+test_expect_success 'git ls-tree -r output for a known tree' '\n+\tcat >expected <<-EOF &&\n+\t100644 blob $(test_oid path0f)\tpath0\n+\t120000 blob $(test_oid path0s)\tpath0sym\n+\t100644 blob $(test_oid path2f)\tpath2/file2\n+\t120000 blob $(test_oid path2s)\tpath2/file2sym\n+\t100644 blob $(test_oid path3f)\tpath3/file3\n+\t120000 blob $(test_oid path3s)\tpath3/file3sym\n+\t100644 blob $(test_oid subp3f)\tpath3/subp3/file3\n+\t120000 blob $(test_oid subp3s)\tpath3/subp3/file3sym\n \tEOF\n \ttest_cmp expected current\n '\n@@ -978,19 +1019,19 @@ test_expect_success 'showing tree with git ls-tree -r -t' '\n \tgit ls-tree -r -t $tree >current\n '\n \n-test_expect_success SHA1 'git ls-tree -r output for a known tree' '\n-\tcat >expected <<-\\EOF &&\n-\t100644 blob f87290f8eb2cbbea7857214459a0739927eab154\tpath0\n-\t120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01\tpath0sym\n-\t040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe\tpath2\n-\t100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7\tpath2/file2\n-\t120000 blob d8ce161addc5173867a3c3c730924388daedbc38\tpath2/file2sym\n-\t040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3\tpath3\n-\t100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376\tpath3/file3\n-\t120000 blob 8599103969b43aff7e430efea79ca4636466794f\tpath3/file3sym\n-\t040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2\tpath3/subp3\n-\t100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f\tpath3/subp3/file3\n-\t120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c\tpath3/subp3/file3sym\n+test_expect_success 'git ls-tree -r output for a known tree' '\n+\tcat >expected <<-EOF &&\n+\t100644 blob $(test_oid path0f)\tpath0\n+\t120000 blob $(test_oid path0s)\tpath0sym\n+\t040000 tree $(test_oid path2d)\tpath2\n+\t100644 blob $(test_oid path2f)\tpath2/file2\n+\t120000 blob $(test_oid path2s)\tpath2/file2sym\n+\t040000 tree $(test_oid path3d)\tpath3\n+\t100644 blob $(test_oid path3f)\tpath3/file3\n+\t120000 blob $(test_oid path3s)\tpath3/file3sym\n+\t040000 tree $(test_oid subp3d)\tpath3/subp3\n+\t100644 blob $(test_oid subp3f)\tpath3/subp3/file3\n+\t120000 blob $(test_oid subp3s)\tpath3/subp3/file3sym\n \tEOF\n \ttest_cmp expected current\n '\n@@ -999,16 +1040,16 @@ test_expect_success 'writing partial tree out with git write-tree --prefix' '\n \tptree=$(git write-tree --prefix=path3)\n '\n \n-test_expect_success SHA1 'validate object ID for a known tree' '\n-\ttest \"$ptree\" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3\n+test_expect_success 'validate object ID for a known tree' '\n+\ttest \"$ptree\" = $(test_oid path3d)\n '\n \n test_expect_success 'writing partial tree out with git write-tree --prefix' '\n \tptree=$(git write-tree --prefix=path3/subp3)\n '\n \n-test_expect_success SHA1 'validate object ID for a known tree' '\n-\ttest \"$ptree\" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2\n+test_expect_success 'validate object ID for a known tree' '\n+\ttest \"$ptree\" = $(test_oid subp3d)\n '\n \n test_expect_success 'put invalid objects into the index' '\n@@ -1042,16 +1083,16 @@ test_expect_success 'git read-tree followed by write-tree should be idempotent'\n \ttest \"$newtree\" = \"$tree\"\n '\n \n-test_expect_success SHA1 'validate git diff-files output for a know cache/work tree state' '\n-\tcat >expected <<\\EOF &&\n-:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M\tpath0\n-:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M\tpath0sym\n-:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M\tpath2/file2\n-:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M\tpath2/file2sym\n-:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M\tpath3/file3\n-:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M\tpath3/file3sym\n-:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M\tpath3/subp3/file3\n-:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M\tpath3/subp3/file3sym\n+test_expect_success 'validate git diff-files output for a know cache/work tree state' '\n+\tcat >expected <<EOF &&\n+:100644 100644 $(test_oid path0f) $ZERO_OID M\tpath0\n+:120000 120000 $(test_oid path0s) $ZERO_OID M\tpath0sym\n+:100644 100644 $(test_oid path2f) $ZERO_OID M\tpath2/file2\n+:120000 120000 $(test_oid path2s) $ZERO_OID M\tpath2/file2sym\n+:100644 100644 $(test_oid path3f) $ZERO_OID M\tpath3/file3\n+:120000 120000 $(test_oid path3s) $ZERO_OID M\tpath3/file3sym\n+:100644 100644 $(test_oid subp3f) $ZERO_OID M\tpath3/subp3/file3\n+:120000 120000 $(test_oid subp3s) $ZERO_OID M\tpath3/subp3/file3sym\n EOF\n \tgit diff-files >current &&\n \ttest_cmp current expected\n@@ -1067,23 +1108,23 @@ test_expect_success 'no diff after checkout and git update-index --refresh' '\n '\n \n ################################################################\n-P=087704a96baf1c2d1c869a8b084481e121c88b5b\n+P=$(test_oid root)\n \n-test_expect_success SHA1 'git commit-tree records the correct tree in a commit' '\n+test_expect_success 'git commit-tree records the correct tree in a commit' '\n \tcommit0=$(echo NO | git commit-tree $P) &&\n \ttree=$(git show --pretty=raw $commit0 |\n \t\t sed -n -e \"s/^tree //p\" -e \"/^author /q\") &&\n \ttest \"z$tree\" = \"z$P\"\n '\n \n-test_expect_success SHA1 'git commit-tree records the correct parent in a commit' '\n+test_expect_success 'git commit-tree records the correct parent in a commit' '\n \tcommit1=$(echo NO | git commit-tree $P -p $commit0) &&\n \tparent=$(git show --pretty=raw $commit1 |\n \t\tsed -n -e \"s/^parent //p\" -e \"/^author /q\") &&\n \ttest \"z$commit0\" = \"z$parent\"\n '\n \n-test_expect_success SHA1 'git commit-tree omits duplicated parent in a commit' '\n+test_expect_success 'git commit-tree omits duplicated parent in a commit' '\n \tcommit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&\n \t     parent=$(git show --pretty=raw $commit2 |\n \t\tsed -n -e \"s/^parent //p\" -e \"/^author /q\" |\n"},{"id":"356787","messageId":"20180829005642.980617-6-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 05/11] t0027: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:36Z","receivedAt":"2018-08-29T00:57:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"We transform various object IDs into all-zero object IDs for comparison.\nAdjust the length as well so that this works for all hash algorithms.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0027-auto-crlf.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex beb5927f77..0f1235d9d1 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -14,11 +14,13 @@ compare_files () {\n compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n+\ttmp=$2.tmp\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$tmp\" &&\n \ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n+\tsed -e \"s/0000*/$ZERO_OID/\" \"$tmp\" >\"$exp\" &&\n \ttest_cmp \"$exp\" \"$act\" &&\n-\trm \"$exp\" \"$act\"\n+\trm \"$exp\" \"$act\" \"$tmp\"\n }\n \n create_gitattributes () {\n"},{"id":"356788","messageId":"20180829005642.980617-5-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 04/11] t0002: abstract away SHA-1 specific constants","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:35Z","receivedAt":"2018-08-29T00:57:09Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Adjust the test so that it computes variables for object IDs instead of\nusing hard-coded hashes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0002-gitfile.sh | 27 +++++++++++++++------------\n 1 file changed, 15 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh\nindex 3691023d51..0aa9908ea1 100755\n--- a/t/t0002-gitfile.sh\n+++ b/t/t0002-gitfile.sh\n@@ -92,11 +92,12 @@ test_expect_success 'enter_repo non-strict mode' '\n \t\tmv .git .realgit &&\n \t\techo \"gitdir: .realgit\" >.git\n \t) &&\n+\thead=$(git -C enter_repo rev-parse HEAD) &&\n \tgit ls-remote enter_repo >actual &&\n-\tcat >expected <<-\\EOF &&\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n+\tcat >expected <<-EOF &&\n+\t$head\tHEAD\n+\t$head\trefs/heads/master\n+\t$head\trefs/tags/foo\n \tEOF\n \ttest_cmp expected actual\n '\n@@ -106,21 +107,23 @@ test_expect_success 'enter_repo linked checkout' '\n \t\tcd enter_repo &&\n \t\tgit worktree add  ../foo refs/tags/foo\n \t) &&\n+\thead=$(git -C enter_repo rev-parse HEAD) &&\n \tgit ls-remote foo >actual &&\n-\tcat >expected <<-\\EOF &&\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n+\tcat >expected <<-EOF &&\n+\t$head\tHEAD\n+\t$head\trefs/heads/master\n+\t$head\trefs/tags/foo\n \tEOF\n \ttest_cmp expected actual\n '\n \n test_expect_success 'enter_repo strict mode' '\n+\thead=$(git -C enter_repo rev-parse HEAD) &&\n \tgit ls-remote --upload-pack=\"git upload-pack --strict\" foo/.git >actual &&\n-\tcat >expected <<-\\EOF &&\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n-\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n+\tcat >expected <<-EOF &&\n+\t$head\tHEAD\n+\t$head\trefs/heads/master\n+\t$head\trefs/tags/foo\n \tEOF\n \ttest_cmp expected actual\n '\n"},{"id":"356790","messageId":"20180829005642.980617-8-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 07/11] t1006: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:38Z","receivedAt":"2018-08-29T00:57:10Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Compute the size of the tree and commit objects we're creating by\nchecking for the size of an object ID and computing the resulting sizes\naccordingly.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1006-cat-file.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh\nindex 7f19d591f2..a7c95bb785 100755\n--- a/t/t1006-cat-file.sh\n+++ b/t/t1006-cat-file.sh\n@@ -140,15 +140,17 @@ test_expect_success '--batch-check without %(rest) considers whole line' '\n \ttest_cmp expect actual\n '\n \n+test_oid_init\n+\n tree_sha1=$(git write-tree)\n-tree_size=33\n+tree_size=$(($(test_oid rawsz) + 13))\n tree_pretty_content=\"100644 blob $hello_sha1\thello\"\n \n run_tests 'tree' $tree_sha1 $tree_size \"\" \"$tree_pretty_content\"\n \n commit_message=\"Initial commit\"\n commit_sha1=$(echo_without_newline \"$commit_message\" | git commit-tree $tree_sha1)\n-commit_size=177\n+commit_size=$(($(test_oid hexsz) + 137))\n commit_content=\"tree $tree_sha1\n author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 0000000000 +0000\n committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 0000000000 +0000\n"},{"id":"356789","messageId":"20180829005642.980617-7-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 06/11] t0064: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:37Z","receivedAt":"2018-08-29T00:57:11Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Compute test values of the appropriate size instead of hard-coding\n40-character values.  Rename the echo20 function to echoid, since the\nvalues may be of varying sizes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0064-sha1-array.sh | 49 ++++++++++++++++++++++++-------------------\n 1 file changed, 27 insertions(+), 22 deletions(-)\n\ndiff --git a/t/t0064-sha1-array.sh b/t/t0064-sha1-array.sh\nindex 67484502a0..5dda570b9a 100755\n--- a/t/t0064-sha1-array.sh\n+++ b/t/t0064-sha1-array.sh\n@@ -3,30 +3,30 @@\n test_description='basic tests for the SHA1 array implementation'\n . ./test-lib.sh\n \n-echo20 () {\n+echoid () {\n \tprefix=\"${1:+$1 }\"\n \tshift\n \twhile test $# -gt 0\n \tdo\n-\t\techo \"$prefix$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1\"\n+\t\techo \"$prefix$ZERO_OID\" | sed -e \"s/00/$1/g\"\n \t\tshift\n \tdone\n }\n \n test_expect_success 'ordered enumeration' '\n-\techo20 \"\" 44 55 88 aa >expect &&\n+\techoid \"\" 44 55 88 aa >expect &&\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n+\t\techoid append 88 44 aa 55 &&\n \t\techo for_each_unique\n \t} | test-tool sha1-array >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'ordered enumeration with duplicate suppression' '\n-\techo20 \"\" 44 55 88 aa >expect &&\n+\techoid \"\" 44 55 88 aa >expect &&\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 append 88 44 aa 55 &&\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid append 88 44 aa 55 &&\n \t\techo for_each_unique\n \t} | test-tool sha1-array >actual &&\n \ttest_cmp expect actual\n@@ -34,8 +34,8 @@ test_expect_success 'ordered enumeration with duplicate suppression' '\n \n test_expect_success 'lookup' '\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 lookup 55\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid lookup 55\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -eq 1\n@@ -43,8 +43,8 @@ test_expect_success 'lookup' '\n \n test_expect_success 'lookup non-existing entry' '\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 lookup 33\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid lookup 33\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -lt 0\n@@ -52,9 +52,9 @@ test_expect_success 'lookup non-existing entry' '\n \n test_expect_success 'lookup with duplicates' '\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 lookup 55\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid lookup 55\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -ge 2 &&\n@@ -63,19 +63,24 @@ test_expect_success 'lookup with duplicates' '\n \n test_expect_success 'lookup non-existing entry with duplicates' '\n \t{\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 append 88 44 aa 55 &&\n-\t\techo20 lookup 66\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid append 88 44 aa 55 &&\n+\t\techoid lookup 66\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -lt 0\n '\n \n test_expect_success 'lookup with almost duplicate values' '\n+\t# n-1 5s\n+\troot=$(echoid \"\" 55) &&\n+\troot=${root%5} &&\n \t{\n-\t\techo \"append 5555555555555555555555555555555555555555\" &&\n-\t\techo \"append 555555555555555555555555555555555555555f\" &&\n-\t\techo20 lookup 55\n+\t\tid1=\"${root}5\" &&\n+\t\tid2=\"${root}f\" &&\n+\t\techo \"append $id1\" &&\n+\t\techo \"append $id2\" &&\n+\t\techoid lookup 55\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -eq 0\n@@ -83,8 +88,8 @@ test_expect_success 'lookup with almost duplicate values' '\n \n test_expect_success 'lookup with single duplicate value' '\n \t{\n-\t\techo20 append 55 55 &&\n-\t\techo20 lookup 55\n+\t\techoid append 55 55 &&\n+\t\techoid lookup 55\n \t} | test-tool sha1-array >actual &&\n \tn=$(cat actual) &&\n \ttest \"$n\" -ge 0 &&\n"},{"id":"356791","messageId":"20180829005642.980617-9-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 08/11] t1400: switch hard-coded object ID to variable","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:39Z","receivedAt":"2018-08-29T00:57:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Switch a hard-coded all-zeros object ID to use a variable instead.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1400-update-ref.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex 7c8df20955..6072650686 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -346,7 +346,7 @@ test_expect_success \"verifying $m's log (logged by config)\" '\n \n git update-ref $m $D\n cat >.git/logs/$m <<EOF\n-0000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500\n+$Z $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500\n $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500\n $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500\n $F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500\n"},{"id":"356792","messageId":"20180829005642.980617-10-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 09/11] t1405: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:40Z","receivedAt":"2018-08-29T00:57:13Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of hard-coding a 40-based constant, split the output of\nfor-each-ref and for-each-reflog by field.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1405-main-ref-store.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh\nindex a74c38b5fb..331899ddc4 100755\n--- a/t/t1405-main-ref-store.sh\n+++ b/t/t1405-main-ref-store.sh\n@@ -54,7 +54,7 @@ test_expect_success 'for_each_ref(refs/heads/)' '\n '\n \n test_expect_success 'for_each_ref() is sorted' '\n-\t$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&\n+\t$RUN for-each-ref refs/heads/ | cut -d\" \" -f 2- >actual &&\n \tsort actual > expected &&\n \ttest_cmp expected actual\n '\n@@ -71,7 +71,7 @@ test_expect_success 'verify_ref(new-master)' '\n '\n \n test_expect_success 'for_each_reflog()' '\n-\t$RUN for-each-reflog | sort -k2 | cut -c 42- >actual &&\n+\t$RUN for-each-reflog | sort -k2 | cut -d\" \" -f 2- >actual &&\n \tcat >expected <<-\\EOF &&\n \tHEAD 0x1\n \trefs/heads/master 0x0\n"},{"id":"356793","messageId":"20180829005642.980617-11-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 10/11] t1406: make hash-size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:41Z","receivedAt":"2018-08-29T00:57:14Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of hard-coding a 40-based constant, split the output of\nfor-each-ref and for-each-reflog by field.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1406-submodule-ref-store.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh\nindex e093782cc3..d199d872fb 100755\n--- a/t/t1406-submodule-ref-store.sh\n+++ b/t/t1406-submodule-ref-store.sh\n@@ -39,7 +39,7 @@ test_expect_success 'rename_refs() not allowed' '\n '\n \n test_expect_success 'for_each_ref(refs/heads/)' '\n-\t$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&\n+\t$RUN for-each-ref refs/heads/ | cut -d\" \" -f 2- >actual &&\n \tcat >expected <<-\\EOF &&\n \tmaster 0x0\n \tnew-master 0x0\n@@ -48,7 +48,7 @@ test_expect_success 'for_each_ref(refs/heads/)' '\n '\n \n test_expect_success 'for_each_ref() is sorted' '\n-\t$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&\n+\t$RUN for-each-ref refs/heads/ | cut -d\" \" -f 2- >actual &&\n \tsort actual > expected &&\n \ttest_cmp expected actual\n '\n@@ -65,7 +65,7 @@ test_expect_success 'verify_ref(new-master)' '\n '\n \n test_expect_success 'for_each_reflog()' '\n-\t$RUN for-each-reflog | sort | cut -c 42- >actual &&\n+\t$RUN for-each-reflog | sort | cut -d\" \" -f 2- >actual &&\n \tcat >expected <<-\\EOF &&\n \tHEAD 0x1\n \trefs/heads/master 0x0\n"},{"id":"356794","messageId":"20180829005642.980617-12-sandals@crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829005642.980617-1-sandals@crustytoothpaste.net","subject":"[PATCH v3 11/11] t1407: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T00:56:42Z","receivedAt":"2018-08-29T00:57:15Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of hard-coding a 40-based constant, split the output of\nfor-each-ref and for-each-reflog by field.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1407-worktree-ref-store.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t1407-worktree-ref-store.sh b/t/t1407-worktree-ref-store.sh\nindex 4623ae15c4..9a84858118 100755\n--- a/t/t1407-worktree-ref-store.sh\n+++ b/t/t1407-worktree-ref-store.sh\n@@ -58,7 +58,7 @@ test_expect_success 'for_each_reflog()' '\n \tmkdir -p     .git/worktrees/wt/logs/refs/bisect &&\n \techo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&\n \n-\t$RWT for-each-reflog | cut -c 42- | sort >actual &&\n+\t$RWT for-each-reflog | cut -d\" \" -f 2- | sort >actual &&\n \tcat >expected <<-\\EOF &&\n \tHEAD 0x1\n \tPSEUDO-WT 0x0\n@@ -68,7 +68,7 @@ test_expect_success 'for_each_reflog()' '\n \tEOF\n \ttest_cmp expected actual &&\n \n-\t$RMAIN for-each-reflog | cut -c 42- | sort >actual &&\n+\t$RMAIN for-each-reflog | cut -d\" \" -f 2- | sort >actual &&\n \tcat >expected <<-\\EOF &&\n \tHEAD 0x1\n \tPSEUDO-MAIN 0x0\n"},{"id":"356808","messageId":"20180829040548.GB197350@aiede.svl.corp.google.com","threadId":"49250","inReplyTo":"20180829005642.980617-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH v3 01/11] t: add tool to translate hash-related values","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-08-29T04:05:48Z","receivedAt":"2018-08-29T04:05:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nbrian m. carlson wrote:\n\n> Add a test function helper, test_oid, that produces output that varies\n> depending on the hash in use.\n\nCool!\n\n>                                Add two additional helpers,\n> test_oid_cache, which can be used to load data for test_oid from\n> standard input, and test_oid_init, which can be used to load certain\n> fixed values from lookup charts.  Check that these functions work in\n> t0000, as the rest of the testsuite will soon come to depend on them.\n>\n> Implement two basic lookup charts, one for common invalid or synthesized\n> object IDs, and one for various facts about the hash function in use.\n> Provide versions for both SHA-1 and SHA-256.\n\nWhat do test_oid_cache and test_oid_init do?  How can I use them?\n\nJudging from t0000-basic.sh, the idea looks something like\n\n\tAdd a test function helper, test_oid, that ...\n\n\ttest_oid allows looking up arbitrary information about an object format:\n\tthe length of object ids, values of well known object ids, etc.  Before\n\tcalling it, a test script must invoke test_oid_cache (either directly\n\tor indirectly through test_oid_init) to load the lookup charts.\n\n\tSee t0000 for an example, which also serves as a sanity-check that\n\tthese functions work in preparation for using them in the rest of the\n\ttest suite.\n\n\tThere are two basic lookup charts for now: oid-info/oid, with common\n\tinvalid or synthesized object IDs; and oid-info/hash-info, with facts\n\tsuch as object id length about the formats in use.  The charts contain\n\tinformation about both SHA-1 and SHA-256.\n\n\tSo now you can update existing tests to be format-independent by (1)\n\tadding an invocation of test_oid_init to test setup and (2) replacing\n\tformat dependencies with $(test_oid foo).\n\n\tSince values are stored as shell variables, names used for lookup can\n\tonly consist of shell identifier characters.  If this is a problem in\n\tthe future, we can hash the names before use.\n\n\tImproved-by: Eric Sunshine <sunshine@sunshineco.com>\n\nDo these always use sha1 for now?  Ah, t0000 answers but it might be\nworth mentioning in the commit message, too:\n\n\ttest_set_hash allows setting which object format test_oid should look\n\tup information for, and test_detect_hash returns to the default format.\n\n[...]\n> --- /dev/null\n> +++ b/t/oid-info/hash-info\n> @@ -0,0 +1,8 @@\n> +rawsz sha1:20\n> +rawsz sha256:32\n\nCan there be a README in this directory describing the files and format?\n\n[...]\n> --- a/t/t0000-basic.sh\n> +++ b/t/t0000-basic.sh\n> @@ -821,6 +821,41 @@ test_expect_success 'tests clean up even on failures' \"\n>  \tEOF\n>  \"\n>  \n> +test_oid_init\n\nCan this be wrapped in test_expect_success?  That way, if it fails or\nprints an error message then the usual test machinery would handle it.\n\n> +\n> +test_expect_success 'test_oid provides sane info by default' '\n> +\ttest_oid zero >actual &&\n> +\tgrep \"^00*$\" actual &&\n\nnit: can save the reader some confusion by escaping the $.\n\n> +\trawsz=\"$(test_oid rawsz)\" &&\n> +\thexsz=\"$(test_oid hexsz)\" &&\n\noptional: no need for these quotation marks --- a command substitution\nassigned to a shell variable is treated as if it were quoted.\n\n> +\ttest \"$hexsz\" -eq $(wc -c <actual) &&\n> +\ttest $(( $rawsz * 2)) -eq \"$hexsz\"\n\nMakes sense.\n\n[...]\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1155,3 +1155,47 @@ depacketize () {\n[...]\n> +test_oid_cache () {\n> +\ttest -n \"$test_hash_algo\" || test_detect_hash\n\nShould this use an uninterrupted &&-chain?\n\n> +\twhile read _tag _rest\n\nThis appears to be the first use of this naming convention.  I wonder\nif we can use \"local\" instead.\n\n> +\tdo\n> +\t\tcase $_tag in\n> +\t\t\\#*)\n> +\t\t\tcontinue;;\n> +\t\t?*)\n> +\t\t\t# non-empty\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\t# blank line\n> +\t\t\tcontinue;;\n> +\n\nunnecessary blank line here\n\n> +\t\tesac &&\n> +\n> +\t\t_k=\"${_rest%:*}\" &&\n> +\t\t_v=\"${_rest#*:}\" &&\n> +\t\t{ echo \"$_k\" | egrep '^[a-z0-9]+$' >/dev/null ||\n> +\t\t\terror 'bug in the test script: bad hash algorithm'; } &&\n> +\t\teval \"test_oid_${_k}_$_tag=\\\"\\$_v\\\"\" || return 1\n\nThis is dense, so I'm having trouble taking it in at a glance.\n\nI think the idea is\n\n\t\tkey=${rest%%:*} &&\n\t\tval=${rest#*:} &&\n\n\t\tif ! expr \"$key\" : '[a-z0-9]*$' >/dev/null\n\t\tthen\n\t\t\terror ...\n\t\tfi &&\n\t\teval \"test_oid_${key}_${tag}=\\${val}\"\n\n> +\tdone\n> +}\n> +\n> +test_oid () {\n> +\teval \"\n> +\t\ttest -n \\\"\\${test_oid_${test_hash_algo}_$1+set}\\\" &&\n> +\t\tprintf '%s' \\\"\\${test_oid_${test_hash_algo}_$1}\\\"\n> +\t\"\n\nI'm also having trouble taking this one in.  Maybe splitting into two\nevals would work?\n\n\tvar=test_oid_${test_hash_algo}_$1 &&\n\n\teval \"test -n \\\"\\${$var+set}\\\"\" &&\n\teval \"printf '%s\\n' \\\"\\${$var}\\\"\"\n\nWhat is the initial test meant to do?  Can this function get a\ndocumentation comment?  Are we relying on \"test -n\" to return a failing\nresult if the variable is unset, or could the test be omitted (relying\non \"\\${$var}\" to evaluate to \"\" when the variable is unset)?  Should\nthis call 'error' when the variable is unset?\n\nCan t/README describe the new test helpers?\n\nThanks,\nJonathan\n"},{"id":"356826","messageId":"777ea296-005d-0408-1197-178898399593@gmail.com","threadId":"49250","inReplyTo":"20180829005642.980617-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH v3 01/11] t: add tool to translate hash-related values","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-08-29T12:37:48Z","receivedAt":"2018-08-29T12:37:52Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 8/28/2018 8:56 PM, brian m. carlson wrote:\n> +\trawsz=\"$(test_oid rawsz)\" &&\n> +\thexsz=\"$(test_oid hexsz)\" &&\n\nThese are neat helpers! The 'git commit-graph verify' tests in \nt5318-commit-graph.sh should automatically work if we use these for \nHASH_LEN instead of 20. I'll use a similar pattern when writing 'git \nmulti-pack-index verify'.\n\nThanks,\n\n-Stolee\n\n"},{"id":"356912","messageId":"20180829225222.GE432229@genre.crustytoothpaste.net","threadId":"49250","inReplyTo":"777ea296-005d-0408-1197-178898399593@gmail.com","subject":"Re: [PATCH v3 01/11] t: add tool to translate hash-related values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T22:52:22Z","receivedAt":"2018-08-29T22:52:30Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Wed, Aug 29, 2018 at 08:37:48AM -0400, Derrick Stolee wrote:\n> On 8/28/2018 8:56 PM, brian m. carlson wrote:\n> > +\trawsz=\"$(test_oid rawsz)\" &&\n> > +\thexsz=\"$(test_oid hexsz)\" &&\n> \n> These are neat helpers! The 'git commit-graph verify' tests in\n> t5318-commit-graph.sh should automatically work if we use these for HASH_LEN\n> instead of 20. I'll use a similar pattern when writing 'git multi-pack-index\n> verify'.\n\nThanks.  In the future, test_oid will learn about internal versus\nexternal object names, since we'll have what's printed by the UI (which\nmight be SHA-1) and what's under the hood (which might be SHA-256).\nHowever, it should be easy enough to update all those pplaces, so if you\nuse them now, it should be easy enough to update them in them in the\nfuture to refer to the right thing.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"356914","messageId":"20180829232211.GF432229@genre.crustytoothpaste.net","threadId":"49250","inReplyTo":"20180829040548.GB197350@aiede.svl.corp.google.com","subject":"Re: [PATCH v3 01/11] t: add tool to translate hash-related values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-08-29T23:22:11Z","receivedAt":"2018-08-29T23:22:22Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Tue, Aug 28, 2018 at 09:05:48PM -0700, Jonathan Nieder wrote:\n> >                                Add two additional helpers,\n> > test_oid_cache, which can be used to load data for test_oid from\n> > standard input, and test_oid_init, which can be used to load certain\n> > fixed values from lookup charts.  Check that these functions work in\n> > t0000, as the rest of the testsuite will soon come to depend on them.\n> >\n> > Implement two basic lookup charts, one for common invalid or synthesized\n> > object IDs, and one for various facts about the hash function in use.\n> > Provide versions for both SHA-1 and SHA-256.\n> \n> What do test_oid_cache and test_oid_init do?  How can I use them?\n> \n> Judging from t0000-basic.sh, the idea looks something like\n> \n> \tAdd a test function helper, test_oid, that ...\n> \n> \ttest_oid allows looking up arbitrary information about an object format:\n> \tthe length of object ids, values of well known object ids, etc.  Before\n> \tcalling it, a test script must invoke test_oid_cache (either directly\n> \tor indirectly through test_oid_init) to load the lookup charts.\n> \n> \tSee t0000 for an example, which also serves as a sanity-check that\n> \tthese functions work in preparation for using them in the rest of the\n> \ttest suite.\n> \n> \tThere are two basic lookup charts for now: oid-info/oid, with common\n> \tinvalid or synthesized object IDs; and oid-info/hash-info, with facts\n> \tsuch as object id length about the formats in use.  The charts contain\n> \tinformation about both SHA-1 and SHA-256.\n> \n> \tSo now you can update existing tests to be format-independent by (1)\n> \tadding an invocation of test_oid_init to test setup and (2) replacing\n> \tformat dependencies with $(test_oid foo).\n> \n> \tSince values are stored as shell variables, names used for lookup can\n> \tonly consist of shell identifier characters.  If this is a problem in\n> \tthe future, we can hash the names before use.\n> \n> \tImproved-by: Eric Sunshine <sunshine@sunshineco.com>\n> \n> Do these always use sha1 for now?  Ah, t0000 answers but it might be\n> worth mentioning in the commit message, too:\n> \n> \ttest_set_hash allows setting which object format test_oid should look\n> \tup information for, and test_detect_hash returns to the default format.\n\nI'll expand the commit message.  They do use SHA-1 for now, but I have a\nbranch that makes them use SHA-256 instead.\n\n> [...]\n> > --- /dev/null\n> > +++ b/t/oid-info/hash-info\n> > @@ -0,0 +1,8 @@\n> > +rawsz sha1:20\n> > +rawsz sha256:32\n> \n> Can there be a README in this directory describing the files and format?\n\nSure, if you like.\n\n> [...]\n> > --- a/t/t0000-basic.sh\n> > +++ b/t/t0000-basic.sh\n> > @@ -821,6 +821,41 @@ test_expect_success 'tests clean up even on failures' \"\n> >  \tEOF\n> >  \"\n> >  \n> > +test_oid_init\n> \n> Can this be wrapped in test_expect_success?  That way, if it fails or\n> prints an error message then the usual test machinery would handle it.\n\nSure.\n\n> > +\n> > +test_expect_success 'test_oid provides sane info by default' '\n> > +\ttest_oid zero >actual &&\n> > +\tgrep \"^00*$\" actual &&\n> \n> nit: can save the reader some confusion by escaping the $.\n\nGood point.\n\n> > +\trawsz=\"$(test_oid rawsz)\" &&\n> > +\thexsz=\"$(test_oid hexsz)\" &&\n> \n> optional: no need for these quotation marks --- a command substitution\n> assigned to a shell variable is treated as if it were quoted.\n\nThat's good to know.  I will honestly say that looking through the Git\ncodebase and getting reviews on the list has taught me huge amounts\nabout the intricacies of shell.\n\n> [...]\n> > --- a/t/test-lib-functions.sh\n> > +++ b/t/test-lib-functions.sh\n> > @@ -1155,3 +1155,47 @@ depacketize () {\n> [...]\n> > +test_oid_cache () {\n> > +\ttest -n \"$test_hash_algo\" || test_detect_hash\n> \n> Should this use an uninterrupted &&-chain?\n\nYes.  Will fix.\n\n> > +\twhile read _tag _rest\n> \n> This appears to be the first use of this naming convention.  I wonder\n> if we can use \"local\" instead.\n\nWe probably can.  There was a discussion about this elsewhere, and we\ndetermined that it's probably safe, and if it's not, it should be\nrelatively easy to back out.\n\n> > +\t\tesac &&\n> > +\n> > +\t\t_k=\"${_rest%:*}\" &&\n> > +\t\t_v=\"${_rest#*:}\" &&\n> > +\t\t{ echo \"$_k\" | egrep '^[a-z0-9]+$' >/dev/null ||\n> > +\t\t\terror 'bug in the test script: bad hash algorithm'; } &&\n> > +\t\teval \"test_oid_${_k}_$_tag=\\\"\\$_v\\\"\" || return 1\n> \n> This is dense, so I'm having trouble taking it in at a glance.\n> \n> I think the idea is\n> \n> \t\tkey=${rest%%:*} &&\n> \t\tval=${rest#*:} &&\n> \n> \t\tif ! expr \"$key\" : '[a-z0-9]*$' >/dev/null\n> \t\tthen\n> \t\t\terror ...\n> \t\tfi &&\n> \t\teval \"test_oid_${key}_${tag}=\\${val}\"\n\nYes.  I take it that you think that's easier to read, so I'll rewrite it\nthat way.  I will admit a tendency to write code that is more compact,\nsometimes (unintentionally) at the cost of readability.  Thanks for\nproviding a sanity check.\n\nI agree that expr is probably better than the echo and egrep.\n\n> > +\tdone\n> > +}\n> > +\n> > +test_oid () {\n> > +\teval \"\n> > +\t\ttest -n \\\"\\${test_oid_${test_hash_algo}_$1+set}\\\" &&\n> > +\t\tprintf '%s' \\\"\\${test_oid_${test_hash_algo}_$1}\\\"\n> > +\t\"\n> \n> I'm also having trouble taking this one in.  Maybe splitting into two\n> evals would work?\n> \n> \tvar=test_oid_${test_hash_algo}_$1 &&\n> \n> \teval \"test -n \\\"\\${$var+set}\\\"\" &&\n> \teval \"printf '%s\\n' \\\"\\${$var}\\\"\"\n> \n> What is the initial test meant to do?  Can this function get a\n> documentation comment?  Are we relying on \"test -n\" to return a failing\n> result if the variable is unset, or could the test be omitted (relying\n> on \"\\${$var}\" to evaluate to \"\" when the variable is unset)?  Should\n> this call 'error' when the variable is unset?\n\nYes.  The test -n will return false if the variable is unset, since\n${$var+set} evaluates to nothing if the variable is unset and \"set\" if\nit is set.  I will admit that I had to look this up in the shell\ndocumentation, so I'm not surprised that this is confusing at first\nglance.\n\nSwitching to error is probably better.\n\n> Can t/README describe the new test helpers?\n\nSure.  I wasn't aware that there was one to add this to, but now that\nyou've pointed it out, it makes sense to add them.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"357108","messageId":"20180831182141.GA9399@tor.lan","threadId":"49250","inReplyTo":"20180829005642.980617-6-sandals@crustytoothpaste.net","subject":"Re: [PATCH v3 05/11] t0027: make hash size independent","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-08-31T18:21:41Z","receivedAt":"2018-08-31T18:27:05Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Aug 29, 2018 at 12:56:36AM +0000, brian m. carlson wrote:\n> We transform various object IDs into all-zero object IDs for comparison.\n> Adjust the length as well so that this works for all hash algorithms.\n> \n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>  t/t0027-auto-crlf.sh | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> index beb5927f77..0f1235d9d1 100755\n> --- a/t/t0027-auto-crlf.sh\n> +++ b/t/t0027-auto-crlf.sh\n> @@ -14,11 +14,13 @@ compare_files () {\n>  compare_ws_file () {\n>  \tpfx=$1\n>  \texp=$2.expect\n> +\ttmp=$2.tmp\n>  \tact=$pfx.actual.$3\n> -\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n> +\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$tmp\" &&\n>  \ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n> +\tsed -e \"s/0000*/$ZERO_OID/\" \"$tmp\" >\"$exp\" &&\n>  \ttest_cmp \"$exp\" \"$act\" &&\n> -\trm \"$exp\" \"$act\"\n> +\trm \"$exp\" \"$act\" \"$tmp\"\n>  }\n>  \n>  create_gitattributes () {\n\nI only managed to review the changes in t0027.\nOut of interest: why do we use a \"tmp\" file here?\nWould it make more sense  to chain the 'tr' with 'sed' and skip the\ntmp file ?\n\n \ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" |\n\tsed -e \"s/0000*/$ZERO_OID/\"  >\"$exp\" &&\n\n\nYes, we will loose the exit status of 'tr', I think.\nHow important is the exit status ?\n\nI don't know, hopefully someone with more experience/knowledge\nabout shell scripting can help me out here.\n"},{"id":"357111","messageId":"CAPig+cSSs9a_RSnc6==zb70Swh1L1Ok4y-DGc8YawPyea0Gm9Q@mail.gmail.com","threadId":"49250","inReplyTo":"20180831182141.GA9399@tor.lan","subject":"Re: [PATCH v3 05/11] t0027: make hash size independent","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-08-31T18:40:12Z","receivedAt":"2018-08-31T18:40:25Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Aug 31, 2018 at 2:21 PM Torsten Bögershausen <tboegi@web.de> wrote:\n> > diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\n> > @@ -14,11 +14,13 @@ compare_files () {\n> >  compare_ws_file () {\n> > +     tmp=$2.tmp\n> >       act=$pfx.actual.$3\n> > -     tr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n> > +     tr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$tmp\" &&\n> >       tr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n> > +     sed -e \"s/0000*/$ZERO_OID/\" \"$tmp\" >\"$exp\" &&\n>\n> Out of interest: why do we use a \"tmp\" file here?\n> Would it make more sense  to chain the 'tr' with 'sed' and skip the\n> tmp file ?\n>\n>         tr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" |\n>         sed -e \"s/0000*/$ZERO_OID/\"  >\"$exp\" &&\n>\n> Yes, we will loose the exit status of 'tr', I think.\n> How important is the exit status ?\n\nAs far as I understand, it is only Git commands for which we worry\nabout losing the exit status upstream in pipes. System utilities, on\nthe other hand, are presumed to be bug-free, thus we don't mind having\nthem upstream.\n\nA different question is why does this need to run both 'tr' and 'sed'\nwhen 'sed itself could do the entire job since 'sed' has 'tr'\nfunctionality built in (see sed's \"y\" command)?\n"},{"id":"357161","messageId":"20180901153304.GM432229@genre.crustytoothpaste.net","threadId":"49250","inReplyTo":"CAPig+cSSs9a_RSnc6==zb70Swh1L1Ok4y-DGc8YawPyea0Gm9Q@mail.gmail.com","subject":"Re: [PATCH v3 05/11] t0027: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-01T15:33:09Z","receivedAt":"2018-09-01T15:33:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Fri, Aug 31, 2018 at 02:40:12PM -0400, Eric Sunshine wrote:\n> On Fri, Aug 31, 2018 at 2:21 PM Torsten Bögershausen <tboegi@web.de> wrote:\n> > Out of interest: why do we use a \"tmp\" file here?\n> > Would it make more sense  to chain the 'tr' with 'sed' and skip the\n> > tmp file ?\n> >\n> >         tr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" |\n> >         sed -e \"s/0000*/$ZERO_OID/\"  >\"$exp\" &&\n> >\n> > Yes, we will loose the exit status of 'tr', I think.\n> > How important is the exit status ?\n> \n> As far as I understand, it is only Git commands for which we worry\n> about losing the exit status upstream in pipes. System utilities, on\n> the other hand, are presumed to be bug-free, thus we don't mind having\n> them upstream.\n\nIf that's the case, that's fine, and I can make that change.  I know\nthat we do often want to preserve the exit status of a system command,\nbut presumably the tr and sed here would exit 0, so I'm happy to assume\nthat for the test.\n\n> A different question is why does this need to run both 'tr' and 'sed'\n> when 'sed itself could do the entire job since 'sed' has 'tr'\n> functionality built in (see sed's \"y\" command)?\n\nIt doesn't.  I went for a minimal change, but I could switch to using\nboth s/// and y/// in sed instead.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}