{"thread":{"id":"49271","subject":"[PATCH v4 00/12] Hash-independent tests (part 3)","startedAt":"2018-09-03T23:25:34Z","lastAt":"2018-09-05T22:50:12Z","messageCount":18,"participants":["brian m. carlson","Eric Sunshine","Derrick Stolee","Duy Nguyen","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":12},"messages":[{"id":"357267","messageId":"20180903232515.336397-1-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":null,"subject":"[PATCH v4 00/12] Hash-independent tests (part 3)","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:03Z","receivedAt":"2018-09-03T23:25:34Z","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 v3:\n* Update t/README to specify new helpers.\n* Escape \"$\" in double quotes.\n* Add documentation comments to test helpers.\n* Use local instead of underscores in variable names.\n* Use expr instead of egrep to match hash algorithm names.\n* Improve clarity of unset variable check in test_oid.\n* Wrap test_oid_init in a test_expect_success.\n* Improved && chain handling in test functions.\n* Add test_detect_hash in test_oid_init.\n* Clean up extra blank line.\n* Add patch from Derrick Stolee for t5318, modified slightly.\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\n\nDerrick Stolee (1):\n  t5318: use test_oid for HASH_LEN\n\nbrian m. carlson (11):\n  t: add test functions 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/README                       |  22 ++++\n t/oid-info/README              |  19 +++\n t/oid-info/hash-info           |   8 ++\n t/oid-info/oid                 |  29 +++++\n t/t0000-basic.sh               | 213 ++++++++++++++++++++++-----------\n t/t0002-gitfile.sh             |  27 +++--\n t/t0027-auto-crlf.sh           |   3 +-\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/t5318-commit-graph.sh        |   5 +-\n t/test-lib-functions.sh        |  67 +++++++++++\n 15 files changed, 350 insertions(+), 114 deletions(-)\n create mode 100644 t/oid-info/README\n create mode 100644 t/oid-info/hash-info\n create mode 100644 t/oid-info/oid\n\nrange-diff:\n\n 1:  a897533a90 !  1:  fd13b542e7 t: add tool to translate hash-related values\n    @@ -1,25 +1,115 @@\n     Author: brian m. carlson <sandals@crustytoothpaste.net>\n     \n    -    t: add tool to translate hash-related values\n    +    t: add test functions 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 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    +    Add several test functions to make working with various hash-related\n    +    values easier.\n    +\n    +    Add test_oid_init, which loads common hash-related constants and\n    +    placeholder object IDs from the newly added files in t/oid-info.\n    +    Provide values for these constants for both SHA-1 and SHA-256.\n    +\n    +    Add test_oid_cache, which accepts data on standard input in the form of\n    +    hash-specific key-value pairs that can be looked up later, using the\n    +    same format as the files in t/oid-info.  Document this format in a\n    +    t/oid-info/README directory so that it's easier to use in the future.\n    +\n    +    Add test_oid, which is used to specify look up a per-hash value\n    +    (produced on standard output) based on the key specified as its\n    +    argument.  Usually the data to be looked up will be a hash-related\n    +    constant (such as the size of the hash in binary or hexadecimal), a\n    +    well-known or placeholder object ID (such as the all-zeros object ID or\n    +    one consisting of \"deadbeef\" repeated), or something similar.  For these\n    +    reasons, test_oid will usually be used within a command substitution.\n    +    Consequently, redirect the error output to standard error, since\n    +    otherwise it will not be displayed.\n    +\n    +    Add test_detect_hash, which currently only detects SHA-1, and\n    +    test_set_hash, which can be used to set a different hash algorithm for\n    +    test purposes.  In the future, test_detect_hash will learn to actually\n    +    detect the hash depending on how the testsuite is to be run.\n    +\n    +    Use the local keyword within these functions to avoid overwriting other\n    +    shell variables.  We have had a test balloon in place for a couple of\n    +    releases to catch shells that don't have this keyword and have not\n    +    received any reports of failure.  Note that the varying usages of local\n    +    used here are supported by all common open-source shells supporting the\n    +    local keyword.\n    +\n    +    Test these new functions as part of t0000, which also serves to\n    +    demonstrate basic usage of them.  In addition, add documentation on how\n    +    to format the lookup data and how to use the test functions.\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    +    Provide versions of the data for both SHA-1 and SHA-256.\n     \n    -    Note that due to the implementation used, names used for lookup can\n    +    Since we use shell variables for storage, 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    +    Improved-by: Eric Sunshine <sunshine@sunshineco.com>\n         Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>\n         Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n     \n    + diff --git a/t/README b/t/README\n    + --- a/t/README\n    + +++ b/t/README\n    +@@\n    +    the symbolic link in the file system and a part that does; then only\n    +    the latter part need be protected by a SYMLINKS prerequisite (see below).\n    + \n    ++ - test_oid_init\n    ++\n    ++   This function loads facts and useful object IDs related to the hash\n    ++   algorithm(s) in use from the files in t/oid-info.\n    ++\n    ++ - test_oid_cache\n    ++\n    ++   This function reads per-hash algorithm information from standard\n    ++   input (usually a heredoc) in the format described in\n    ++   t/oid-info/README.  This is useful for test-specific values, such as\n    ++   object IDs, which must vary based on the hash algorithm.\n    ++\n    ++   Certain fixed values, such as hash sizes and common placeholder\n    ++   object IDs, can be loaded with test_oid_init (described above).\n    ++\n    ++ - test_oid <key>\n    ++\n    ++   This function looks up a value for the hash algorithm in use, based\n    ++   on the key given.  The value must have been loaded using\n    ++   test_oid_init or test_oid_cache.  Providing an unknown key is an\n    ++   error.\n    ++\n    + Prerequisites\n    + -------------\n    + \n    +\n    + diff --git a/t/oid-info/README b/t/oid-info/README\n    + new file mode 100644\n    + --- /dev/null\n    + +++ b/t/oid-info/README\n    +@@\n    ++This directory contains various per-hash values that are used in the testsuite.\n    ++\n    ++Each file contains lines containing a key-value pair; blank lines and lines\n    ++starting with `#` are ignored.  The key and value are separated by whitespace\n    ++(specifically, those whitespace in the default `$IFS`).  The key consists only\n    ++of shell identifier characters, and the value consists of a hash algorithm,\n    ++colon, and value.  The hash algorithm also consists only of shell identifier\n    ++characters; it should match the value in sha1-file.c.\n    ++\n    ++For example, the following lines map the key \"rawsz\" to \"20\" if SHA-1 is in use\n    ++and to \"32\" if SHA-256 is in use:\n    ++\n    ++----\n    ++rawsz sha1:20\n    ++rawsz sha256:32\n    ++----\n    ++\n    ++The keys and values used here are loaded by `test_oid_init` (see the README file\n    ++in the \"t\" directory) and are used by calling `test_oid`.\n    +\n      diff --git a/t/oid-info/hash-info b/t/oid-info/hash-info\n      new file mode 100644\n      --- /dev/null\n    @@ -76,11 +166,13 @@\n      \tEOF\n      \"\n      \n    -+test_oid_init\n    ++test_expect_success 'test_oid setup' '\n    ++\ttest_oid_init\n    ++'\n     +\n     +test_expect_success 'test_oid provides sane info by default' '\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 \"$hexsz\" -eq $(wc -c <actual) &&\n    @@ -91,7 +183,7 @@\n     +\ttest_when_finished \"test_detect_hash\" &&\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    @@ -103,7 +195,7 @@\n     +\ttest_when_finished \"test_detect_hash\" &&\n     +\ttest_set_hash sha256 &&\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 64 &&\n    @@ -123,24 +215,38 @@\n      \t'\n      }\n     +\n    ++# Set the hash algorithm in use to $1.  Only useful when testing the testsuite.\n     +test_set_hash () {\n     +\ttest_hash_algo=\"$1\"\n     +}\n     +\n    ++# Detect the hash algorithm in use.\n     +test_detect_hash () {\n     +\ttest_hash_algo='sha1'\n     +}\n     +\n    ++# Load common hash metadata and common placeholder object IDs for use with\n    ++# test_oid.\n     +test_oid_init () {\n    ++\ttest -n \"$test_hash_algo\" || test_detect_hash &&\n     +\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/hash-info\" &&\n     +\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/oid\"\n     +}\n     +\n    ++# Load key-value pairs from stdin suitable for use with test_oid.  Blank lines\n    ++# and lines starting with \"#\" are ignored.  Keys must be shell identifier\n    ++# characters.\n    ++#\n    ++# Examples:\n    ++# rawsz sha1:20\n    ++# rawsz sha256:32\n     +test_oid_cache () {\n    -+\ttest -n \"$test_hash_algo\" || test_detect_hash\n    -+\twhile read _tag _rest\n    ++\tlocal tag reset k v\n    ++\n    ++\ttest -n \"$test_hash_algo\" || test_detect_hash &&\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    @@ -149,20 +255,29 @@\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    ++\t\tk=\"${rest%:*}\" &&\n    ++\t\tv=\"${rest#*:}\" &&\n    ++\n    ++\t\tif ! expr \"$k\" : '[a-z0-9][a-z0-9]*$' >/dev/null\n    ++\t\tthen\n    ++\t\t\terror 'bug in the test script: bad hash algorithm'\n    ++\t\tfi &&\n    ++\t\teval \"test_oid_${k}_$tag=\\\"\\$v\\\"\"\n     +\tdone\n     +}\n     +\n    ++# Look up a per-hash value based on a key ($1).  The value must have been loaded\n    ++# by test_oid_init or test_oid_cache.\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    ++\tlocal var=\"test_oid_${test_hash_algo}_$1\"\n    ++\n    ++\t# If the variable is unset, we must be missing an entry for this\n    ++\t# key-hash pair, so exit with an error.\n    ++\tif eval \"test -z \\\"\\${$var+set}\\\"\"\n    ++\tthen\n    ++\t\terror \"bug in the test script: undefined key '$1'\" >&2\n    ++\tfi &&\n    ++\teval \"printf '%s' \\\"\\${$var}\\\"\"\n     +}\n 2:  d63dc976f4 =  2:  335c75e1ec t0000: use hash translation table\n 3:  9e55529efd =  3:  257b458ad9 t0000: update tests for SHA-256\n 4:  4d5b8d4025 =  4:  69080d3bfc t0002: abstract away SHA-1 specific constants\n 5:  6037c4d10a <  -:  ---------- t0027: make hash size independent\n -:  ---------- >  5:  a4297d7ae8 t0027: make hash size independent\n 6:  dfad561965 =  6:  7cf1221274 t0064: make hash size independent\n 7:  8a860a7492 =  7:  7e5c857c25 t1006: make hash size independent\n 8:  1baaf8374a =  8:  9271787d4b t1400: switch hard-coded object ID to variable\n 9:  232c043ed7 =  9:  43bd41156a t1405: make hash size independent\n10:  9d0207bc52 = 10:  875bbd7fc5 t1406: make hash-size independent\n11:  d292c6311f = 11:  a9c2d31089 t1407: make hash size independent\n -:  ---------- > 12:  10452cc352 t5318: use test_oid for HASH_LEN\n"},{"id":"357269","messageId":"20180903232515.336397-3-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 02/12] t0000: use hash translation table","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:05Z","receivedAt":"2018-09-03T23:25:34Z","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 b94221b951..a9dc534048 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -1015,12 +1015,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":"357268","messageId":"20180903232515.336397-2-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 01/12] t: add test functions to translate hash-related values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:04Z","receivedAt":"2018-09-03T23:25:35Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Add several test functions to make working with various hash-related\nvalues easier.\n\nAdd test_oid_init, which loads common hash-related constants and\nplaceholder object IDs from the newly added files in t/oid-info.\nProvide values for these constants for both SHA-1 and SHA-256.\n\nAdd test_oid_cache, which accepts data on standard input in the form of\nhash-specific key-value pairs that can be looked up later, using the\nsame format as the files in t/oid-info.  Document this format in a\nt/oid-info/README directory so that it's easier to use in the future.\n\nAdd test_oid, which is used to specify look up a per-hash value\n(produced on standard output) based on the key specified as its\nargument.  Usually the data to be looked up will be a hash-related\nconstant (such as the size of the hash in binary or hexadecimal), a\nwell-known or placeholder object ID (such as the all-zeros object ID or\none consisting of \"deadbeef\" repeated), or something similar.  For these\nreasons, test_oid will usually be used within a command substitution.\nConsequently, redirect the error output to standard error, since\notherwise it will not be displayed.\n\nAdd test_detect_hash, which currently only detects SHA-1, and\ntest_set_hash, which can be used to set a different hash algorithm for\ntest purposes.  In the future, test_detect_hash will learn to actually\ndetect the hash depending on how the testsuite is to be run.\n\nUse the local keyword within these functions to avoid overwriting other\nshell variables.  We have had a test balloon in place for a couple of\nreleases to catch shells that don't have this keyword and have not\nreceived any reports of failure.  Note that the varying usages of local\nused here are supported by all common open-source shells supporting the\nlocal keyword.\n\nTest these new functions as part of t0000, which also serves to\ndemonstrate basic usage of them.  In addition, add documentation on how\nto format the lookup data and how to use the test functions.\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 of the data for both SHA-1 and SHA-256.\n\nSince we use shell variables for storage, 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\nImproved-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/README                | 22 ++++++++++++++\n t/oid-info/README       | 19 ++++++++++++\n t/oid-info/hash-info    |  8 +++++\n t/oid-info/oid          | 29 ++++++++++++++++++\n t/t0000-basic.sh        | 37 +++++++++++++++++++++++\n t/test-lib-functions.sh | 67 +++++++++++++++++++++++++++++++++++++++++\n 6 files changed, 182 insertions(+)\n create mode 100644 t/oid-info/README\n create mode 100644 t/oid-info/hash-info\n create mode 100644 t/oid-info/oid\n\ndiff --git a/t/README b/t/README\nindex 9028b47d92..eed574dd9b 100644\n--- a/t/README\n+++ b/t/README\n@@ -806,6 +806,28 @@ library for your script to use.\n    the symbolic link in the file system and a part that does; then only\n    the latter part need be protected by a SYMLINKS prerequisite (see below).\n \n+ - test_oid_init\n+\n+   This function loads facts and useful object IDs related to the hash\n+   algorithm(s) in use from the files in t/oid-info.\n+\n+ - test_oid_cache\n+\n+   This function reads per-hash algorithm information from standard\n+   input (usually a heredoc) in the format described in\n+   t/oid-info/README.  This is useful for test-specific values, such as\n+   object IDs, which must vary based on the hash algorithm.\n+\n+   Certain fixed values, such as hash sizes and common placeholder\n+   object IDs, can be loaded with test_oid_init (described above).\n+\n+ - test_oid <key>\n+\n+   This function looks up a value for the hash algorithm in use, based\n+   on the key given.  The value must have been loaded using\n+   test_oid_init or test_oid_cache.  Providing an unknown key is an\n+   error.\n+\n Prerequisites\n -------------\n \ndiff --git a/t/oid-info/README b/t/oid-info/README\nnew file mode 100644\nindex 0000000000..27f843fc00\n--- /dev/null\n+++ b/t/oid-info/README\n@@ -0,0 +1,19 @@\n+This directory contains various per-hash values that are used in the testsuite.\n+\n+Each file contains lines containing a key-value pair; blank lines and lines\n+starting with `#` are ignored.  The key and value are separated by whitespace\n+(specifically, those whitespace in the default `$IFS`).  The key consists only\n+of shell identifier characters, and the value consists of a hash algorithm,\n+colon, and value.  The hash algorithm also consists only of shell identifier\n+characters; it should match the value in sha1-file.c.\n+\n+For example, the following lines map the key \"rawsz\" to \"20\" if SHA-1 is in use\n+and to \"32\" if SHA-256 is in use:\n+\n+----\n+rawsz sha1:20\n+rawsz sha256:32\n+----\n+\n+The keys and values used here are loaded by `test_oid_init` (see the README file\n+in the \"t\" directory) and are used by calling `test_oid`.\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..b94221b951 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -821,6 +821,43 @@ test_expect_success 'tests clean up even on failures' \"\n \tEOF\n \"\n \n+test_expect_success 'test_oid setup' '\n+\ttest_oid_init\n+'\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..9eca6c620d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1155,3 +1155,70 @@ depacketize () {\n \t\t}\n \t'\n }\n+\n+# Set the hash algorithm in use to $1.  Only useful when testing the testsuite.\n+test_set_hash () {\n+\ttest_hash_algo=\"$1\"\n+}\n+\n+# Detect the hash algorithm in use.\n+test_detect_hash () {\n+\ttest_hash_algo='sha1'\n+}\n+\n+# Load common hash metadata and common placeholder object IDs for use with\n+# test_oid.\n+test_oid_init () {\n+\ttest -n \"$test_hash_algo\" || test_detect_hash &&\n+\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/hash-info\" &&\n+\ttest_oid_cache <\"$TEST_DIRECTORY/oid-info/oid\"\n+}\n+\n+# Load key-value pairs from stdin suitable for use with test_oid.  Blank lines\n+# and lines starting with \"#\" are ignored.  Keys must be shell identifier\n+# characters.\n+#\n+# Examples:\n+# rawsz sha1:20\n+# rawsz sha256:32\n+test_oid_cache () {\n+\tlocal tag reset k v\n+\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+\t\tesac &&\n+\n+\t\tk=\"${rest%:*}\" &&\n+\t\tv=\"${rest#*:}\" &&\n+\n+\t\tif ! expr \"$k\" : '[a-z0-9][a-z0-9]*$' >/dev/null\n+\t\tthen\n+\t\t\terror 'bug in the test script: bad hash algorithm'\n+\t\tfi &&\n+\t\teval \"test_oid_${k}_$tag=\\\"\\$v\\\"\"\n+\tdone\n+}\n+\n+# Look up a per-hash value based on a key ($1).  The value must have been loaded\n+# by test_oid_init or test_oid_cache.\n+test_oid () {\n+\tlocal var=\"test_oid_${test_hash_algo}_$1\"\n+\n+\t# If the variable is unset, we must be missing an entry for this\n+\t# key-hash pair, so exit with an error.\n+\tif eval \"test -z \\\"\\${$var+set}\\\"\"\n+\tthen\n+\t\terror \"bug in the test script: undefined key '$1'\" >&2\n+\tfi &&\n+\teval \"printf '%s' \\\"\\${$var}\\\"\"\n+}\n"},{"id":"357270","messageId":"20180903232515.336397-4-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 03/12] t0000: update tests for SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:06Z","receivedAt":"2018-09-03T23:25:37Z","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 a9dc534048..391f910c6a 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -861,6 +861,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@@ -876,8 +917,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@@ -919,16 +960,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@@ -937,20 +978,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@@ -961,16 +1002,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@@ -980,19 +1021,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@@ -1001,16 +1042,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@@ -1044,16 +1085,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@@ -1069,23 +1110,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":"357271","messageId":"20180903232515.336397-6-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 05/12] t0027: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:08Z","receivedAt":"2018-09-03T23:25:38Z","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\nWhile it would be slightly more efficient to use a sed y/// expression\ninstead of both the tr and sed, retain the tr in both cases for\nparallelism and compactness.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0027-auto-crlf.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex beb5927f77..dfb46bbe86 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -15,7 +15,8 @@ compare_ws_file () {\n \tpfx=$1\n \texp=$2.expect\n \tact=$pfx.actual.$3\n-\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" |\n+\t\tsed -e \"s/0000*/$ZERO_OID/\" >\"$exp\" &&\n \ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" >\"$act\" &&\n \ttest_cmp \"$exp\" \"$act\" &&\n \trm \"$exp\" \"$act\"\n"},{"id":"357272","messageId":"20180903232515.336397-7-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 06/12] t0064: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:09Z","receivedAt":"2018-09-03T23:25:39Z","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":"357273","messageId":"20180903232515.336397-5-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 04/12] t0002: abstract away SHA-1 specific constants","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:07Z","receivedAt":"2018-09-03T23:25:40Z","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":"357274","messageId":"20180903232515.336397-8-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 07/12] t1006: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:10Z","receivedAt":"2018-09-03T23:25:44Z","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":"357276","messageId":"20180903232515.336397-9-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 08/12] t1400: switch hard-coded object ID to variable","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:11Z","receivedAt":"2018-09-03T23:25:45Z","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":"357275","messageId":"20180903232515.336397-10-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 09/12] t1405: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:12Z","receivedAt":"2018-09-03T23:25:46Z","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":"357277","messageId":"20180903232515.336397-11-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 10/12] t1406: make hash-size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:13Z","receivedAt":"2018-09-03T23:25:47Z","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":"357278","messageId":"20180903232515.336397-12-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 11/12] t1407: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:14Z","receivedAt":"2018-09-03T23:25:49Z","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":"357279","messageId":"20180903232515.336397-13-sandals@crustytoothpaste.net","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"[PATCH v4 12/12] t5318: use test_oid for HASH_LEN","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-03T23:25:15Z","receivedAt":"2018-09-03T23:25:50Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"From: Derrick Stolee <stolee@gmail.com>\n\nSigned-off-by: Derrick Stolee <dstolee@microsoft.com>\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t5318-commit-graph.sh | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh\nindex 3c1ffad491..d286516f0e 100755\n--- a/t/t5318-commit-graph.sh\n+++ b/t/t5318-commit-graph.sh\n@@ -8,7 +8,8 @@ test_expect_success 'setup full repo' '\n \tcd \"$TRASH_DIRECTORY/full\" &&\n \tgit init &&\n \tgit config core.commitGraph true &&\n-\tobjdir=\".git/objects\"\n+\tobjdir=\".git/objects\" &&\n+\ttest_oid_init\n '\n \n test_expect_success 'verify graph with no graph file' '\n@@ -273,7 +274,7 @@ test_expect_success 'git commit-graph verify' '\n \n NUM_COMMITS=9\n NUM_OCTOPUS_EDGES=2\n-HASH_LEN=20\n+HASH_LEN=\"$(test_oid rawsz)\"\n GRAPH_BYTE_VERSION=4\n GRAPH_BYTE_HASH=5\n GRAPH_BYTE_CHUNK_COUNT=6\n"},{"id":"357281","messageId":"CAPig+cQZMEvJZ2b3RjtXvy9ZtTjRKUvye_xT0nibOqcHtpApZQ@mail.gmail.com","threadId":"49271","inReplyTo":"20180903232515.336397-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH v4 01/12] t: add test functions to translate hash-related values","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-09-04T00:01:35Z","receivedAt":"2018-09-04T00:01:49Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Sep 3, 2018 at 7:25 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> Add several test functions to make working with various hash-related\n> values easier.\n> [...]\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> @@ -1155,3 +1155,70 @@ depacketize () {\n> +# Detect the hash algorithm in use.\n> +test_detect_hash () {\n> +       test_hash_algo='sha1'\n> +}\n\nNot worth a re-roll itself, but if you do re-roll for some reason,\nperhaps include a comment inside the function saying that the actual\n\"detect\" part will be fleshed out later.\n\n> +test_oid_cache () {\n> +       local tag reset k v\n\ns/reset/rest/\n\nIt probably wouldn't hurt to &&-chain the above, as well, to\nfuture-proof it against someone coming along and inserting code before\nthe 'local' line.\n\n> +       test -n \"$test_hash_algo\" || test_detect_hash &&\n> +       while read tag rest\n> +       do\n> +               case $tag in\n> +               [...]\n> +               esac &&\n> +\n> +               k=\"${rest%:*}\" &&\n> +               v=\"${rest#*:}\" &&\n> +\n> +               if ! expr \"$k\" : '[a-z0-9][a-z0-9]*$' >/dev/null\n> +               then\n> +                       error 'bug in the test script: bad hash algorithm'\n\nDid you want to redirect this to stderr like you do with error() in test_oid()?\n\n> +               fi &&\n> +               eval \"test_oid_${k}_$tag=\\\"\\$v\\\"\"\n> +       done\n> +}\n"},{"id":"357292","messageId":"8af735dc-99cd-f297-415f-24e53ea77344@gmail.com","threadId":"49271","inReplyTo":"20180903232515.336397-13-sandals@crustytoothpaste.net","subject":"Re: [PATCH v4 12/12] t5318: use test_oid for HASH_LEN","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-09-04T12:36:11Z","receivedAt":"2018-09-04T12:36:17Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 9/3/2018 7:25 PM, brian m. carlson wrote:\n> From: Derrick Stolee <stolee@gmail.com>\n>\n> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>   t/t5318-commit-graph.sh | 5 +++--\n>   1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh\n> index 3c1ffad491..d286516f0e 100755\n> --- a/t/t5318-commit-graph.sh\n> +++ b/t/t5318-commit-graph.sh\n> @@ -8,7 +8,8 @@ test_expect_success 'setup full repo' '\n>   \tcd \"$TRASH_DIRECTORY/full\" &&\n>   \tgit init &&\n>   \tgit config core.commitGraph true &&\n> -\tobjdir=\".git/objects\"\n> +\tobjdir=\".git/objects\" &&\n> +\ttest_oid_init\n>   '\n\nAh yes, thanks for adding this.\n\n>   \n>   test_expect_success 'verify graph with no graph file' '\n> @@ -273,7 +274,7 @@ test_expect_success 'git commit-graph verify' '\n>   \n>   NUM_COMMITS=9\n>   NUM_OCTOPUS_EDGES=2\n> -HASH_LEN=20\n> +HASH_LEN=\"$(test_oid rawsz)\"\n>   GRAPH_BYTE_VERSION=4\n>   GRAPH_BYTE_HASH=5\n>   GRAPH_BYTE_CHUNK_COUNT=6\n"},{"id":"357302","messageId":"CACsJy8Ak3Gba-z09Gz8iFrRyXoLbR+jW0tGuPnwCLpxVZWfMtw@mail.gmail.com","threadId":"49271","inReplyTo":"20180903232515.336397-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH v4 00/12] Hash-independent tests (part 3)","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-09-04T16:22:58Z","receivedAt":"2018-09-04T16:23:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Sep 4, 2018 at 1:26 AM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> This is the next in the series of improvements to make tests\n> hash-independent.\n\nIf it helps, I looked over the series and didn't find anything questionable.\n-- \nDuy\n"},{"id":"357332","messageId":"xmqqmusx837u.fsf@gitster-ct.c.googlers.com","threadId":"49271","inReplyTo":"CACsJy8Ak3Gba-z09Gz8iFrRyXoLbR+jW0tGuPnwCLpxVZWfMtw@mail.gmail.com","subject":"Re: [PATCH v4 00/12] Hash-independent tests (part 3)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-09-04T19:36:21Z","receivedAt":"2018-09-04T19:36:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Tue, Sep 4, 2018 at 1:26 AM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n>>\n>> This is the next in the series of improvements to make tests\n>> hash-independent.\n>\n> If it helps, I looked over the series and didn't find anything questionable.\n\nThanks.  I'll tick the message I am resopnding to in my Inbox so\nthat I know I can come back to it later after the final release.\n"},{"id":"357490","messageId":"20180905225004.GO432229@genre.crustytoothpaste.net","threadId":"49271","inReplyTo":"CAPig+cQZMEvJZ2b3RjtXvy9ZtTjRKUvye_xT0nibOqcHtpApZQ@mail.gmail.com","subject":"Re: [PATCH v4 01/12] t: add test functions to translate hash-related values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-05T22:50:04Z","receivedAt":"2018-09-05T22:50:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Sep 03, 2018 at 08:01:35PM -0400, Eric Sunshine wrote:\n> On Mon, Sep 3, 2018 at 7:25 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > Add several test functions to make working with various hash-related\n> > values easier.\n> > [...]\n> > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> > @@ -1155,3 +1155,70 @@ depacketize () {\n> > +# Detect the hash algorithm in use.\n> > +test_detect_hash () {\n> > +       test_hash_algo='sha1'\n> > +}\n> \n> Not worth a re-roll itself, but if you do re-roll for some reason,\n> perhaps include a comment inside the function saying that the actual\n> \"detect\" part will be fleshed out later.\n\nSure.\n\n> > +test_oid_cache () {\n> > +       local tag reset k v\n> \n> s/reset/rest/\n> \n> It probably wouldn't hurt to &&-chain the above, as well, to\n> future-proof it against someone coming along and inserting code before\n> the 'local' line.\n\nI'll fix that and reroll.\n\n> > +       test -n \"$test_hash_algo\" || test_detect_hash &&\n> > +       while read tag rest\n> > +       do\n> > +               case $tag in\n> > +               [...]\n> > +               esac &&\n> > +\n> > +               k=\"${rest%:*}\" &&\n> > +               v=\"${rest#*:}\" &&\n> > +\n> > +               if ! expr \"$k\" : '[a-z0-9][a-z0-9]*$' >/dev/null\n> > +               then\n> > +                       error 'bug in the test script: bad hash algorithm'\n> \n> Did you want to redirect this to stderr like you do with error() in test_oid()?\n\nNo, I don't believe it's necessary.  The commit message hints at this\nslightly, but test_oid_cache is run with stdout unredirected, while\ntest_oid is run inside a command substitution (where stdout is\nessentially redirected).\n\nThe issue with test_oid is not that it doesn't abort successfully (it\ndoes) but that you don't see the error message and therefore have no\nclue why your test suddenly exited 1, which is unfriendly to developers\nwhen they make this mistake.  Since that's not an issue here, I opted\nnot to redirect it.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}