{"thread":{"id":"51327","subject":"[PATCH v2 00/10] Hash-independent tests, part 4","startedAt":"2019-06-16T18:53:52Z","lastAt":"2019-06-19T19:56:51Z","messageCount":20,"participants":["brian m. carlson","Johannes Schindelin","Johannes Sixt","SZEDER Gábor","Jeff King"],"isPatch":true,"patchVersion":2,"patchTotal":10},"messages":[{"id":"377321","messageId":"20190616185330.549436-1-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":null,"subject":"[PATCH v2 00/10] Hash-independent tests, part 4","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:20Z","receivedAt":"2019-06-16T18:53:52Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is an additional series of fixes for tests to make them work with\nSHA-256.\n\nThis series makes use of several constants, such as $ZERO_OID, which\nwill be replaced with appropriate values based on \"test_oid\" with later\nwork.\n\nThere is one test (t1410) which adds an SHA1 prerequisite. I wasn't able\nto get the math to work out when trying to compute the proper values for\nSHA-256, and the test doesn't test what it's supposed to test without\nchanges, so I opted to mark it with a prerequisite. Suggestions on how\nto make it functionally useful under SHA-256 would be appreciated.\n\nbrian m. carlson (10):\n  t: add helper to convert object IDs to paths\n  t1410: make hash size independent\n  t1450: make hash size independent\n  t5000: make hash independent\n  t6030: make test work with SHA-256\n  t0027: make hash size independent\n  t0090: make test pass with SHA-256\n  t1007: remove SHA1 prerequisites\n  t1710: make hash independent\n  t2203: avoid hard-coded object ID values\n\n t/t0027-auto-crlf.sh                          |   6 +-\n t/t0090-cache-tree.sh                         |   4 +-\n t/t1007-hash-object.sh                        |  58 ++++++++++--------\n t/t1410-reflog.sh                             |  16 ++---\n t/t1450-fsck.sh                               |  41 ++++++++-----\n t/t1700-split-index.sh                        |  51 ++++++++++-----\n t/t2203-add-intent.sh                         |   6 +-\n t/t5000-tar-tree.sh                           |  16 +++--\n ...8938e6999cb59b3ff66739902a => huge-object} | Bin\n t/t6030-bisect-porcelain.sh                   |  31 +++++-----\n t/test-lib-functions.sh                       |   6 ++\n 11 files changed, 142 insertions(+), 93 deletions(-)\n rename t/t5000/{19f9c8273ec45a8938e6999cb59b3ff66739902a => huge-object} (100%)\n\n"},{"id":"377322","messageId":"20190616185330.549436-2-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:21Z","receivedAt":"2019-06-16T18:53:57Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"There are several places in our testsuite where we want to insert a\nslash after an object ID to make it into a path we can reference under\n.git/objects, and we have various ways of doing so.  Add a helper to\nprovide a standard way of doing this that works for all size hashes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/test-lib-functions.sh | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 8270de74be..11a6abca2e 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1314,6 +1314,12 @@ test_oid () {\n \teval \"printf '%s' \\\"\\${$var}\\\"\"\n }\n \n+# Insert a slash into an object ID so it can be used to reference a location\n+# under \".git/objects\".  For example, \"deadbeef...\" becomes \"de/adbeef..\".\n+test_oid_to_path () {\n+\techo \"$1\" | sed -e 's!^..!&/!'\n+}\n+\n # Choose a port number based on the test script's number and store it in\n # the given variable name, unless that variable already contains a number.\n test_set_port () {\n"},{"id":"377323","messageId":"20190616185330.549436-3-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 02/10] t1410: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:22Z","receivedAt":"2019-06-16T18:53:57Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of parsing object IDs using fixed-length shell patterns, use cut\nto extract the first two characters of an object ID in addition to the\ntest helper for object paths.  Update another test to look up an\nappropriate object ID fragment from the all-zeros object ID instead of\nhardcoding the value.\n\nAlthough the test for parsing reflogs at BUFSIZ boundaries passes, mark\nit with the SHA1 prerequisite, as it doesn't currently usefully test\nanything when using a hash longer than 20 bytes.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1410-reflog.sh | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh\nindex 79f731db37..82950c0282 100755\n--- a/t/t1410-reflog.sh\n+++ b/t/t1410-reflog.sh\n@@ -30,14 +30,13 @@ check_fsck () {\n }\n \n corrupt () {\n-\taa=${1%??????????????????????????????????????} zz=${1#??}\n-\tmv .git/objects/$aa/$zz .git/$aa$zz\n+\tmv .git/objects/$(test_oid_to_path $1) .git/$1\n }\n \n recover () {\n-\taa=${1%??????????????????????????????????????} zz=${1#??}\n+\taa=$(echo $1 | cut -c 1-2)\n \tmkdir -p .git/objects/$aa\n-\tmv .git/$aa$zz .git/objects/$aa/$zz\n+\tmv .git/$1 .git/objects/$(test_oid_to_path $1)\n }\n \n check_dont_have () {\n@@ -55,6 +54,7 @@ check_dont_have () {\n }\n \n test_expect_success setup '\n+\ttest_oid_init &&\n \tmkdir -p A/B &&\n \techo rat >C &&\n \techo ox >A/D &&\n@@ -313,12 +313,12 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '\n # Each line is 114 characters, so we need 75 to still have a few before the\n # last 8K. The 89-character padding on the final entry lines up our\n # newline exactly.\n-test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '\n+test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '\n \tgit checkout -b reflogskip &&\n-\tz38=00000000000000000000000000000000000000 &&\n+\tzf=$(test_oid zero_2) &&\n \tident=\"abc <xyz> 0000000001 +0000\" &&\n \tfor i in $(test_seq 1 75); do\n-\t\tprintf \"$z38%02d $z38%02d %s\\t\" $i $(($i+1)) \"$ident\" &&\n+\t\tprintf \"$zf%02d $zf%02d %s\\t\" $i $(($i+1)) \"$ident\" &&\n \t\tif test $i = 75; then\n \t\t\tfor j in $(test_seq 1 89); do\n \t\t\t\tprintf X\n@@ -329,7 +329,7 @@ test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '\n \t\tprintf \"\\n\"\n \tdone >.git/logs/refs/heads/reflogskip &&\n \tgit rev-parse reflogskip@{73} >actual &&\n-\techo ${z38}03 >expect &&\n+\techo ${zf}03 >expect &&\n \ttest_cmp expect actual\n '\n \n"},{"id":"377324","messageId":"20190616185330.549436-4-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 03/10] t1450: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:23Z","receivedAt":"2019-06-16T18:53:58Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Replace several hard-coded full and partial object IDs with variables or\ncomputed values.  Create junk data to stuff inside an invalid tree that\ncan be either 20 or 32 bytes long.  Compute a binary all-zeros object ID\ninstead of hard-coding a 20-byte length.\n\nAdditionally, compute various object IDs by using test_oid and\n$EMPTY_BLOB so that this test works with multiple hash algorithms.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1450-fsck.sh | 41 +++++++++++++++++++++++++----------------\n 1 file changed, 25 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh\nindex 0f268a3664..b36e0528d0 100755\n--- a/t/t1450-fsck.sh\n+++ b/t/t1450-fsck.sh\n@@ -9,6 +9,7 @@ test_description='git fsck random collection of tests\n . ./test-lib.sh\n \n test_expect_success setup '\n+\ttest_oid_init &&\n \tgit config gc.auto 0 &&\n \tgit config i18n.commitencoding ISO-8859-1 &&\n \ttest_commit A fileA one &&\n@@ -54,8 +55,8 @@ test_expect_success 'setup: helpers for corruption tests' '\n \n test_expect_success 'object with bad sha1' '\n \tsha=$(echo blob | git hash-object -w --stdin) &&\n-\told=$(echo $sha | sed \"s+^..+&/+\") &&\n-\tnew=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&\n+\told=$(test_oid_to_path \"$sha\") &&\n+\tnew=$(dirname $old)/$(test_oid ff_2) &&\n \tsha=\"$(dirname $new)$(basename $new)\" &&\n \tmv .git/objects/$old .git/objects/$new &&\n \ttest_when_finished \"remove_object $sha\" &&\n@@ -84,7 +85,7 @@ test_expect_success 'branch pointing to non-commit' '\n test_expect_success 'HEAD link pointing at a funny object' '\n \ttest_when_finished \"mv .git/SAVED_HEAD .git/HEAD\" &&\n \tmv .git/HEAD .git/SAVED_HEAD &&\n-\techo 0000000000000000000000000000000000000000 >.git/HEAD &&\n+\techo $ZERO_OID >.git/HEAD &&\n \t# avoid corrupt/broken HEAD from interfering with repo discovery\n \ttest_must_fail env GIT_DIR=.git git fsck 2>out &&\n \tcat out &&\n@@ -244,10 +245,16 @@ test_expect_success 'tree object with duplicate entries' '\n '\n \n test_expect_success 'unparseable tree object' '\n+\ttest_oid_cache <<-\\EOF &&\n+\tjunk sha1:twenty-bytes-of-junk\n+\tjunk sha256:twenty-bytes-of-junk-twelve-more\n+\tEOF\n+\n \ttest_when_finished \"git update-ref -d refs/heads/wrong\" &&\n \ttest_when_finished \"remove_object \\$tree_sha1\" &&\n \ttest_when_finished \"remove_object \\$commit_sha1\" &&\n-\ttree_sha1=$(printf \"100644 \\0twenty-bytes-of-junk\" | git hash-object -t tree --stdin -w --literally) &&\n+\tjunk=$(test_oid junk) &&\n+\ttree_sha1=$(printf \"100644 \\0$junk\" | git hash-object -t tree --stdin -w --literally) &&\n \tcommit_sha1=$(git commit-tree $tree_sha1) &&\n \tgit update-ref refs/heads/wrong $commit_sha1 &&\n \ttest_must_fail git fsck 2>out &&\n@@ -275,8 +282,9 @@ test_expect_success 'tree entry with type mismatch' '\n '\n \n test_expect_success 'tag pointing to nonexistent' '\n-\tcat >invalid-tag <<-\\EOF &&\n-\tobject ffffffffffffffffffffffffffffffffffffffff\n+\tbadoid=$(test_oid deadbeef) &&\n+\tcat >invalid-tag <<-EOF &&\n+\tobject $badoid\n \ttype commit\n \ttag invalid\n \ttagger T A Gger <tagger@example.com> 1234567890 -0000\n@@ -386,8 +394,8 @@ test_expect_success 'rev-list --verify-objects' '\n \n test_expect_success 'rev-list --verify-objects with bad sha1' '\n \tsha=$(echo blob | git hash-object -w --stdin) &&\n-\told=$(echo $sha | sed \"s+^..+&/+\") &&\n-\tnew=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&\n+\told=$(test_oid_to_path $sha) &&\n+\tnew=$(dirname $old)/$(test_oid ff_2) &&\n \tsha=\"$(dirname $new)$(basename $new)\" &&\n \tmv .git/objects/$old .git/objects/$new &&\n \ttest_when_finished \"remove_object $sha\" &&\n@@ -402,7 +410,7 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '\n \n \ttest_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out &&\n \tcat out &&\n-\ttest_i18ngrep -q \"error: hash mismatch 63ffffffffffffffffffffffffffffffffffffff\" out\n+\ttest_i18ngrep -q \"error: hash mismatch $(dirname $new)$(test_oid ff_2)\" out\n '\n \n test_expect_success 'force fsck to ignore double author' '\n@@ -417,13 +425,12 @@ test_expect_success 'force fsck to ignore double author' '\n '\n \n _bz='\\0'\n-_bz5=\"$_bz$_bz$_bz$_bz$_bz\"\n-_bz20=\"$_bz5$_bz5$_bz5$_bz5\"\n+_bzoid=$(printf $ZERO_OID | sed -e 's/00/\\\\0/g')\n \n test_expect_success 'fsck notices blob entry pointing to null sha1' '\n \t(git init null-blob &&\n \t cd null-blob &&\n-\t sha=$(printf \"100644 file$_bz$_bz20\" |\n+\t sha=$(printf \"100644 file$_bz$_bzoid\" |\n \t       git hash-object -w --stdin -t tree) &&\n \t  git fsck 2>out &&\n \t  cat out &&\n@@ -434,7 +441,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '\n test_expect_success 'fsck notices submodule entry pointing to null sha1' '\n \t(git init null-commit &&\n \t cd null-commit &&\n-\t sha=$(printf \"160000 submodule$_bz$_bz20\" |\n+\t sha=$(printf \"160000 submodule$_bz$_bzoid\" |\n \t       git hash-object -w --stdin -t tree) &&\n \t  git fsck 2>out &&\n \t  cat out &&\n@@ -586,7 +593,7 @@ test_expect_success 'fsck --connectivity-only' '\n \t\t# its type. That lets us see that --connectivity-only is\n \t\t# not actually looking at the contents, but leaves it\n \t\t# free to examine the type if it chooses.\n-\t\tempty=.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 &&\n+\t\tempty=.git/objects/$(test_oid_to_path $EMPTY_BLOB) &&\n \t\tblob=$(echo unrelated | git hash-object -w --stdin) &&\n \t\tmv -f $(sha1_file $blob) $empty &&\n \n@@ -631,10 +638,12 @@ test_expect_success 'fsck --name-objects' '\n \n test_expect_success 'alternate objects are correctly blamed' '\n \ttest_when_finished \"rm -rf alt.git .git/objects/info/alternates\" &&\n+\tname=$(test_oid numeric) &&\n+\tpath=$(test_oid_to_path \"$name\") &&\n \tgit init --bare alt.git &&\n \techo \"../../alt.git/objects\" >.git/objects/info/alternates &&\n-\tmkdir alt.git/objects/12 &&\n-\t>alt.git/objects/12/34567890123456789012345678901234567890 &&\n+\tmkdir alt.git/objects/$(dirname $path) &&\n+\t>alt.git/objects/$(dirname $path)/$(basename $path) &&\n \ttest_must_fail git fsck >out 2>&1 &&\n \ttest_i18ngrep alt.git out\n '\n"},{"id":"377325","messageId":"20190616185330.549436-5-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 04/10] t5000: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:24Z","receivedAt":"2019-06-16T18:53:58Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This test uses a stub of a very large (64 GB) object to test our\ngeneration of tar archives.  In doing so, it uses the object ID of the\nobject so it can insert it into the database properly.  Look up these\nvalues using test_oid.  Restructure the test slightly to use\ntest_oid_in_path.\n\nSince we care about the object, not how it is named in a particular hash\nalgorithm, rename it to \"huge-object\", which is shorter and more\ndescriptive.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t5000-tar-tree.sh                             |  16 +++++++++++-----\n ...5a8938e6999cb59b3ff66739902a => huge-object} | Bin\n 2 files changed, 11 insertions(+), 5 deletions(-)\n rename t/t5000/{19f9c8273ec45a8938e6999cb59b3ff66739902a => huge-object} (100%)\n\ndiff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh\nindex 602bfd9574..37655a237c 100755\n--- a/t/t5000-tar-tree.sh\n+++ b/t/t5000-tar-tree.sh\n@@ -94,6 +94,13 @@ check_tar() {\n \t'\n }\n \n+test_expect_success 'setup' '\n+\ttest_oid_cache <<-EOF\n+\tobj sha1:19f9c8273ec45a8938e6999cb59b3ff66739902a\n+\tobj sha256:3c666f798798601571f5cec0adb57ce4aba8546875e7693177e0535f34d2c49b\n+\tEOF\n+'\n+\n test_expect_success \\\n     'populate workdir' \\\n     'mkdir a &&\n@@ -369,11 +376,10 @@ test_lazy_prereq TAR_HUGE '\n '\n \n test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '\n-\tobj_d=19 &&\n-\tobj_f=f9c8273ec45a8938e6999cb59b3ff66739902a &&\n-\tobj=${obj_d}${obj_f} &&\n-\tmkdir -p .git/objects/$obj_d &&\n-\tcp \"$TEST_DIRECTORY\"/t5000/$obj .git/objects/$obj_d/$obj_f &&\n+\tobj=$(test_oid obj) &&\n+\tpath=$(test_oid_to_path $obj) &&\n+\tmkdir -p .git/objects/$(dirname $path) &&\n+\tcp \"$TEST_DIRECTORY\"/t5000/huge-object .git/objects/$path &&\n \trm -f .git/index &&\n \tgit update-index --add --cacheinfo 100644,$obj,huge &&\n \tgit commit -m huge\ndiff --git a/t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a b/t/t5000/huge-object\nsimilarity index 100%\nrename from t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a\nrename to t/t5000/huge-object\n"},{"id":"377326","messageId":"20190616185330.549436-7-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 06/10] t0027: make hash size independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:26Z","receivedAt":"2019-06-16T18:53:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Several parts of this test generate files that have specific hard-coded\nobject IDs in them.  We don't really care about what the object ID in\nquestion is, so we turn them all to zeros.\n\nHowever, because some of these values are fixed and some are generated,\nthey can be of different lengths, which causes problems when running\nwith SHA-256.  Furthermore, some assertions in this test use only fixed\nobject IDs and some use both fixed and generated ones, so converting\nonly the expected results fixes some tests while breaking others.\nConvert both actual and expected object IDs to the all-zeros object ID\nof the appropriate length to ensure that the test passes when using\nSHA-256.\n\nThe astute observer will notice that both tr and sed are used here.\nConverting the tr call to a sed y/// command looks logical at first, but\nit isn't possible because POSIX doesn't allow escapes in y/// commands\nother than \"\\\\\" and \"\\n\".\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 3587e454f1..959b6da449 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -15,8 +15,10 @@ 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 <\"$3\" >\"$act\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$2\" |\n+\t\tsed -e \"s/0000*/$ZERO_OID/\" >\"$exp\" &&\n+\ttr '\\015\\000abcdef0123456789' QN00000000000000000 <\"$3\" |\n+\t\tsed -e \"s/0000*/$ZERO_OID/\" >\"$act\" &&\n \ttest_cmp \"$exp\" \"$act\" &&\n \trm \"$exp\" \"$act\"\n }\n"},{"id":"377327","messageId":"20190616185330.549436-6-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 05/10] t6030: make test work with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:25Z","receivedAt":"2019-06-16T18:53:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Compute several object ID values instead of hard-coding them, and use\ntest_oid_to_path to cleanly produce a path for an object.\n\nNote that the bisect code which is tested here remains sensitive to the\nhash algorithm in use because it uses the object ID to disambiguate\nbetween two equidistant commits.  Fortunately, SHA-1 and SHA-256\ndisambiguate identically in the cases we care about, so there is no need\nto modify the test to accommodate this situation.  However, if a further\nhash algorithm change occurs, this test may require some restructuring.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t6030-bisect-porcelain.sh | 31 ++++++++++++++++---------------\n 1 file changed, 16 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 49a394bd75..bdc42e9440 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -615,6 +615,7 @@ test_expect_success 'broken branch creation' '\n \tgit add missing/MISSING &&\n \tgit commit -m \"6(broken): Added file that will be deleted\" &&\n \tgit tag BROKEN_HASH6 &&\n+\tdeleted=$(git rev-parse --verify HEAD:missing) &&\n \tadd_line_into_file \"7(broken): second line on a broken branch\" hello2 &&\n \tgit tag BROKEN_HASH7 &&\n \tadd_line_into_file \"8(broken): third line on a broken branch\" hello2 &&\n@@ -622,12 +623,12 @@ test_expect_success 'broken branch creation' '\n \tgit rm missing/MISSING &&\n \tgit commit -m \"9(broken): Remove missing file\" &&\n \tgit tag BROKEN_HASH9 &&\n-\trm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d\n+\trm .git/objects/$(test_oid_to_path $deleted)\n '\n \n echo \"\" > expected.ok\n cat > expected.missing-tree.default <<EOF\n-fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d\n+fatal: unable to read tree $deleted\n EOF\n \n test_expect_success 'bisect fails if tree is broken on start commit' '\n@@ -713,12 +714,12 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' \"\n \"\n \n cat > expected.bisect-log <<EOF\n-# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.\n-# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.\n-git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'\n-# good: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.\n-git bisect good 3de952f2416b6084f557ec417709eac740c6818c\n-# first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.\n+# bad: [$HASH4] Add <4: Ciao for now> into <hello>.\n+# good: [$HASH2] Add <2: A new day for git> into <hello>.\n+git bisect start '$HASH4' '$HASH2'\n+# good: [$HASH3] Add <3: Another new day for git> into <hello>.\n+git bisect good $HASH3\n+# first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.\n EOF\n \n test_expect_success 'bisect log: successful result' '\n@@ -731,14 +732,14 @@ test_expect_success 'bisect log: successful result' '\n '\n \n cat > expected.bisect-skip-log <<EOF\n-# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.\n-# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.\n-git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'\n-# skip: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.\n-git bisect skip 3de952f2416b6084f557ec417709eac740c6818c\n+# bad: [$HASH4] Add <4: Ciao for now> into <hello>.\n+# good: [$HASH2] Add <2: A new day for git> into <hello>.\n+git bisect start '$HASH4' '$HASH2'\n+# skip: [$HASH3] Add <3: Another new day for git> into <hello>.\n+git bisect skip $HASH3\n # only skipped commits left to test\n-# possible first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.\n-# possible first bad commit: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.\n+# possible first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.\n+# possible first bad commit: [$HASH3] Add <3: Another new day for git> into <hello>.\n EOF\n \n test_expect_success 'bisect log: only skip commits left' '\n"},{"id":"377328","messageId":"20190616185330.549436-8-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 07/10] t0090: make test pass with SHA-256","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:27Z","receivedAt":"2019-06-16T18:54:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"One assertion of this test checks for a shrinking cache tree.  The\ninitial index contains a cache tree with two directory names but no\nobject ID, and the second index contains a cache tree with an object ID\nbut no directory name.\n\nWith SHA-1, the second index is smaller than the first, because the\ndirectory information stored takes more than the 20 bytes of an SHA-1\nhash, but with SHA-256, the hash is longer, and the test fails the\nassertion that the second index is smaller than the first.\n\nTo address this issue, increase the length of the subdirectory name to\nensure that the cache tree does indeed shrink in size regardless of the\nalgorithm in use.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t0090-cache-tree.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh\nindex 504334e552..ce9a4a5f32 100755\n--- a/t/t0090-cache-tree.sh\n+++ b/t/t0090-cache-tree.sh\n@@ -162,8 +162,8 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi\n '\n \n test_expect_success PERL 'commit -p with shrinking cache-tree' '\n-\tmkdir -p deep/subdir &&\n-\techo content >deep/subdir/file &&\n+\tmkdir -p deep/very-long-subdir &&\n+\techo content >deep/very-long-subdir/file &&\n \tgit add deep &&\n \tgit commit -m add &&\n \tgit rm -r deep &&\n"},{"id":"377329","messageId":"20190616185330.549436-9-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 08/10] t1007: remove SHA1 prerequisites","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:28Z","receivedAt":"2019-06-16T18:54:03Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Update this test to use test_oid_cache to specify the object IDs for\nboth SHA-1 and SHA-256.  Since this test now works with both algorithms,\nremove the SHA1 prerequisite.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1007-hash-object.sh | 58 +++++++++++++++++++++++-------------------\n 1 file changed, 32 insertions(+), 26 deletions(-)\n\ndiff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh\nindex 7099d33508..64b340f227 100755\n--- a/t/t1007-hash-object.sh\n+++ b/t/t1007-hash-object.sh\n@@ -9,22 +9,19 @@ echo_without_newline() {\n }\n \n test_blob_does_not_exist() {\n-\ttest_expect_success SHA1 'blob does not exist in database' \"\n+\ttest_expect_success 'blob does not exist in database' \"\n \t\ttest_must_fail git cat-file blob $1\n \t\"\n }\n \n test_blob_exists() {\n-\ttest_expect_success SHA1 'blob exists in database' \"\n+\ttest_expect_success 'blob exists in database' \"\n \t\tgit cat-file blob $1\n \t\"\n }\n \n hello_content=\"Hello World\"\n-hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689\n-\n example_content=\"This is an example\"\n-example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399\n \n setup_repo() {\n \techo_without_newline \"$hello_content\" > hello\n@@ -44,7 +41,16 @@ pop_repo() {\n \trm -rf $test_repo\n }\n \n-setup_repo\n+test_expect_success 'setup' '\n+\tsetup_repo &&\n+\ttest_oid_cache <<-EOF\n+\thello sha1:5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689\n+\thello sha256:1e3b6c04d2eeb2b3e45c8a330445404c0b7cc7b257e2b097167d26f5230090c4\n+\n+\texample sha1:ddd3f836d3e3fbb7ae289aa9ae83536f76956399\n+\texample sha256:b44fe1fe65589848253737db859bd490453510719d7424daab03daf0767b85ae\n+\tEOF\n+'\n \n # Argument checking\n \n@@ -73,23 +79,23 @@ test_expect_success \"Can't use --path with --no-filters\" '\n \n push_repo\n \n-test_expect_success SHA1 'hash a file' '\n-\ttest $hello_sha1 = $(git hash-object hello)\n+test_expect_success 'hash a file' '\n+\ttest \"$(test_oid hello)\" = $(git hash-object hello)\n '\n \n-test_blob_does_not_exist $hello_sha1\n+test_blob_does_not_exist \"$(test_oid hello)\"\n \n-test_expect_success SHA1 'hash from stdin' '\n-\ttest $example_sha1 = $(git hash-object --stdin < example)\n+test_expect_success 'hash from stdin' '\n+\ttest \"$(test_oid example)\" = $(git hash-object --stdin < example)\n '\n \n-test_blob_does_not_exist $example_sha1\n+test_blob_does_not_exist \"$(test_oid example)\"\n \n-test_expect_success SHA1 'hash a file and write to database' '\n-\ttest $hello_sha1 = $(git hash-object -w hello)\n+test_expect_success 'hash a file and write to database' '\n+\ttest \"$(test_oid hello)\" = $(git hash-object -w hello)\n '\n \n-test_blob_exists $hello_sha1\n+test_blob_exists \"$(test_oid hello)\"\n \n test_expect_success 'git hash-object --stdin file1 <file0 first operates on file0, then file1' '\n \techo foo > file1 &&\n@@ -161,11 +167,11 @@ pop_repo\n for args in \"-w --stdin\" \"--stdin -w\"; do\n \tpush_repo\n \n-\ttest_expect_success SHA1 \"hash from stdin and write to database ($args)\" '\n-\t\ttest $example_sha1 = $(git hash-object $args < example)\n+\ttest_expect_success \"hash from stdin and write to database ($args)\" '\n+\t\ttest \"$(test_oid example)\" = $(git hash-object $args < example)\n \t'\n \n-\ttest_blob_exists $example_sha1\n+\ttest_blob_exists \"$(test_oid example)\"\n \n \tpop_repo\n done\n@@ -173,22 +179,22 @@ done\n filenames=\"hello\n example\"\n \n-sha1s=\"$hello_sha1\n-$example_sha1\"\n+oids=\"$(test_oid hello)\n+$(test_oid example)\"\n \n-test_expect_success SHA1 \"hash two files with names on stdin\" '\n-\ttest \"$sha1s\" = \"$(echo_without_newline \"$filenames\" | git hash-object --stdin-paths)\"\n+test_expect_success \"hash two files with names on stdin\" '\n+\ttest \"$oids\" = \"$(echo_without_newline \"$filenames\" | git hash-object --stdin-paths)\"\n '\n \n for args in \"-w --stdin-paths\" \"--stdin-paths -w\"; do\n \tpush_repo\n \n-\ttest_expect_success SHA1 \"hash two files with names on stdin and write to database ($args)\" '\n-\t\ttest \"$sha1s\" = \"$(echo_without_newline \"$filenames\" | git hash-object $args)\"\n+\ttest_expect_success \"hash two files with names on stdin and write to database ($args)\" '\n+\t\ttest \"$oids\" = \"$(echo_without_newline \"$filenames\" | git hash-object $args)\"\n \t'\n \n-\ttest_blob_exists $hello_sha1\n-\ttest_blob_exists $example_sha1\n+\ttest_blob_exists \"$(test_oid hello)\"\n+\ttest_blob_exists \"$(test_oid example)\"\n \n \tpop_repo\n done\n"},{"id":"377330","messageId":"20190616185330.549436-10-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 09/10] t1710: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:29Z","receivedAt":"2019-06-16T18:54:05Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This test uses several index hashes, which necessarily depend on the\nversion of the index and the hash algorithm in use.  Use test_oid_cache\nto provide values for these for both SHA-1 and SHA-256.  Also, compute\nan object ID and use $EMPTY_BLOB to make the remainder of the tests\nindependent of the hash algorithm in use.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t1700-split-index.sh | 51 ++++++++++++++++++++++++++++--------------\n 1 file changed, 34 insertions(+), 17 deletions(-)\n\ndiff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh\nindex 4f2f84f309..12a5568844 100755\n--- a/t/t1700-split-index.sh\n+++ b/t/t1700-split-index.sh\n@@ -20,6 +20,22 @@ create_non_racy_file () {\n \ttest-tool chmtime =-5 \"$1\"\n }\n \n+test_expect_success 'setup' '\n+\ttest_oid_cache <<-EOF\n+\town_v3 sha1:8299b0bcd1ac364e5f1d7768efb62fa2da79a339\n+\town_v3 sha256:38a6d2925e3eceec33ad7b34cbff4e0086caa0daf28f31e51f5bd94b4a7af86b\n+\n+\tbase_v3 sha1:39d890139ee5356c7ef572216cebcd27aa41f9df\n+\tbase_v3 sha256:c9baeadf905112bf6c17aefbd7d02267afd70ded613c30cafed2d40cb506e1ed\n+\n+\town_v4 sha1:432ef4b63f32193984f339431fd50ca796493569\n+\town_v4 sha256:6738ac6319c25b694afa7bcc313deb182d1a59b68bf7a47b4296de83478c0420\n+\n+\tbase_v4 sha1:508851a7f0dfa8691e9f69c7f055865389012491\n+\tbase_v4 sha256:3177d4adfdd4b6904f7e921d91d715a471c0dde7cf6a4bba574927f02b699508\n+\tEOF\n+'\n+\n test_expect_success 'enable split index' '\n \tgit config splitIndex.maxPercentChange 100 &&\n \tgit update-index --split-index &&\n@@ -29,11 +45,11 @@ test_expect_success 'enable split index' '\n \t# NEEDSWORK: Stop hard-coding checksums.\n \tif test \"$indexversion\" = \"4\"\n \tthen\n-\t\town=432ef4b63f32193984f339431fd50ca796493569\n-\t\tbase=508851a7f0dfa8691e9f69c7f055865389012491\n+\t\town=$(test_oid own_v4)\n+\t\tbase=$(test_oid base_v4)\n \telse\n-\t\town=8299b0bcd1ac364e5f1d7768efb62fa2da79a339\n-\t\tbase=39d890139ee5356c7ef572216cebcd27aa41f9df\n+\t\town=$(test_oid own_v3)\n+\t\tbase=$(test_oid base_v3)\n \tfi &&\n \n \tcat >expect <<-EOF &&\n@@ -99,17 +115,18 @@ test_expect_success 'enable split index again, \"one\" now belongs to base index\"'\n \n test_expect_success 'modify original file, base index untouched' '\n \techo modified | create_non_racy_file one &&\n+\tfile1_blob=$(git hash-object one) &&\n \tgit update-index one &&\n \tgit ls-files --stage >ls-files.actual &&\n \tcat >ls-files.expect <<-EOF &&\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0\tone\n+\t100644 $file1_blob 0\tone\n \tEOF\n \ttest_cmp ls-files.expect ls-files.actual &&\n \n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n \tq_to_tab >expect <<-EOF &&\n \t$BASE\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q\n+\t100644 $file1_blob 0Q\n \treplacements: 0\n \tdeletions:\n \tEOF\n@@ -121,7 +138,7 @@ test_expect_success 'add another file, which stays index' '\n \tgit update-index --add two &&\n \tgit ls-files --stage >ls-files.actual &&\n \tcat >ls-files.expect <<-EOF &&\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0\tone\n+\t100644 $file1_blob 0\tone\n \t100644 $EMPTY_BLOB 0\ttwo\n \tEOF\n \ttest_cmp ls-files.expect ls-files.actual &&\n@@ -129,7 +146,7 @@ test_expect_success 'add another file, which stays index' '\n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n \tq_to_tab >expect <<-EOF &&\n \t$BASE\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q\n+\t100644 $file1_blob 0Q\n \t100644 $EMPTY_BLOB 0\ttwo\n \treplacements: 0\n \tdeletions:\n@@ -141,14 +158,14 @@ test_expect_success 'remove file not in base index' '\n \tgit update-index --force-remove two &&\n \tgit ls-files --stage >ls-files.actual &&\n \tcat >ls-files.expect <<-EOF &&\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0\tone\n+\t100644 $file1_blob 0\tone\n \tEOF\n \ttest_cmp ls-files.expect ls-files.actual &&\n \n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n \tq_to_tab >expect <<-EOF &&\n \t$BASE\n-\t100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q\n+\t100644 $file1_blob 0Q\n \treplacements: 0\n \tdeletions:\n \tEOF\n@@ -237,9 +254,9 @@ test_expect_success 'set core.splitIndex config variable to true' '\n \tgit update-index --add three &&\n \tgit ls-files --stage >ls-files.actual &&\n \tcat >ls-files.expect <<-EOF &&\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\tone\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\tthree\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\ttwo\n+\t100644 $EMPTY_BLOB 0\tone\n+\t100644 $EMPTY_BLOB 0\tthree\n+\t100644 $EMPTY_BLOB 0\ttwo\n \tEOF\n \ttest_cmp ls-files.expect ls-files.actual &&\n \tBASE=$(test-tool dump-split-index .git/index | grep \"^base\") &&\n@@ -257,8 +274,8 @@ test_expect_success 'set core.splitIndex config variable to false' '\n \tgit update-index --force-remove three &&\n \tgit ls-files --stage >ls-files.actual &&\n \tcat >ls-files.expect <<-EOF &&\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\tone\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\ttwo\n+\t100644 $EMPTY_BLOB 0\tone\n+\t100644 $EMPTY_BLOB 0\ttwo\n \tEOF\n \ttest_cmp ls-files.expect ls-files.actual &&\n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n@@ -285,7 +302,7 @@ test_expect_success 'set core.splitIndex config variable back to true' '\n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n \tcat >expect <<-EOF &&\n \t$BASE\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\tfour\n+\t100644 $EMPTY_BLOB 0\tfour\n \treplacements:\n \tdeletions:\n \tEOF\n@@ -309,7 +326,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '\n \ttest-tool dump-split-index .git/index | sed \"/^own/d\" >actual &&\n \tcat >expect <<-EOF &&\n \t$BASE\n-\t100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0\tsix\n+\t100644 $EMPTY_BLOB 0\tsix\n \treplacements:\n \tdeletions:\n \tEOF\n"},{"id":"377331","messageId":"20190616185330.549436-11-sandals@crustytoothpaste.net","threadId":"51327","inReplyTo":"20190616185330.549436-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 10/10] t2203: avoid hard-coded object ID values","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-16T18:53:30Z","receivedAt":"2019-06-16T18:54:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"In order to make this test work with multiple hash algorithms, compute\nthe object ID used in this test instead of hard-coding it.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n t/t2203-add-intent.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh\nindex 68e54d5c44..5bbe8dcce4 100755\n--- a/t/t2203-add-intent.sh\n+++ b/t/t2203-add-intent.sh\n@@ -247,12 +247,14 @@ test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '\n test_expect_success '\"diff HEAD\" includes ita as new files' '\n \tgit reset --hard &&\n \techo new >new-ita &&\n+\toid=$(git hash-object new-ita) &&\n+\toid=$(git rev-parse --short $oid) &&\n \tgit add -N new-ita &&\n \tgit diff HEAD >actual &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \tdiff --git a/new-ita b/new-ita\n \tnew file mode 100644\n-\tindex 0000000..3e75765\n+\tindex 0000000..$oid\n \t--- /dev/null\n \t+++ b/new-ita\n \t@@ -0,0 +1 @@\n"},{"id":"377367","messageId":"nycvar.QRO.7.76.6.1906172102180.44@tvgsbejvaqbjf.bet","threadId":"51327","inReplyTo":"20190616185330.549436-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-17T19:05:03Z","receivedAt":"2019-06-17T19:05:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi brian,\n\nOn Sun, 16 Jun 2019, brian m. carlson wrote:\n\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 8270de74be..11a6abca2e 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -1314,6 +1314,12 @@ test_oid () {\n>  \teval \"printf '%s' \\\"\\${$var}\\\"\"\n>  }\n>\n> +# Insert a slash into an object ID so it can be used to reference a location\n> +# under \".git/objects\".  For example, \"deadbeef...\" becomes \"de/adbeef..\".\n> +test_oid_to_path () {\n> +\techo \"$1\" | sed -e 's!^..!&/!'\n> +}\n\nI guess it does not *really* matter all that much, but this does spawn a\nnew process (and I think it actually spawns 4 on Windows, for reasons, and\nspawning processes is super expensive on Windows).\n\nWe might actually want to think about using something like this instead\n(which admittedly looks a bit like gobbledygook to the uninitiated, but it\ndefinitely avoids any spawned process):\n\ntest_oid_to_path () {\n\techo \"${1%${1#??}}/${1#??}\"\n}\n\nCiao,\nDscho\n"},{"id":"377381","messageId":"20190618012943.GB8877@genre.crustytoothpaste.net","threadId":"51327","inReplyTo":"nycvar.QRO.7.76.6.1906172102180.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-18T01:29:44Z","receivedAt":"2019-06-18T01:29:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-06-17 at 19:05:03, Johannes Schindelin wrote:\n> I guess it does not *really* matter all that much, but this does spawn a\n> new process (and I think it actually spawns 4 on Windows, for reasons, and\n> spawning processes is super expensive on Windows).\n> \n> We might actually want to think about using something like this instead\n> (which admittedly looks a bit like gobbledygook to the uninitiated, but it\n> definitely avoids any spawned process):\n> \n> test_oid_to_path () {\n> \techo \"${1%${1#??}}/${1#??}\"\n> }\n\nI'm fine making that change. The original design was because we had\nother code that used that technique and I didn't see an obviously better\nsolution. Now you've provided one and a good justification.\n\nI think the complexity isn't too terrible since it's a one-line function\nand the comment adequately explains the behavior so people don't have to\nparse it to understand it.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"377386","messageId":"c9be7464-21f3-6651-500d-14137f0f1c0f@kdbg.org","threadId":"51327","inReplyTo":"20190618012943.GB8877@genre.crustytoothpaste.net","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-06-18T06:14:03Z","receivedAt":"2019-06-18T06:58:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 18.06.19 um 03:29 schrieb brian m. carlson:\n> On 2019-06-17 at 19:05:03, Johannes Schindelin wrote:\n>> I guess it does not *really* matter all that much, but this does spawn a\n>> new process (and I think it actually spawns 4 on Windows, for reasons, and\n>> spawning processes is super expensive on Windows).\n>>\n>> We might actually want to think about using something like this instead\n>> (which admittedly looks a bit like gobbledygook to the uninitiated, but it\n>> definitely avoids any spawned process):\n>>\n>> test_oid_to_path () {\n>> \techo \"${1%${1#??}}/${1#??}\"\n>> }\n> \n> I'm fine making that change. The original design was because we had\n> other code that used that technique and I didn't see an obviously better\n> solution. Now you've provided one and a good justification.\n\nRegardless of how it is implemented, I have another gripe with this\nhelper: the way it must be used requires a process: $(test_out_to_path $foo)\n\nAnd looking through this patch series, I see a gazillion of *new*\nprocess substitutions $(test_something...) and $(basename $whatever).\nCan't we do something about it?\n\n-- Hannes\n"},{"id":"377415","messageId":"nycvar.QRO.7.76.6.1906181647480.44@tvgsbejvaqbjf.bet","threadId":"51327","inReplyTo":"c9be7464-21f3-6651-500d-14137f0f1c0f@kdbg.org","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-18T16:15:46Z","receivedAt":"2019-06-18T16:15:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Tue, 18 Jun 2019, Johannes Sixt wrote:\n\n> Am 18.06.19 um 03:29 schrieb brian m. carlson:\n> > On 2019-06-17 at 19:05:03, Johannes Schindelin wrote:\n> >> I guess it does not *really* matter all that much, but this does spawn a\n> >> new process (and I think it actually spawns 4 on Windows, for reasons, and\n> >> spawning processes is super expensive on Windows).\n> >>\n> >> We might actually want to think about using something like this instead\n> >> (which admittedly looks a bit like gobbledygook to the uninitiated, but it\n> >> definitely avoids any spawned process):\n> >>\n> >> test_oid_to_path () {\n> >> \techo \"${1%${1#??}}/${1#??}\"\n> >> }\n> >\n> > I'm fine making that change. The original design was because we had\n> > other code that used that technique and I didn't see an obviously better\n> > solution. Now you've provided one and a good justification.\n>\n> Regardless of how it is implemented, I have another gripe with this\n> helper: the way it must be used requires a process: $(test_out_to_path\n> $foo)\n\nIndeed.\n\n> And looking through this patch series, I see a gazillion of *new*\n> process substitutions $(test_something...) and $(basename $whatever).\n> Can't we do something about it?\n\nI wish there was. Unix shell scripting has not evolved much in the past,\nwhat, 3 decades? So I don't really see a way to \"pass variables by\nreference\" to shell functions, short of calling `eval` (which buys\npreciously little as it _also_ has to spawn a new process [*1*]).\n\nOf course, if we would slowly get away from depending so much on shell\nscripting, then we would reap quite a few other benefits, too, not only\nspeed, but also much easier debugging, code coverage, etc.\n\nCiao,\nDscho\n\nFootnote *1*: Theoretically, it could be a *ton* faster by using threads\non Windows. But threads are pretty much an afterthought on Unix/Linux, so\nno mainstream POSIX shell supports this. They all `fork()` to interpret an\n`eval` as far as I can tell.\n"},{"id":"377418","messageId":"20190618165525.GN31952@szeder.dev","threadId":"51327","inReplyTo":"nycvar.QRO.7.76.6.1906181647480.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-06-18T16:55:25Z","receivedAt":"2019-06-18T16:55:31Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Jun 18, 2019 at 06:15:46PM +0200, Johannes Schindelin wrote:\n> > Regardless of how it is implemented, I have another gripe with this\n> > helper: the way it must be used requires a process: $(test_out_to_path\n> > $foo)\n> \n> Indeed.\n> \n> > And looking through this patch series, I see a gazillion of *new*\n> > process substitutions $(test_something...) and $(basename $whatever).\n> > Can't we do something about it?\n> \n> I wish there was. Unix shell scripting has not evolved much in the past,\n> what, 3 decades? So I don't really see a way to \"pass variables by\n> reference\" to shell functions, short of calling `eval` (which buys\n> preciously little as it _also_ has to spawn a new process [*1*]).\n\n> Footnote *1*: Theoretically, it could be a *ton* faster by using threads\n> on Windows. But threads are pretty much an afterthought on Unix/Linux, so\n> no mainstream POSIX shell supports this. They all `fork()` to interpret an\n> `eval` as far as I can tell.\n\n'eval' doesn't fork().  It can't possibly fork(), because if it did,\nthen any variables set in the eval-ed code snippet couldn't be visible\noutside the 'eval'.\n\n"},{"id":"377420","messageId":"20190618170416.GA14636@sigill.intra.peff.net","threadId":"51327","inReplyTo":"nycvar.QRO.7.76.6.1906181647480.44@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-06-18T17:04:16Z","receivedAt":"2019-06-18T17:04:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 18, 2019 at 06:15:46PM +0200, Johannes Schindelin wrote:\n\n> > And looking through this patch series, I see a gazillion of *new*\n> > process substitutions $(test_something...) and $(basename $whatever).\n> > Can't we do something about it?\n> \n> I wish there was. Unix shell scripting has not evolved much in the past,\n> what, 3 decades? So I don't really see a way to \"pass variables by\n> reference\" to shell functions, short of calling `eval` (which buys\n> preciously little as it _also_ has to spawn a new process [*1*]).\n\nReally? An eval can impact the caller's state, so it _can't_ happen in a\nsub-process in most cases.\n\nE.g., if I run this:\n\n-- >8 --\n#!/bin/sh\n\n# usage: test_oid_to_path <var> <oid>\n# to set the variable <var> in the caller's environment to the path of <oid>\ntest_oid_to_path() {\n\tpath=\"${2%${2#??}}/${2#??}\"\n\teval \"$1=\\$path\"\n}\n\ntest_oid_to_path foo 1234abcd\necho foo: $foo\n-- >8 --\n\nit all happens in a single process, under both bash and dash.\n\n-Peff\n"},{"id":"377464","messageId":"20190618230334.GC8877@genre.crustytoothpaste.net","threadId":"51327","inReplyTo":"c9be7464-21f3-6651-500d-14137f0f1c0f@kdbg.org","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-18T23:03:34Z","receivedAt":"2019-06-18T23:03:44Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-06-18 at 06:14:03, Johannes Sixt wrote:\n> Am 18.06.19 um 03:29 schrieb brian m. carlson:\n> > On 2019-06-17 at 19:05:03, Johannes Schindelin wrote:\n> > I'm fine making that change. The original design was because we had\n> > other code that used that technique and I didn't see an obviously better\n> > solution. Now you've provided one and a good justification.\n> \n> Regardless of how it is implemented, I have another gripe with this\n> helper: the way it must be used requires a process: $(test_out_to_path $foo)\n> \n> And looking through this patch series, I see a gazillion of *new*\n> process substitutions $(test_something...) and $(basename $whatever).\n> Can't we do something about it?\n\nA command substitution need not invoke another process. In fact, all of\nthe test_oid calls operate only within the shell. The test_oid_cache and\ntest_oid_init calls require spawning only expr, and they are typically\nlimited to one or two per test.\n\nWithin reason, I'm happy to try to make things easier for Windows folks\nif I can, but it's still the case that process creation is more\nexpensive on Windows and shell scripting is designed around process\ncreation. My hope is that Microsoft's work on WSL will help them improve\ntheir Win32 process creation time so it's faster and this becomes less\nof an issue.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"377554","messageId":"nycvar.QRO.7.76.6.1906192119380.44@tvgsbejvaqbjf.bet","threadId":"51327","inReplyTo":"20190618170416.GA14636@sigill.intra.peff.net","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T19:55:38Z","receivedAt":"2019-06-19T19:55:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Peff,\n\nOn Tue, 18 Jun 2019, Jeff King wrote:\n\n> On Tue, Jun 18, 2019 at 06:15:46PM +0200, Johannes Schindelin wrote:\n>\n> > > And looking through this patch series, I see a gazillion of *new*\n> > > process substitutions $(test_something...) and $(basename $whatever).\n> > > Can't we do something about it?\n> >\n> > I wish there was. Unix shell scripting has not evolved much in the past,\n> > what, 3 decades? So I don't really see a way to \"pass variables by\n> > reference\" to shell functions, short of calling `eval` (which buys\n> > preciously little as it _also_ has to spawn a new process [*1*]).\n>\n> Really? An eval can impact the caller's state, so it _can't_ happen in a\n> sub-process in most cases.\n>\n> E.g., if I run this:\n>\n> -- >8 --\n> #!/bin/sh\n>\n> # usage: test_oid_to_path <var> <oid>\n> # to set the variable <var> in the caller's environment to the path of <oid>\n> test_oid_to_path() {\n> \tpath=\"${2%${2#??}}/${2#??}\"\n> \teval \"$1=\\$path\"\n> }\n>\n> test_oid_to_path foo 1234abcd\n> echo foo: $foo\n> -- >8 --\n>\n> it all happens in a single process, under both bash and dash.\n\nOops. I think I may have read too much into the name `eval.c` in Dash's\nsource code, I assumed that it was all about the `eval` command. But now\nthat I look at this again, I see:\n\n/*\n * Execute a command inside back quotes.  If it's a builtin command, we\n * want to save its output in a block obtained from malloc.  Otherwise\n * we fork off a subprocess and get the output of the command via a pipe.\n * Should be called with interrupts off.\n */\n\nvoid\nevalbackcmd(union node *n, struct backcmd *result)\n{\n\t[...]\n\nI saw this at\nhttps://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/eval.c#n608\n\nSo this is actually about `$(...)` (or the old, non-nestable backtick\nversion of it) and not about `eval`.\n\nAnd of course I was also making another incorrect connection to the Perl\ncommand `eval` which allows you to catch code that `die()`s (which *must*\nrun in a subprocess).\n\nSo yeah, I guess `eval` would work here to avoid the `$(...)` constructs.\n\nSorry for the noise,\nDscho\n"},{"id":"377555","messageId":"nycvar.QRO.7.76.6.1906192155560.44@tvgsbejvaqbjf.bet","threadId":"51327","inReplyTo":"20190618165525.GN31952@szeder.dev","subject":"Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-06-19T19:56:41Z","receivedAt":"2019-06-19T19:56:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Jun 2019, SZEDER Gábor wrote:\n\n> On Tue, Jun 18, 2019 at 06:15:46PM +0200, Johannes Schindelin wrote:\n> > > Regardless of how it is implemented, I have another gripe with this\n> > > helper: the way it must be used requires a process: $(test_out_to_path\n> > > $foo)\n> >\n> > Indeed.\n> >\n> > > And looking through this patch series, I see a gazillion of *new*\n> > > process substitutions $(test_something...) and $(basename $whatever).\n> > > Can't we do something about it?\n> >\n> > I wish there was. Unix shell scripting has not evolved much in the past,\n> > what, 3 decades? So I don't really see a way to \"pass variables by\n> > reference\" to shell functions, short of calling `eval` (which buys\n> > preciously little as it _also_ has to spawn a new process [*1*]).\n>\n> > Footnote *1*: Theoretically, it could be a *ton* faster by using threads\n> > on Windows. But threads are pretty much an afterthought on Unix/Linux, so\n> > no mainstream POSIX shell supports this. They all `fork()` to interpret an\n> > `eval` as far as I can tell.\n>\n> 'eval' doesn't fork().  It can't possibly fork(), because if it did,\n> then any variables set in the eval-ed code snippet couldn't be visible\n> outside the 'eval'.\n\nGood point. My brain must have made a couple of incorrect associations\nthere.\n\nSorry,\nDscho\n"}]}