git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 00/28] Hash-independent tests (part 2)
@ 2018-05-13  2:24 brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
                   ` (27 more replies)
  0 siblings, 28 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

This is part 2 in the series to make tests hash independent.

This series introduces an SHA1 prerequisite which checks if the hash in
use is SHA-1, and can be used to skip the test if it is not.
Additionally, because NewHash will be 256-bit, I introduced aliases for
the test constants $_x40 and $_z40 which will be less confusing when the
hash isn't 40 hex characters long.  I opted to leave the old names in
place for the moment to prevent any potential conflicts with other
series and will clean up any stragglers later.

To address any concerns that might be present, I do plan to retrofit
tests marked with the SHA1 prerequisite and ensure that they are passing
or are not applicable (e.g. for pack formats supporting only SHA-1).  I
agree with concerns that shipping a NewHash-capable Git without a
complete, functional testsuite would be a bad idea.

Changes from v1:
* Amend commit message to indicate that we *will* be updating tests
  annotated with the SHA1 prerequisite to work with NewHash.
* Rename FULL_HEX to OID_REGEX.
* Regenerate patch for OID_REGEX.
* Update variable name from "link_oid" to "slink_id" for consistency
  while still preserving alignment.
* Restore blank line between tests.

tbdiff output below.

brian m. carlson (28):
  t/test-lib: add an SHA1 prerequisite
  t/test-lib: introduce ZERO_OID
  t: switch $_z40 to $ZERO_OID
  t/test-lib: introduce OID_REGEX
  t: switch $_x40 to $OID_REGEX
  t0000: annotate with SHA1 prerequisite
  t1007: annotate with SHA1 prerequisite
  t1512: skip test if not using SHA-1
  t4044: skip test if not using SHA-1
  t: skip pack tests if not using SHA-1
  t2203: abstract away SHA-1-specific constants
  t3103: abstract away SHA-1-specific constants
  t3702: abstract away SHA-1-specific constants
  t3905: abstract away SHA-1-specific constants
  t4007: abstract away SHA-1-specific constants
  t4008: abstract away SHA-1-specific constants
  t4014: abstract away SHA-1-specific constants
  t4020: abstract away SHA-1-specific constants
  t4022: abstract away SHA-1-specific constants
  t4029: fix test indentation
  t4029: abstract away SHA-1-specific constants
  t4030: abstract away SHA-1-specific constants
  t/lib-diff-alternative: abstract away SHA-1-specific constants
  t4205: sort log output in a hash-independent way
  t4042: abstract away SHA-1-specific constants
  t4045: abstract away SHA-1-specific constants
  t4208: abstract away SHA-1-specific constants
  t5300: abstract away SHA-1-specific constants

 t/diff-lib.sh                       |  4 +-
 t/lib-diff-alternative.sh           | 12 ++++--
 t/t0000-basic.sh                    | 24 ++++++------
 t/t0090-cache-tree.sh               |  2 +-
 t/t1000-read-tree-m-3way.sh         |  2 +-
 t/t1001-read-tree-m-2way.sh         |  2 +-
 t/t1002-read-tree-m-u-2way.sh       |  2 +-
 t/t1006-cat-file.sh                 |  8 ++--
 t/t1007-hash-object.sh              | 16 ++++----
 t/t1012-read-tree-df.sh             |  2 +-
 t/t1400-update-ref.sh               |  2 +-
 t/t1407-worktree-ref-store.sh       |  8 ++--
 t/t1450-fsck.sh                     |  4 +-
 t/t1501-work-tree.sh                |  6 +--
 t/t1512-rev-parse-disambiguation.sh |  6 +++
 t/t1601-index-bogus.sh              |  2 +-
 t/t1700-split-index.sh              |  2 +-
 t/t2011-checkout-invalid-head.sh    |  2 +-
 t/t2025-worktree-add.sh             |  8 ++--
 t/t2027-worktree-list.sh            |  2 +-
 t/t2107-update-index-basic.sh       |  4 +-
 t/t2201-add-update-typechange.sh    | 16 ++++----
 t/t2203-add-intent.sh               | 14 +++----
 t/t3100-ls-tree-restrict.sh         |  2 +-
 t/t3101-ls-tree-dirname.sh          |  2 +-
 t/t3103-ls-tree-misc.sh             |  3 +-
 t/t3200-branch.sh                   |  4 +-
 t/t3510-cherry-pick-sequence.sh     |  8 ++--
 t/t3702-add-edit.sh                 |  7 ++--
 t/t3905-stash-include-untracked.sh  | 11 ++++--
 t/t4002-diff-basic.sh               |  2 +-
 t/t4006-diff-mode.sh                |  2 +-
 t/t4007-rename-3.sh                 | 17 +++++----
 t/t4008-diff-break-rewrite.sh       | 59 ++++++++++++++++-------------
 t/t4014-format-patch.sh             | 11 +++---
 t/t4020-diff-external.sh            | 18 +++++----
 t/t4022-diff-rewrite.sh             |  5 ++-
 t/t4027-diff-submodule.sh           |  6 +--
 t/t4029-diff-trailing-space.sh      | 38 ++++++++++---------
 t/t4030-diff-textconv.sh            |  5 ++-
 t/t4042-diff-textconv-caching.sh    | 16 +++++---
 t/t4044-diff-index-unique-abbrev.sh |  6 +++
 t/t4045-diff-relative.sh            |  6 ++-
 t/t4046-diff-unmerged.sh            | 14 +++----
 t/t4054-diff-bogus-tree.sh          | 12 +++---
 t/t4058-diff-duplicates.sh          | 12 +++---
 t/t4150-am.sh                       |  4 +-
 t/t4200-rerere.sh                   |  2 +-
 t/t4201-shortlog.sh                 |  2 +-
 t/t4205-log-pretty-formats.sh       |  8 ++--
 t/t4208-log-magic-pathspec.sh       |  3 +-
 t/t5150-request-pull.sh             |  2 +-
 t/t5300-pack-object.sh              |  8 ++--
 t/t5308-pack-detect-duplicates.sh   |  6 +++
 t/t5309-pack-delta-cycles.sh        |  6 +++
 t/t5516-fetch-push.sh               | 22 +++++------
 t/t5527-fetch-odd-refs.sh           |  2 +-
 t/t5571-pre-push-hook.sh            |  8 ++--
 t/t6006-rev-list-format.sh          |  4 +-
 t/t6012-rev-list-simplify.sh        |  2 +-
 t/t6111-rev-list-treesame.sh        |  2 +-
 t/t6120-describe.sh                 |  2 +-
 t/t6300-for-each-ref.sh             |  2 +-
 t/t6301-for-each-ref-errors.sh      |  2 +-
 t/t7009-filter-branch-null-sha1.sh  |  2 +-
 t/t7011-skip-worktree-reading.sh    |  2 +-
 t/t7064-wtstatus-pv2.sh             | 58 ++++++++++++++--------------
 t/t7506-status-submodule.sh         |  2 +-
 t/t9010-svn-fe.sh                   | 14 +++----
 t/t9300-fast-import.sh              |  6 +--
 t/test-lib.sh                       | 11 +++++-
 71 files changed, 331 insertions(+), 267 deletions(-)

tbdiff output:

 1: 03ad090b53 !  1: 1a2e23b4f8 t/test-lib: add an SHA1 prerequisite
    @@ -12,7 +12,7 @@
         these cases.  These tests, too, will fail with a different hash.
         
         Add an SHA1 prerequisite to annotate both of these types of tests and
    -    disable them when we're using a different hash.  In the future, we can
    +    disable them when we're using a different hash.  In the future, we will
         create versions of these tests which handle both SHA-1 and NewHash.
         
         Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
 2: 6b39476f58 =  2: 809ac7d7c3 t/test-lib: introduce ZERO_OID
 3: 45ac938b66 =  3: 1394616579 t: switch $_z40 to $ZERO_OID
 4: a8677dbf35 !  4: adbbf8af80 t/test-lib: introduce OID_REGEX
    @@ -1,13 +1,13 @@
     Author: brian m. carlson <sandals@crustytoothpaste.net>
     
    -    t/test-lib: introduce FULL_HEX
    +    t/test-lib: introduce OID_REGEX
         
         Currently we have a variable, $_x40, which contains a regex that matches
         a full 40-character hex constant.  However, with NewHash, we'll have
         object IDs that are longer than 40 characters.  In such a case, $_x40
    -    will be a confusing name.  Create a $FULL_HEX variable which will always
    -    reflect a regex matching the appropriate object ID, regardless of the
    -    length of the current hash.
    +    will be a confusing name.  Create a $OID_REGEX variable which will
    +    always reflect a regex matching the appropriate object ID, regardless of
    +    the length of the current hash.
         
         Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
     
    @@ -18,7 +18,7 @@
      # Zero SHA-1
      _z40=0000000000000000000000000000000000000000
      
    -+FULL_HEX="$_x40"
    ++OID_REGEX="$_x40"
      ZERO_OID=$_z40
      EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
      EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
    @@ -27,7 +27,7 @@
      u200c=$(printf '\342\200\214')
      
     -export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID
    -+export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID FULL_HEX
    ++export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX
      
      # Each test should start with something like this, after copyright notices:
      #
 5: e9e9c1fa49 !  5: 77877cd04e t: switch $_x40 to $OID_REGEX
    @@ -1,12 +1,12 @@
     Author: brian m. carlson <sandals@crustytoothpaste.net>
     
    -    t: switch $_x40 to $FULL_HEX
    +    t: switch $_x40 to $OID_REGEX
         
    -    Switch all uses of $_x40 to $FULL_HEX so that they work correctly with
    +    Switch all uses of $_x40 to $OID_REGEX so that they work correctly with
         larger hashes.  This commit was created by using the following sed
         command to modify all files in the t directory except t/test-lib.sh:
         
    -      sed -i 's/\$_x40/$FULL_HEX/g'
    +      sed -i 's/\$_x40/$OID_REGEX/g'
         
         Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
     
    @@ -17,7 +17,7 @@
      :
      
     -sanitize_diff_raw='/^:/s/ '"\($_x40\)"' '"\($_x40\)"' \([A-Z]\)[0-9]*	/ \1 \2 \3#	/'
    -+sanitize_diff_raw='/^:/s/ '"\($FULL_HEX\)"' '"\($FULL_HEX\)"' \([A-Z]\)[0-9]*	/ \1 \2 \3#	/'
    ++sanitize_diff_raw='/^:/s/ '"\($OID_REGEX\)"' '"\($OID_REGEX\)"' \([A-Z]\)[0-9]*	/ \1 \2 \3#	/'
      compare_diff_raw () {
          # When heuristics are improved, the score numbers would change.
          # Ignore them while comparing.
    @@ -26,7 +26,7 @@
      }
      
     -sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
    -+sanitize_diff_raw_z='/^:/s/ '"$FULL_HEX"' '"$FULL_HEX"' \([A-Z]\)[0-9]*$/ X X \1#/'
    ++sanitize_diff_raw_z='/^:/s/ '"$OID_REGEX"' '"$OID_REGEX"' \([A-Z]\)[0-9]*$/ X X \1#/'
      compare_diff_raw_z () {
          # When heuristics are improved, the score numbers would change.
          # Ignore them while comparing.
    @@ -39,7 +39,7 @@
      cmp_cache_tree () {
      	test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual &&
     -	sed "s/$_x40/SHA/" <actual >filtered &&
    -+	sed "s/$FULL_HEX/SHA/" <actual >filtered &&
    ++	sed "s/$OID_REGEX/SHA/" <actual >filtered &&
      	test_cmp "$1" filtered
      }
      
    @@ -52,7 +52,7 @@
      
      check_result () {
     -	git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
    -+	git ls-files --stage | sed -e 's/ '"$FULL_HEX"' / X /' >current &&
    ++	git ls-files --stage | sed -e 's/ '"$OID_REGEX"' / X /' >current &&
      	test_cmp expected current
      }
      
    @@ -65,7 +65,7 @@
      	sed -n >current \
      	    -e '/^--- /d; /^+++ /d; /^@@ /d;' \
     -	    -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
    -+	    -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$FULL_HEX"' /\1 X /p' \
    ++	    -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$OID_REGEX"' /\1 X /p' \
      	    "$1"
      	test_cmp expected current
      }
    @@ -78,7 +78,7 @@
      	    -e '2{/^index /d;}' \
      	    -e '/^--- /d; /^+++ /d; /^@@ /d;' \
     -	    -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
    -+	    -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$FULL_HEX"' /\1 X /' "$1"
    ++	    -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$OID_REGEX"' /\1 X /' "$1"
      	test_cmp expected current
      }
      
    @@ -91,7 +91,7 @@
      checkindex () {
      	git ls-files -s |
     -	sed "s|^[0-7][0-7]* $_x40 \([0-3]\)	|\1 |" >current &&
    -+	sed "s|^[0-7][0-7]* $FULL_HEX \([0-3]\)	|\1 |" >current &&
    ++	sed "s|^[0-7][0-7]* $OID_REGEX \([0-3]\)	|\1 |" >current &&
      	cat >expect &&
      	test_cmp expect current
      }
    @@ -104,7 +104,7 @@
      
      test_output () {
     -    sed -e "s/ $_x40	/ X	/" <current >check
    -+    sed -e "s/ $FULL_HEX	/ X	/" <current >check
    ++    sed -e "s/ $OID_REGEX	/ X	/" <current >check
          test_cmp expected check
      }
      
    @@ -117,7 +117,7 @@
      
      test_output () {
     -	sed -e "s/ $_x40	/ X	/" <current >check &&
    -+	sed -e "s/ $FULL_HEX	/ X	/" <current >check &&
    ++	sed -e "s/ $OID_REGEX	/ X	/" <current >check &&
      	test_cmp expected check
      }
      
    @@ -130,16 +130,16 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    - 	} >actual &&
    - 	test_cmp expect actual
    - '
    -@@
    - 	{
    - 		git rev-list HEAD |
    - 		git diff-tree --root --stdin |
    --		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
    + 	} >actual &&
    + 	test_cmp expect actual
    + '
    +@@
    + 	{
    + 		git rev-list HEAD |
    + 		git diff-tree --root --stdin |
    +-		sed "s/$_x40/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	cat >expect <<-\EOF &&
      	OBJID
    @@ -148,7 +148,7 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual.log &&
      	test_cmp expect foo &&
      	test_cmp expect.log actual.log
    @@ -157,7 +157,7 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	cat >expect <<-\EOF &&
      	OBJID
    @@ -170,7 +170,7 @@
          # filesystem.
          sed <"$2" >.test-tmp \
     -	-e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
    -+	-e '/^:000000 /d;s/'$FULL_HEX'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
    ++	-e '/^:000000 /d;s/'$OID_REGEX'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
          test_cmp "$1" .test-tmp
      }
      
    @@ -183,7 +183,7 @@
      . ./test-lib.sh
      
     -sed_script='s/\(:100644 100755\) \('"$_x40"'\) \2 /\1 X X /'
    -+sed_script='s/\(:100644 100755\) \('"$FULL_HEX"'\) \2 /\1 X X /'
    ++sed_script='s/\(:100644 100755\) \('"$OID_REGEX"'\) \2 /\1 X X /'
      
      test_expect_success 'setup' '
      	echo frotz >rezrov &&
    @@ -196,7 +196,7 @@
      	git format-patch --stdout v2..v1 >patch2 &&
      	grep "^From " patch2 >from &&
     -	grep "^From $_x40 Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
    -+	grep "^From $FULL_HEX Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
    ++	grep "^From $OID_REGEX Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
      	test_cmp from filtered
      '
      
    @@ -209,7 +209,7 @@
      	file=$1 &&
      	sed "
     -			s/$_x40/OBJECT_NAME/g
    -+			s/$FULL_HEX/OBJECT_NAME/g
    ++			s/$OID_REGEX/OBJECT_NAME/g
      			s/$_x35/OBJID/g
      			s/^ \{6\}[CTa].*/      SUBJECT/g
      			s/^ \{8\}[^ ].*/        CONTINUATION/g
    @@ -222,7 +222,7 @@
      	#!/bin/sed -nf
      	s/$downstream_url_for_sed/URL/g
     -	s/$_x40/OBJECT_NAME/g
    -+	s/$FULL_HEX/OBJECT_NAME/g
    ++	s/$OID_REGEX/OBJECT_NAME/g
      	s/A U Thor/AUTHOR/g
      	s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
      	s/        [^ ].*/        SUBJECT/g
    @@ -236,8 +236,8 @@
      	git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 &&
     -	sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
     -	sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
    -+	sed -e "s/$FULL_HEX/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
    -+	sed -e "s/$FULL_HEX/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
    ++	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
    ++	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
      	test_cmp expect2 fuzzy2 &&
      	test_cmp expect3 fuzzy3 &&
      	! test_cmp actual1 actual2
    @@ -250,7 +250,7 @@
      
      unnote () {
     -	git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
    -+	git name-rev --tags --stdin | sed -e "s|$FULL_HEX (tags/\([^)]*\)) |\1 |g"
    ++	git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g"
      }
      
      test_expect_success setup '
    @@ -263,7 +263,7 @@
      
      unnote () {
     -	git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\))\([ 	]\)|\1\2|g"
    -+	git name-rev --tags --stdin | sed -e "s|$FULL_HEX (tags/\([^)]*\))\([ 	]\)|\1\2|g"
    ++	git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ 	]\)|\1\2|g"
      }
      
      test_expect_success setup '
    @@ -276,7 +276,7 @@
      
      sanitize_output () {
     -	sed -e "s/$_x40/HASH/" -e "s/$_x40/HASH/" output >output2 &&
    -+	sed -e "s/$FULL_HEX/HASH/" -e "s/$FULL_HEX/HASH/" output >output2 &&
    ++	sed -e "s/$OID_REGEX/HASH/" -e "s/$OID_REGEX/HASH/" output >output2 &&
      	mv output2 output
      }
      
    @@ -289,7 +289,7 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	git show HEAD:greeting >actual.blob &&
      	git show HEAD^:greeting >actual.target &&
    @@ -298,7 +298,7 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	{
      		git cat-file commit HEAD | nul_to_q &&
    @@ -307,7 +307,7 @@
      		git rev-list HEAD |
      		git diff-tree --root --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	git show HEAD:greeting >actual.blob &&
      	git show HEAD^:greeting >actual.target &&
    @@ -316,7 +316,7 @@
      		git rev-list HEAD |
      		git diff-tree --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	test_cmp expect actual
      '
    @@ -325,25 +325,25 @@
      		git rev-list HEAD |
      		git diff-tree --root --always --stdin |
     -		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    - 	} >actual &&
    - 	test_cmp expect actual
    - '
    -@@
    - 	{
    - 		git rev-list HEAD |
    - 		git diff-tree --root --stdin |
    --		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    - 	} >actual &&
    - 	test_cmp expect actual
    - '
    -@@
    - 	{
    - 		git rev-list HEAD |
    - 		git diff-tree --root --stdin |
    --		sed "s/$_x40/OBJID/g"
    -+		sed "s/$FULL_HEX/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
    + 	} >actual &&
    + 	test_cmp expect actual
    + '
    +@@
    + 	{
    + 		git rev-list HEAD |
    + 		git diff-tree --root --stdin |
    +-		sed "s/$_x40/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
    + 	} >actual &&
    + 	test_cmp expect actual
    + '
    +@@
    + 	{
    + 		git rev-list HEAD |
    + 		git diff-tree --root --stdin |
    +-		sed "s/$_x40/OBJID/g"
    ++		sed "s/$OID_REGEX/OBJID/g"
      	} >actual &&
      	test_cmp expect actual &&
      	git show HEAD:postimage >actual.3 &&
    @@ -356,7 +356,7 @@
      	git rev-list read-empty |
      	git diff-tree -r --root --stdin |
     -	sed "s/$_x40/OBJNAME/g" >actual &&
    -+	sed "s/$FULL_HEX/OBJNAME/g" >actual &&
    ++	sed "s/$OID_REGEX/OBJNAME/g" >actual &&
      	test_cmp expect actual
      '
      
    @@ -365,7 +365,7 @@
      	git rev-list N-delete |
      		git diff-tree -r --stdin --root --always |
     -		sed -e "s/$_x40/OBJID/g" >actual &&
    -+		sed -e "s/$FULL_HEX/OBJID/g" >actual &&
    ++		sed -e "s/$OID_REGEX/OBJID/g" >actual &&
      	test_cmp expect actual
      '
      
    @@ -374,7 +374,7 @@
      	git rev-list done-ends |
      	git diff-tree -r --stdin --root --always |
     -	sed -e "s/$_x40/OBJID/g" >actual &&
    -+	sed -e "s/$FULL_HEX/OBJID/g" >actual &&
    - 	test_cmp expect actual
    - '
    - 
    ++	sed -e "s/$OID_REGEX/OBJID/g" >actual &&
    + 	test_cmp expect actual
    + '
    + 
 6: 266d018808 =  6: 41c01b5fcf t0000: annotate with SHA1 prerequisite
 7: 6fea58fcc2 =  7: c175f5d565 t1007: annotate with SHA1 prerequisite
 8: 57722629fa =  8: 936a8d90fd t1512: skip test if not using SHA-1
 9: e17c66bbb0 =  9: 18a2c50777 t4044: skip test if not using SHA-1
10: 2d2baa9729 = 10: bdb27df589 t: skip pack tests if not using SHA-1
11: 0b50c02784 = 11: d09b454988 t2203: abstract away SHA-1-specific constants
12: 6de266bf25 = 12: 61c93d4d8a t3103: abstract away SHA-1-specific constants
13: a36512bfed = 13: 2fdf7883c2 t3702: abstract away SHA-1-specific constants
14: edc0e12cca ! 14: 9e99a40aa1 t3905: abstract away SHA-1-specific constants
    @@ -11,10 +11,9 @@
     --- a/t/t3905-stash-include-untracked.sh
     +++ b/t/t3905-stash-include-untracked.sh
     @@
    - 	git status --porcelain >actual &&
      	test_cmp expect actual
      '
    --
    + 
     +tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin))
     +untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin))
      cat > expect.diff <<EOF
15: cd84d00f27 = 15: ad45ab6bed t4007: abstract away SHA-1-specific constants
16: 5b49fc4b62 ! 16: 56a69fbe23 t4008: abstract away SHA-1-specific constants
    @@ -77,7 +77,7 @@
      test_expect_success 'make file0 into something completely different' '
      	rm -f file0 &&
      	test_ln_s_add frotz file0 &&
    -+	link_oid=$(printf frotz | git hash-object --stdin) &&
    ++	slink_id=$(printf frotz | git hash-object --stdin) &&
      	git update-index file1
      '
      
    @@ -87,7 +87,7 @@
     -	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
     -	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100	file1
     +	cat >expect <<-EOF &&
    -+	:100644 120000 $blob0_id $link_oid T	file0
    ++	:100644 120000 $blob0_id $slink_id T	file0
     +	:100644 100644 $blob1_id $blob0_id M100	file1
      	EOF
      	compare_diff_raw expect current
    @@ -100,7 +100,7 @@
     -	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
     -	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 C	file0	file1
     +	cat >expect <<-EOF &&
    -+	:100644 120000 $blob0_id $link_oid T	file0
    ++	:100644 120000 $blob0_id $slink_id T	file0
     +	:100644 100644 $blob0_id $blob0_id C	file0	file1
      	EOF
      	compare_diff_raw expect current
    @@ -113,7 +113,7 @@
     -	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
     -	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M	file1
     +	cat >expect <<-EOF &&
    -+	:100644 120000 $blob0_id $link_oid T	file0
    ++	:100644 120000 $blob0_id $slink_id T	file0
     +	:100644 100644 $blob1_id $blob0_id M	file1
      	EOF
      	compare_diff_raw expect current
17: a723e189cd = 17: 11c545cd51 t4014: abstract away SHA-1-specific constants
18: 970a3016ed = 18: fcca4074e6 t4020: abstract away SHA-1-specific constants
19: 4640ef9170 = 19: ad252e46c4 t4022: abstract away SHA-1-specific constants
20: f1f66b513b = 20: 4046eecebd t4029: fix test indentation
21: 9a8a9b6762 = 21: 56896e45f0 t4029: abstract away SHA-1-specific constants
22: 6573352174 = 22: 27609ec546 t4030: abstract away SHA-1-specific constants
23: e79d9ab24e = 23: 8c782009bf t/lib-diff-alternative: abstract away SHA-1-specific constants
24: d0bab817d4 = 24: 2f0da3e1b8 t4205: sort log output in a hash-independent way
25: 3b2719de86 = 25: 3e913f2526 t4042: abstract away SHA-1-specific constants
26: f3034dd64a = 26: 2261c64650 t4045: abstract away SHA-1-specific constants
27: fbf4568271 = 27: 458006036a t4208: abstract away SHA-1-specific constants
28: a1c8324b74 = 28: 8da8c65428 t5300: abstract away SHA-1-specific constants

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v2 01/28] t/test-lib: add an SHA1 prerequisite
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 02/28] t/test-lib: introduce ZERO_OID brian m. carlson
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

There are some basic tests in our codebase that test that we get fixed
SHA-1 values.  These are valuable because they make sure that our SHA-1
implementation is free of bugs, but obviously these tests will fail with
a different hash.

There are also tests which intentionally produce objects that have
collisions when truncated to a certain length to test our handling of
these cases.  These tests, too, will fail with a different hash.

Add an SHA1 prerequisite to annotate both of these types of tests and
disable them when we're using a different hash.  In the future, we will
create versions of these tests which handle both SHA-1 and NewHash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/test-lib.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index ea2bbaaa7a..fce728d2ea 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1212,3 +1212,10 @@ test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit'
 test_lazy_prereq CURL '
 	curl --version
 '
+
+# SHA1 is a test if the hash algorithm in use is SHA-1.  This is both for tests
+# which will not work with other hash algorithms and tests that work but don't
+# test anything meaningful (e.g. special values which cause short collisions).
+test_lazy_prereq SHA1 '
+	test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
+'

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 02/28] t/test-lib: introduce ZERO_OID
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 03/28] t: switch $_z40 to $ZERO_OID brian m. carlson
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Currently we have a variable, $_z40, which contains the all-zero object
ID.  However, with NewHash, we'll have an all-zero object ID which is
longer than 40 hex characters.  In such a case, $_z40 will be a
confusing name.  Create a $ZERO_OID variable which will always reflect
the all-zeros object ID, regardless of the length of the current hash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/test-lib.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index fce728d2ea..58c2ea52c6 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -184,6 +184,7 @@ _x40="$_x35$_x05"
 # Zero SHA-1
 _z40=0000000000000000000000000000000000000000
 
+ZERO_OID=$_z40
 EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
 EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
 
@@ -195,7 +196,7 @@ LF='
 # when case-folding filenames
 u200c=$(printf '\342\200\214')
 
-export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB
+export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID
 
 # Each test should start with something like this, after copyright notices:
 #

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 03/28] t: switch $_z40 to $ZERO_OID
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 02/28] t/test-lib: introduce ZERO_OID brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 04/28] t/test-lib: introduce OID_REGEX brian m. carlson
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Switch all uses of $_z40 to $ZERO_OID so that they work correctly with
larger hashes.  This commit was created by using the following sed
command to modify all files in the t directory except t/test-lib.sh:

  sed -i 's/\$_z40/$ZERO_OID/g'

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t1006-cat-file.sh                |  8 ++---
 t/t1400-update-ref.sh              |  2 +-
 t/t1407-worktree-ref-store.sh      |  8 ++---
 t/t1450-fsck.sh                    |  4 +--
 t/t1501-work-tree.sh               |  6 ++--
 t/t1601-index-bogus.sh             |  2 +-
 t/t1700-split-index.sh             |  2 +-
 t/t2011-checkout-invalid-head.sh   |  2 +-
 t/t2025-worktree-add.sh            |  8 ++---
 t/t2027-worktree-list.sh           |  2 +-
 t/t2107-update-index-basic.sh      |  4 +--
 t/t2201-add-update-typechange.sh   | 16 ++++-----
 t/t2203-add-intent.sh              |  6 ++--
 t/t3200-branch.sh                  |  4 +--
 t/t4002-diff-basic.sh              |  2 +-
 t/t4014-format-patch.sh            |  2 +-
 t/t4020-diff-external.sh           | 10 +++---
 t/t4027-diff-submodule.sh          |  6 ++--
 t/t4046-diff-unmerged.sh           | 14 ++++----
 t/t4054-diff-bogus-tree.sh         | 12 +++----
 t/t4058-diff-duplicates.sh         | 12 +++----
 t/t4150-am.sh                      |  4 +--
 t/t4200-rerere.sh                  |  2 +-
 t/t5516-fetch-push.sh              | 22 ++++++------
 t/t5527-fetch-odd-refs.sh          |  2 +-
 t/t5571-pre-push-hook.sh           |  8 ++---
 t/t6120-describe.sh                |  2 +-
 t/t6300-for-each-ref.sh            |  2 +-
 t/t6301-for-each-ref-errors.sh     |  2 +-
 t/t7009-filter-branch-null-sha1.sh |  2 +-
 t/t7011-skip-worktree-reading.sh   |  2 +-
 t/t7064-wtstatus-pv2.sh            | 58 +++++++++++++++---------------
 32 files changed, 119 insertions(+), 119 deletions(-)

diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 2ac3b940c6..13dd510b2e 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -236,8 +236,8 @@ test_expect_success "--batch-check for an empty line" '
 '
 
 test_expect_success 'empty --batch-check notices missing object' '
-	echo "$_z40 missing" >expect &&
-	echo "$_z40" | git cat-file --batch-check="" >actual &&
+	echo "$ZERO_OID missing" >expect &&
+	echo "$ZERO_OID" | git cat-file --batch-check="" >actual &&
 	test_cmp expect actual
 '
 
@@ -294,8 +294,8 @@ test_expect_success 'setup blobs which are likely to delta' '
 
 test_expect_success 'confirm that neither loose blob is a delta' '
 	cat >expect <<-EOF &&
-	$_z40
-	$_z40
+	$ZERO_OID
+	$ZERO_OID
 	EOF
 	git cat-file --batch-check="%(deltabase)" <blobs >actual &&
 	test_cmp expect actual
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 664a3a4e4e..f6dc05654e 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -6,7 +6,7 @@
 test_description='Test git update-ref and basic ref logging'
 . ./test-lib.sh
 
-Z=$_z40
+Z=$ZERO_OID
 
 m=refs/heads/master
 n_dir=refs/heads/gu
diff --git a/t/t1407-worktree-ref-store.sh b/t/t1407-worktree-ref-store.sh
index 2211f9831f..4623ae15c4 100755
--- a/t/t1407-worktree-ref-store.sh
+++ b/t/t1407-worktree-ref-store.sh
@@ -50,13 +50,13 @@ test_expect_success 'create_symref(FOO, refs/heads/master)' '
 '
 
 test_expect_success 'for_each_reflog()' '
-	echo $_z40 > .git/logs/PSEUDO-MAIN &&
+	echo $ZERO_OID > .git/logs/PSEUDO-MAIN &&
 	mkdir -p     .git/logs/refs/bisect &&
-	echo $_z40 > .git/logs/refs/bisect/random &&
+	echo $ZERO_OID > .git/logs/refs/bisect/random &&
 
-	echo $_z40 > .git/worktrees/wt/logs/PSEUDO-WT &&
+	echo $ZERO_OID > .git/worktrees/wt/logs/PSEUDO-WT &&
 	mkdir -p     .git/worktrees/wt/logs/refs/bisect &&
-	echo $_z40 > .git/worktrees/wt/logs/refs/bisect/wt-random &&
+	echo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&
 
 	$RWT for-each-reflog | cut -c 42- | sort >actual &&
 	cat >expected <<-\EOF &&
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index cb4b66e29d..91fd71444d 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -713,7 +713,7 @@ test_expect_success 'fsck notices dangling objects' '
 
 test_expect_success 'fsck $name notices bogus $name' '
 	test_must_fail git fsck bogus &&
-	test_must_fail git fsck $_z40
+	test_must_fail git fsck $ZERO_OID
 '
 
 test_expect_success 'bogus head does not fallback to all heads' '
@@ -723,7 +723,7 @@ test_expect_success 'bogus head does not fallback to all heads' '
 	blob=$(git rev-parse :foo) &&
 	test_when_finished "git rm --cached foo" &&
 	remove_object $blob &&
-	test_must_fail git fsck $_z40 >out 2>&1 &&
+	test_must_fail git fsck $ZERO_OID >out 2>&1 &&
 	! grep $blob out
 '
 
diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh
index 9c0bc65250..afcdfafe45 100755
--- a/t/t1501-work-tree.sh
+++ b/t/t1501-work-tree.sh
@@ -238,10 +238,10 @@ test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' '
 
 test_expect_success 'diff-index respects work tree under .git dir' '
 	cat >diff-index-cached.expected <<-EOF &&
-	:000000 100644 $_z40 $EMPTY_BLOB A	sub/dir/tracked
+	:000000 100644 $ZERO_OID $EMPTY_BLOB A	sub/dir/tracked
 	EOF
 	cat >diff-index.expected <<-EOF &&
-	:000000 100644 $_z40 $_z40 A	sub/dir/tracked
+	:000000 100644 $ZERO_OID $ZERO_OID A	sub/dir/tracked
 	EOF
 
 	(
@@ -257,7 +257,7 @@ test_expect_success 'diff-index respects work tree under .git dir' '
 
 test_expect_success 'diff-files respects work tree under .git dir' '
 	cat >diff-files.expected <<-EOF &&
-	:100644 100644 $EMPTY_BLOB $_z40 M	sub/dir/tracked
+	:100644 100644 $EMPTY_BLOB $ZERO_OID M	sub/dir/tracked
 	EOF
 
 	(
diff --git a/t/t1601-index-bogus.sh b/t/t1601-index-bogus.sh
index 73cc9323cd..4171f1e141 100755
--- a/t/t1601-index-bogus.sh
+++ b/t/t1601-index-bogus.sh
@@ -4,7 +4,7 @@ test_description='test handling of bogus index entries'
 . ./test-lib.sh
 
 test_expect_success 'create tree with null sha1' '
-	tree=$(printf "160000 commit $_z40\\tbroken\\n" | git mktree)
+	tree=$(printf "160000 commit $ZERO_OID\\tbroken\\n" | git mktree)
 '
 
 test_expect_success 'read-tree refuses to read null sha1' '
diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh
index e4f4c4df4e..1e81b33b2e 100755
--- a/t/t1700-split-index.sh
+++ b/t/t1700-split-index.sh
@@ -426,7 +426,7 @@ test_expect_success 'writing split index with null sha1 does not write cache tre
 	git commit -m "commit" &&
 	{
 		git ls-tree HEAD &&
-		printf "160000 commit $_z40\\tbroken\\n"
+		printf "160000 commit $ZERO_OID\\tbroken\\n"
 	} >broken-tree &&
 	echo "add broken entry" >msg &&
 
diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh
index c5501b008c..0e8d56aa76 100755
--- a/t/t2011-checkout-invalid-head.sh
+++ b/t/t2011-checkout-invalid-head.sh
@@ -15,7 +15,7 @@ test_expect_success 'checkout should not start branch from a tree' '
 '
 
 test_expect_success 'checkout master from invalid HEAD' '
-	echo $_z40 >.git/HEAD &&
+	echo $ZERO_OID >.git/HEAD &&
 	git checkout master --
 '
 
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index d0d2e4f7ec..beaed5e7a1 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -465,7 +465,7 @@ post_checkout_hook () {
 test_expect_success '"add" invokes post-checkout hook (branch)' '
 	post_checkout_hook &&
 	{
-		echo $_z40 $(git rev-parse HEAD) 1 &&
+		echo $ZERO_OID $(git rev-parse HEAD) 1 &&
 		echo $(pwd)/.git/worktrees/gumby &&
 		echo $(pwd)/gumby
 	} >hook.expect &&
@@ -476,7 +476,7 @@ test_expect_success '"add" invokes post-checkout hook (branch)' '
 test_expect_success '"add" invokes post-checkout hook (detached)' '
 	post_checkout_hook &&
 	{
-		echo $_z40 $(git rev-parse HEAD) 1 &&
+		echo $ZERO_OID $(git rev-parse HEAD) 1 &&
 		echo $(pwd)/.git/worktrees/grumpy &&
 		echo $(pwd)/grumpy
 	} >hook.expect &&
@@ -494,7 +494,7 @@ test_expect_success '"add --no-checkout" suppresses post-checkout hook' '
 test_expect_success '"add" in other worktree invokes post-checkout hook' '
 	post_checkout_hook &&
 	{
-		echo $_z40 $(git rev-parse HEAD) 1 &&
+		echo $ZERO_OID $(git rev-parse HEAD) 1 &&
 		echo $(pwd)/.git/worktrees/guppy &&
 		echo $(pwd)/guppy
 	} >hook.expect &&
@@ -506,7 +506,7 @@ test_expect_success '"add" in bare repo invokes post-checkout hook' '
 	rm -rf bare &&
 	git clone --bare . bare &&
 	{
-		echo $_z40 $(git --git-dir=bare rev-parse HEAD) 1 &&
+		echo $ZERO_OID $(git --git-dir=bare rev-parse HEAD) 1 &&
 		echo $(pwd)/bare/worktrees/goozy &&
 		echo $(pwd)/goozy
 	} >hook.expect &&
diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh
index 720063bf0d..bb6fb9b12c 100755
--- a/t/t2027-worktree-list.sh
+++ b/t/t2027-worktree-list.sh
@@ -116,7 +116,7 @@ test_expect_success 'broken main worktree still at the top' '
 		git worktree add linked &&
 		cat >expected <<-EOF &&
 		worktree $(pwd)
-		HEAD $_z40
+		HEAD $ZERO_OID
 
 		EOF
 		cd linked &&
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh
index 1db7e6a1ab..2242cd098e 100755
--- a/t/t2107-update-index-basic.sh
+++ b/t/t2107-update-index-basic.sh
@@ -37,7 +37,7 @@ test_expect_success '--cacheinfo does not accept blob null sha1' '
 	echo content >file &&
 	git add file &&
 	git rev-parse :file >expect &&
-	test_must_fail git update-index --cacheinfo 100644 $_z40 file &&
+	test_must_fail git update-index --cacheinfo 100644 $ZERO_OID file &&
 	git rev-parse :file >actual &&
 	test_cmp expect actual
 '
@@ -47,7 +47,7 @@ test_expect_success '--cacheinfo does not accept gitlink null sha1' '
 	(cd submodule && test_commit foo) &&
 	git add submodule &&
 	git rev-parse :submodule >expect &&
-	test_must_fail git update-index --cacheinfo 160000 $_z40 submodule &&
+	test_must_fail git update-index --cacheinfo 160000 $ZERO_OID submodule &&
 	git rev-parse :submodule >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
index 954fc51e5b..a4eec0a346 100755
--- a/t/t2201-add-update-typechange.sh
+++ b/t/t2201-add-update-typechange.sh
@@ -75,35 +75,35 @@ test_expect_success modify '
 		git ls-tree -r HEAD |
 		sed -e "s/^/:/" -e "
 			/	caskly/{
-				s/	caskly/ $_z40 D&/
+				s/	caskly/ $ZERO_OID D&/
 				s/blob/000000/
 			}
 			/	nitfol/{
-				s/	nitfol/ $_z40 $T_letter&/
+				s/	nitfol/ $ZERO_OID $T_letter&/
 				s/blob/100644/
 			}
 			/	rezrov.bozbar/{
-				s/	rezrov.bozbar/ $_z40 D&/
+				s/	rezrov.bozbar/ $ZERO_OID D&/
 				s/blob/000000/
 			}
 			/	xyzzy/{
-				s/	xyzzy/ $_z40 D&/
+				s/	xyzzy/ $ZERO_OID D&/
 				s/blob/000000/
 			}
 			/	yomin/{
-			    s/	yomin/ $_z40 T&/
+			    s/	yomin/ $ZERO_OID T&/
 				s/blob/160000/
 			}
 		"
 	} >expect &&
 	{
 		cat expect
-		echo ":100644 160000 $_empty $_z40 T	yonk"
-		echo ":100644 000000 $_empty $_z40 D	zifmia"
+		echo ":100644 160000 $_empty $ZERO_OID T	yonk"
+		echo ":100644 000000 $_empty $ZERO_OID D	zifmia"
 	} >expect-files &&
 	{
 		cat expect
-		echo ":000000 160000 $_z40 $_z40 A	yonk"
+		echo ":000000 160000 $ZERO_OID $ZERO_OID A	yonk"
 	} >expect-index &&
 	{
 		echo "100644 $_empty 0	nitfol"
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 78236dc7d8..1797f946b9 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -30,9 +30,9 @@ test_expect_success 'git status with porcelain v2' '
 	nam1=d00491fd7e5bb6fa28c517a0bb32b8b506539d4d &&
 	nam2=ce013625030ba8dba906f756967f9e9ca394464a &&
 	cat >expect <<-EOF &&
-	1 DA N... 100644 000000 100644 $nam1 $_z40 1.t
-	1 A. N... 000000 100644 100644 $_z40 $nam2 elif
-	1 .A N... 000000 000000 100644 $_z40 $_z40 file
+	1 DA N... 100644 000000 100644 $nam1 $ZERO_OID 1.t
+	1 A. N... 000000 100644 100644 $ZERO_OID $nam2 elif
+	1 .A N... 000000 000000 100644 $ZERO_OID $ZERO_OID file
 	EOF
 	test_cmp expect actual
 '
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c0ef946811..b52c655c37 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -47,7 +47,7 @@ test_expect_success 'git branch HEAD should fail' '
 '
 
 cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	branch: Created from master
+$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	branch: Created from master
 EOF
 test_expect_success 'git branch -l d/e/f should create a branch and a log' '
 	GIT_COMMITTER_DATE="2005-05-26 23:30" \
@@ -901,7 +901,7 @@ test_expect_success '--set-upstream-to notices an error to set branch as own ups
 
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	branch: Created from master
+$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	branch: Created from master
 EOF
 test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
 	GIT_COMMITTER_DATE="2005-05-26 23:30" \
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index a5e8b83083..5af773d6f7 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -131,7 +131,7 @@ cmp_diff_files_output () {
     # object ID for the changed files because it wants you to look at the
     # filesystem.
     sed <"$2" >.test-tmp \
-	-e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\)	/'$_z40'\1	/' &&
+	-e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
     test_cmp "$1" .test-tmp
 }
 
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 482112ca33..0dbf7d5b4b 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1523,7 +1523,7 @@ test_expect_success 'cover letter auto user override' '
 test_expect_success 'format-patch --zero-commit' '
 	git format-patch --zero-commit --stdout v2..v1 >patch2 &&
 	grep "^From " patch2 | sort | uniq >actual &&
-	echo "From $_z40 Mon Sep 17 00:00:00 2001" >expect &&
+	echo "From $ZERO_OID Mon Sep 17 00:00:00 2001" >expect &&
 	test_cmp expect actual
 '
 
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 044620186d..49d3f54b29 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -26,7 +26,7 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment' '
 		read path oldfile oldhex oldmode newfile newhex newmode &&
 		test "z$path" = zfile &&
 		test "z$oldmode" = z100644 &&
-		test "z$newhex" = "z$_z40" &&
+		test "z$newhex" = "z$ZERO_OID" &&
 		test "z$newmode" = z100644 &&
 		oh=$(git rev-parse --verify HEAD:file) &&
 		test "z$oh" = "z$oldhex"
@@ -55,7 +55,7 @@ test_expect_success SYMLINKS 'typechange diff' '
 		read path oldfile oldhex oldmode newfile newhex newmode &&
 		test "z$path" = zfile &&
 		test "z$oldmode" = z100644 &&
-		test "z$newhex" = "z$_z40" &&
+		test "z$newhex" = "z$ZERO_OID" &&
 		test "z$newmode" = z120000 &&
 		oh=$(git rev-parse --verify HEAD:file) &&
 		test "z$oh" = "z$oldhex"
@@ -73,7 +73,7 @@ test_expect_success 'diff.external' '
 		read path oldfile oldhex oldmode newfile newhex newmode &&
 		test "z$path" = zfile &&
 		test "z$oldmode" = z100644 &&
-		test "z$newhex" = "z$_z40" &&
+		test "z$newhex" = "z$ZERO_OID" &&
 		test "z$newmode" = z100644 &&
 		oh=$(git rev-parse --verify HEAD:file) &&
 		test "z$oh" = "z$oldhex"
@@ -104,7 +104,7 @@ test_expect_success 'diff attribute' '
 		read path oldfile oldhex oldmode newfile newhex newmode &&
 		test "z$path" = zfile &&
 		test "z$oldmode" = z100644 &&
-		test "z$newhex" = "z$_z40" &&
+		test "z$newhex" = "z$ZERO_OID" &&
 		test "z$newmode" = z100644 &&
 		oh=$(git rev-parse --verify HEAD:file) &&
 		test "z$oh" = "z$oldhex"
@@ -137,7 +137,7 @@ test_expect_success 'diff attribute' '
 		read path oldfile oldhex oldmode newfile newhex newmode &&
 		test "z$path" = zfile &&
 		test "z$oldmode" = z100644 &&
-		test "z$newhex" = "z$_z40" &&
+		test "z$newhex" = "z$ZERO_OID" &&
 		test "z$newmode" = z100644 &&
 		oh=$(git rev-parse --verify HEAD:file) &&
 		test "z$oh" = "z$oldhex"
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 2ffd11a142..6304130ad4 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -31,7 +31,7 @@ test_expect_success setup '
 		cd sub &&
 		git rev-list HEAD
 	) &&
-	echo ":160000 160000 $3 $_z40 M	sub" >expect &&
+	echo ":160000 160000 $3 $ZERO_OID M	sub" >expect &&
 	subtip=$3 subprev=$2
 '
 
@@ -250,7 +250,7 @@ test_expect_success 'conflicted submodule setup' '
 	# 39 efs
 	c=fffffffffffffffffffffffffffffffffffffff &&
 	(
-		echo "000000 $_z40 0	sub" &&
+		echo "000000 $ZERO_OID 0	sub" &&
 		echo "160000 1$c 1	sub" &&
 		echo "160000 2$c 2	sub" &&
 		echo "160000 3$c 3	sub"
@@ -265,7 +265,7 @@ index 2ffffff,3ffffff..0000000
 ++Subproject commit 0000000000000000000000000000000000000000'\'' &&
 
 	hh=$(git rev-parse HEAD) &&
-	sed -e "s/$_z40/$hh/" expect.nosub >expect.withsub
+	sed -e "s/$ZERO_OID/$hh/" expect.nosub >expect.withsub
 
 '
 
diff --git a/t/t4046-diff-unmerged.sh b/t/t4046-diff-unmerged.sh
index d0f14475ca..ff7cfd884a 100755
--- a/t/t4046-diff-unmerged.sh
+++ b/t/t4046-diff-unmerged.sh
@@ -37,7 +37,7 @@ test_expect_success 'diff-files -0' '
 	for path in $paths
 	do
 		>"$path" &&
-		echo ":000000 100644 $_z40 $_z40 U	$path"
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path"
 	done >diff-files-0.expect &&
 	git diff-files -0 >diff-files-0.actual &&
 	test_cmp diff-files-0.expect diff-files-0.actual
@@ -47,9 +47,9 @@ test_expect_success 'diff-files -1' '
 	for path in $paths
 	do
 		>"$path" &&
-		echo ":000000 100644 $_z40 $_z40 U	$path" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
 		case "$path" in
-		x??) echo ":100644 100644 $blob1 $_z40 M	$path"
+		x??) echo ":100644 100644 $blob1 $ZERO_OID M	$path"
 		esac
 	done >diff-files-1.expect &&
 	git diff-files -1 >diff-files-1.actual &&
@@ -60,9 +60,9 @@ test_expect_success 'diff-files -2' '
 	for path in $paths
 	do
 		>"$path" &&
-		echo ":000000 100644 $_z40 $_z40 U	$path" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
 		case "$path" in
-		?x?) echo ":100644 100644 $blob2 $_z40 M	$path"
+		?x?) echo ":100644 100644 $blob2 $ZERO_OID M	$path"
 		esac
 	done >diff-files-2.expect &&
 	git diff-files -2 >diff-files-2.actual &&
@@ -75,9 +75,9 @@ test_expect_success 'diff-files -3' '
 	for path in $paths
 	do
 		>"$path" &&
-		echo ":000000 100644 $_z40 $_z40 U	$path" &&
+		echo ":000000 100644 $ZERO_OID $ZERO_OID U	$path" &&
 		case "$path" in
-		??x) echo ":100644 100644 $blob3 $_z40 M	$path"
+		??x) echo ":100644 100644 $blob3 $ZERO_OID M	$path"
 		esac
 	done >diff-files-3.expect &&
 	git diff-files -3 >diff-files-3.actual &&
diff --git a/t/t4054-diff-bogus-tree.sh b/t/t4054-diff-bogus-tree.sh
index 18f42c5fff..fcae82fffa 100755
--- a/t/t4054-diff-bogus-tree.sh
+++ b/t/t4054-diff-bogus-tree.sh
@@ -19,37 +19,37 @@ test_expect_success 'create tree with matching file' '
 '
 
 test_expect_success 'raw diff shows null sha1 (addition)' '
-	echo ":000000 100644 $_z40 $_z40 A	foo" >expect &&
+	echo ":000000 100644 $ZERO_OID $ZERO_OID A	foo" >expect &&
 	git diff-tree $EMPTY_TREE $bogus_tree >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (removal)' '
-	echo ":100644 000000 $_z40 $_z40 D	foo" >expect &&
+	echo ":100644 000000 $ZERO_OID $ZERO_OID D	foo" >expect &&
 	git diff-tree $bogus_tree $EMPTY_TREE >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (modification)' '
-	echo ":100644 100644 $blob $_z40 M	foo" >expect &&
+	echo ":100644 100644 $blob $ZERO_OID M	foo" >expect &&
 	git diff-tree $good_tree $bogus_tree >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (other direction)' '
-	echo ":100644 100644 $_z40 $blob M	foo" >expect &&
+	echo ":100644 100644 $ZERO_OID $blob M	foo" >expect &&
 	git diff-tree $bogus_tree $good_tree >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (reverse)' '
-	echo ":100644 100644 $_z40 $blob M	foo" >expect &&
+	echo ":100644 100644 $ZERO_OID $blob M	foo" >expect &&
 	git diff-tree -R $good_tree $bogus_tree >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'raw diff shows null sha1 (index)' '
-	echo ":100644 100644 $_z40 $blob M	foo" >expect &&
+	echo ":100644 100644 $ZERO_OID $blob M	foo" >expect &&
 	git diff-index $bogus_tree >actual &&
 	test_cmp expect actual
 '
diff --git a/t/t4058-diff-duplicates.sh b/t/t4058-diff-duplicates.sh
index 0a23242cb6..c24ee175ef 100755
--- a/t/t4058-diff-duplicates.sh
+++ b/t/t4058-diff-duplicates.sh
@@ -59,12 +59,12 @@ test_expect_success 'create trees with duplicate entries' '
 
 test_expect_success 'diff-tree between trees' '
 	{
-		printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
-		printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
-		printf ":000000 100644 $_z40 $blob_two A\touter/inner\n" &&
-		printf ":100644 000000 $blob_two $_z40 D\touter/inner\n" &&
-		printf ":100644 000000 $blob_two $_z40 D\touter/inner\n" &&
-		printf ":100644 000000 $blob_two $_z40 D\touter/inner\n"
+		printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
+		printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
+		printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
+		printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+		printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
+		printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n"
 	} >expect &&
 	git diff-tree -r --no-abbrev one two >actual &&
 	test_cmp expect actual
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 1eccfb71d0..1ebc587f8f 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -140,8 +140,8 @@ test_expect_success setup '
 		echo "# User $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" &&
 		echo "# Date $test_tick 25200" &&
 		echo "#      $(git show --pretty="%aD" -s second)" &&
-		echo "# Node ID $_z40" &&
-		echo "# Parent  $_z40" &&
+		echo "# Node ID $ZERO_OID" &&
+		echo "# Parent  $ZERO_OID" &&
 		cat msg &&
 		echo &&
 		git diff-tree --no-commit-id -p second
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index eaf18c81cb..8417e5a4b1 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -243,7 +243,7 @@ rerere_gc_custom_expiry_test () {
 	five_days="$1" right_now="$2"
 	test_expect_success "rerere gc with custom expiry ($five_days, $right_now)" '
 		rm -fr .git/rr-cache &&
-		rr=.git/rr-cache/$_z40 &&
+		rr=.git/rr-cache/$ZERO_OID &&
 		mkdir -p "$rr" &&
 		>"$rr/preimage" &&
 		>"$rr/postimage" &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 82239138d5..d9c90f2ba5 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -634,7 +634,7 @@ test_expect_success 'pushing valid refs triggers post-receive and post-update ho
 	orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
 	newmaster=$(git show-ref -s --verify refs/heads/master) &&
 	orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
-	newnext=$_z40 &&
+	newnext=$ZERO_OID &&
 	git push testrepo refs/heads/master:refs/heads/master :refs/heads/next &&
 	(
 		cd testrepo/.git &&
@@ -672,15 +672,15 @@ test_expect_success 'deleting dangling ref triggers hooks with correct args' '
 	(
 		cd testrepo/.git &&
 		cat >pre-receive.expect <<-EOF &&
-		$_z40 $_z40 refs/heads/master
+		$ZERO_OID $ZERO_OID refs/heads/master
 		EOF
 
 		cat >update.expect <<-EOF &&
-		refs/heads/master $_z40 $_z40
+		refs/heads/master $ZERO_OID $ZERO_OID
 		EOF
 
 		cat >post-receive.expect <<-EOF &&
-		$_z40 $_z40 refs/heads/master
+		$ZERO_OID $ZERO_OID refs/heads/master
 		EOF
 
 		cat >post-update.expect <<-EOF &&
@@ -703,12 +703,12 @@ test_expect_success 'deletion of a non-existent ref is not fed to post-receive a
 		cd testrepo/.git &&
 		cat >pre-receive.expect <<-EOF &&
 		$orgmaster $newmaster refs/heads/master
-		$_z40 $_z40 refs/heads/nonexistent
+		$ZERO_OID $ZERO_OID refs/heads/nonexistent
 		EOF
 
 		cat >update.expect <<-EOF &&
 		refs/heads/master $orgmaster $newmaster
-		refs/heads/nonexistent $_z40 $_z40
+		refs/heads/nonexistent $ZERO_OID $ZERO_OID
 		EOF
 
 		cat >post-receive.expect <<-EOF &&
@@ -732,11 +732,11 @@ test_expect_success 'deletion of a non-existent ref alone does trigger post-rece
 	(
 		cd testrepo/.git &&
 		cat >pre-receive.expect <<-EOF &&
-		$_z40 $_z40 refs/heads/nonexistent
+		$ZERO_OID $ZERO_OID refs/heads/nonexistent
 		EOF
 
 		cat >update.expect <<-EOF &&
-		refs/heads/nonexistent $_z40 $_z40
+		refs/heads/nonexistent $ZERO_OID $ZERO_OID
 		EOF
 
 		test_cmp pre-receive.expect pre-receive.actual &&
@@ -751,7 +751,7 @@ test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks w
 	orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
 	newmaster=$(git show-ref -s --verify refs/heads/master) &&
 	orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
-	newnext=$_z40 &&
+	newnext=$ZERO_OID &&
 	orgpu=$(cd testrepo && git show-ref -s --verify refs/heads/pu) &&
 	newpu=$(git show-ref -s --verify refs/heads/master) &&
 	git push testrepo refs/heads/master:refs/heads/master \
@@ -763,14 +763,14 @@ test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks w
 		$orgmaster $newmaster refs/heads/master
 		$orgnext $newnext refs/heads/next
 		$orgpu $newpu refs/heads/pu
-		$_z40 $_z40 refs/heads/nonexistent
+		$ZERO_OID $ZERO_OID refs/heads/nonexistent
 		EOF
 
 		cat >update.expect <<-EOF &&
 		refs/heads/master $orgmaster $newmaster
 		refs/heads/next $orgnext $newnext
 		refs/heads/pu $orgpu $newpu
-		refs/heads/nonexistent $_z40 $_z40
+		refs/heads/nonexistent $ZERO_OID $ZERO_OID
 		EOF
 
 		cat >post-receive.expect <<-EOF &&
diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh
index 207899a99f..3b0cb98422 100755
--- a/t/t5527-fetch-odd-refs.sh
+++ b/t/t5527-fetch-odd-refs.sh
@@ -27,7 +27,7 @@ test_expect_success 'suffix ref is ignored during fetch' '
 '
 
 test_expect_success 'try to create repo with absurdly long refname' '
-	ref240=$_z40/$_z40/$_z40/$_z40/$_z40/$_z40 &&
+	ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID &&
 	ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 &&
 	git init long &&
 	(
diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh
index ba975bb355..ac53d63869 100755
--- a/t/t5571-pre-push-hook.sh
+++ b/t/t5571-pre-push-hook.sh
@@ -78,8 +78,8 @@ test_expect_success 'push to default' '
 cat >expected <<EOF
 parent1
 repo1
-refs/tags/one $COMMIT1 refs/tags/tag1 $_z40
-HEAD~ $COMMIT2 refs/heads/prev $_z40
+refs/tags/one $COMMIT1 refs/tags/tag1 $ZERO_OID
+HEAD~ $COMMIT2 refs/heads/prev $ZERO_OID
 EOF
 
 test_expect_success 'push non-branches' '
@@ -90,7 +90,7 @@ test_expect_success 'push non-branches' '
 cat >expected <<EOF
 parent1
 repo1
-(delete) $_z40 refs/heads/prev $COMMIT2
+(delete) $ZERO_OID refs/heads/prev $COMMIT2
 EOF
 
 test_expect_success 'push delete' '
@@ -101,7 +101,7 @@ test_expect_success 'push delete' '
 cat >expected <<EOF
 repo1
 repo1
-HEAD $COMMIT3 refs/heads/other $_z40
+HEAD $COMMIT3 refs/heads/other $ZERO_OID
 EOF
 
 test_expect_success 'push to URL' '
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index bae78c4e89..84dd1cb690 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -383,7 +383,7 @@ test_expect_success 'describe complains about tree object' '
 '
 
 test_expect_success 'describe complains about missing object' '
-	test_must_fail git describe $_z40
+	test_must_fail git describe $ZERO_OID
 '
 
 test_done
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 295d1475bd..48379aa0ee 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -310,7 +310,7 @@ test_expect_success 'exercise strftime with odd fields' '
 	echo >expected &&
 	git for-each-ref --format="%(authordate:format:)" refs/heads >actual &&
 	test_cmp expected actual &&
-	long="long format -- $_z40$_z40$_z40$_z40$_z40$_z40$_z40" &&
+	long="long format -- $ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID$ZERO_OID" &&
 	echo $long >expected &&
 	git for-each-ref --format="%(authordate:format:$long)" refs/heads >actual &&
 	test_cmp expected actual
diff --git a/t/t6301-for-each-ref-errors.sh b/t/t6301-for-each-ref-errors.sh
index c734ce2388..49cc65bb58 100755
--- a/t/t6301-for-each-ref-errors.sh
+++ b/t/t6301-for-each-ref-errors.sh
@@ -4,7 +4,7 @@ test_description='for-each-ref errors for broken refs'
 
 . ./test-lib.sh
 
-ZEROS=$_z40
+ZEROS=$ZERO_OID
 MISSING=abababababababababababababababababababab
 
 test_expect_success setup '
diff --git a/t/t7009-filter-branch-null-sha1.sh b/t/t7009-filter-branch-null-sha1.sh
index a8d9ec4987..9ba9f24ad2 100755
--- a/t/t7009-filter-branch-null-sha1.sh
+++ b/t/t7009-filter-branch-null-sha1.sh
@@ -12,7 +12,7 @@ test_expect_success 'setup: base commits' '
 test_expect_success 'setup: a commit with a bogus null sha1 in the tree' '
 	{
 		git ls-tree HEAD &&
-		printf "160000 commit $_z40\\tbroken\\n"
+		printf "160000 commit $ZERO_OID\\tbroken\\n"
 	} >broken-tree &&
 	echo "add broken entry" >msg &&
 
diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh
index 84f41451ec..37525cae3a 100755
--- a/t/t7011-skip-worktree-reading.sh
+++ b/t/t7011-skip-worktree-reading.sh
@@ -118,7 +118,7 @@ test_expect_success 'grep with skip-worktree file' '
 	test "$(git grep --no-ext-grep test)" = "1:test"
 '
 
-echo ":000000 100644 $_z40 $EMPTY_BLOB A	1" > expected
+echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A	1" > expected
 test_expect_success 'diff-index does not examine skip-worktree absent entries' '
 	setup_absent &&
 	git diff-index HEAD -- 1 > result &&
diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh
index 8f795327a0..b9a86d3347 100755
--- a/t/t7064-wtstatus-pv2.sh
+++ b/t/t7064-wtstatus-pv2.sh
@@ -46,11 +46,11 @@ test_expect_success 'before initial commit, things added' '
 	cat >expect <<-EOF &&
 	# branch.oid (initial)
 	# branch.head master
-	1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a
-	1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b
-	1 A. N... 000000 100644 100644 $_z40 $OID_X file_x
-	1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y
-	1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_A dir1/file_a
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_B dir1/file_b
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_X file_x
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_Y file_y
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_Z file_z
 	? actual
 	? expect
 	EOF
@@ -63,11 +63,11 @@ test_expect_success 'before initial commit, things added (-z)' '
 	lf_to_nul >expect <<-EOF &&
 	# branch.oid (initial)
 	# branch.head master
-	1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a
-	1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b
-	1 A. N... 000000 100644 100644 $_z40 $OID_X file_x
-	1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y
-	1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_A dir1/file_a
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_B dir1/file_b
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_X file_x
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_Y file_y
+	1 A. N... 000000 100644 100644 $ZERO_OID $OID_Z file_z
 	? actual
 	? expect
 	EOF
@@ -128,7 +128,7 @@ test_expect_success 'after first commit, stage existing changes' '
 	# branch.oid $H0
 	# branch.head master
 	1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x
-	1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z
+	1 D. N... 100644 000000 000000 $OID_Z $ZERO_OID file_z
 	? actual
 	? expect
 	EOF
@@ -145,7 +145,7 @@ test_expect_success 'rename causes 2 path lines' '
 	# branch.oid $H0
 	# branch.head master
 	1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x
-	1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z
+	1 D. N... 100644 000000 000000 $OID_Z $ZERO_OID file_z
 	2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y
 	? actual
 	? expect
@@ -163,7 +163,7 @@ test_expect_success 'rename causes 2 path lines (-z)' '
 	# branch.oid $H0
 	# branch.head master
 	1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x
-	1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z
+	1 D. N... 100644 000000 000000 $OID_Z $ZERO_OID file_z
 	2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y
 	? actual
 	? expect
@@ -246,8 +246,8 @@ test_expect_success 'verify --intent-to-add output' '
 	git add --intent-to-add intent1.add intent2.add &&
 
 	cat >expect <<-EOF &&
-	1 .A N... 000000 000000 100644 $_z40 $_z40 intent1.add
-	1 .A N... 000000 000000 100644 $_z40 $_z40 intent2.add
+	1 .A N... 000000 000000 100644 $ZERO_OID $ZERO_OID intent1.add
+	1 .A N... 000000 000000 100644 $ZERO_OID $ZERO_OID intent2.add
 	EOF
 
 	git status --porcelain=v2 >actual &&
@@ -280,7 +280,7 @@ test_expect_success 'verify AA (add-add) conflict' '
 	cat >expect <<-EOF &&
 	# branch.oid $HM
 	# branch.head AA_M
-	u AA N... 000000 100644 100644 100644 $_z40 $OID_AA_B $OID_AA_A conflict.txt
+	u AA N... 000000 100644 100644 100644 $ZERO_OID $OID_AA_B $OID_AA_A conflict.txt
 	EOF
 
 	git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -373,7 +373,7 @@ test_expect_success 'verify upstream fields in branch header' '
 		## Test upstream-gone case. Fake this by pointing origin/master at
 		## a non-existing commit.
 		OLD=$(git rev-parse origin/master) &&
-		NEW=$_z40 &&
+		NEW=$ZERO_OID &&
 		mv .git/packed-refs .git/old-packed-refs &&
 		sed "s/$OLD/$NEW/g" <.git/old-packed-refs >.git/packed-refs &&
 
@@ -469,8 +469,8 @@ test_expect_success 'create and add submodule, submodule appears clean (A. S...)
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 A. S... 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -494,8 +494,8 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 AM S..U 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -519,8 +519,8 @@ test_expect_success 'staged changes in added submodule (AM S.M.)' '
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -546,8 +546,8 @@ test_expect_success 'staged and unstaged changes in added (AM S.M.)' '
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -573,8 +573,8 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 AM S.MU 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&
@@ -600,8 +600,8 @@ test_expect_success 'commit within the submodule appears as new commit in super
 		# branch.head master
 		# branch.upstream origin/master
 		# branch.ab +0 -0
-		1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules
-		1 AM SC.. 000000 160000 160000 $_z40 $HSUB sub1
+		1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules
+		1 AM SC.. 000000 160000 160000 $ZERO_OID $HSUB sub1
 		EOF
 
 		git status --porcelain=v2 --branch --untracked-files=all >actual &&

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 04/28] t/test-lib: introduce OID_REGEX
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (2 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 03/28] t: switch $_z40 to $ZERO_OID brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 05/28] t: switch $_x40 to $OID_REGEX brian m. carlson
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Currently we have a variable, $_x40, which contains a regex that matches
a full 40-character hex constant.  However, with NewHash, we'll have
object IDs that are longer than 40 characters.  In such a case, $_x40
will be a confusing name.  Create a $OID_REGEX variable which will
always reflect a regex matching the appropriate object ID, regardless of
the length of the current hash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/test-lib.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 58c2ea52c6..fed21c3dfc 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -184,6 +184,7 @@ _x40="$_x35$_x05"
 # Zero SHA-1
 _z40=0000000000000000000000000000000000000000
 
+OID_REGEX="$_x40"
 ZERO_OID=$_z40
 EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
 EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
@@ -196,7 +197,7 @@ LF='
 # when case-folding filenames
 u200c=$(printf '\342\200\214')
 
-export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID
+export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX
 
 # Each test should start with something like this, after copyright notices:
 #

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 05/28] t: switch $_x40 to $OID_REGEX
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (3 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 04/28] t/test-lib: introduce OID_REGEX brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 06/28] t0000: annotate with SHA1 prerequisite brian m. carlson
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Switch all uses of $_x40 to $OID_REGEX so that they work correctly with
larger hashes.  This commit was created by using the following sed
command to modify all files in the t directory except t/test-lib.sh:

  sed -i 's/\$_x40/$OID_REGEX/g'

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/diff-lib.sh                   |  4 ++--
 t/t0090-cache-tree.sh           |  2 +-
 t/t1000-read-tree-m-3way.sh     |  2 +-
 t/t1001-read-tree-m-2way.sh     |  2 +-
 t/t1002-read-tree-m-u-2way.sh   |  2 +-
 t/t1012-read-tree-df.sh         |  2 +-
 t/t3100-ls-tree-restrict.sh     |  2 +-
 t/t3101-ls-tree-dirname.sh      |  2 +-
 t/t3510-cherry-pick-sequence.sh |  8 ++++----
 t/t4002-diff-basic.sh           |  2 +-
 t/t4006-diff-mode.sh            |  2 +-
 t/t4014-format-patch.sh         |  2 +-
 t/t4201-shortlog.sh             |  2 +-
 t/t5150-request-pull.sh         |  2 +-
 t/t6006-rev-list-format.sh      |  4 ++--
 t/t6012-rev-list-simplify.sh    |  2 +-
 t/t6111-rev-list-treesame.sh    |  2 +-
 t/t7506-status-submodule.sh     |  2 +-
 t/t9010-svn-fe.sh               | 14 +++++++-------
 t/t9300-fast-import.sh          |  6 +++---
 20 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/t/diff-lib.sh b/t/diff-lib.sh
index c211dc40ee..2de880f7a5 100644
--- a/t/diff-lib.sh
+++ b/t/diff-lib.sh
@@ -1,6 +1,6 @@
 :
 
-sanitize_diff_raw='/^:/s/ '"\($_x40\)"' '"\($_x40\)"' \([A-Z]\)[0-9]*	/ \1 \2 \3#	/'
+sanitize_diff_raw='/^:/s/ '"\($OID_REGEX\)"' '"\($OID_REGEX\)"' \([A-Z]\)[0-9]*	/ \1 \2 \3#	/'
 compare_diff_raw () {
     # When heuristics are improved, the score numbers would change.
     # Ignore them while comparing.
@@ -12,7 +12,7 @@ compare_diff_raw () {
     test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
 }
 
-sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
+sanitize_diff_raw_z='/^:/s/ '"$OID_REGEX"' '"$OID_REGEX"' \([A-Z]\)[0-9]*$/ X X \1#/'
 compare_diff_raw_z () {
     # When heuristics are improved, the score numbers would change.
     # Ignore them while comparing.
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index 4ae0995cd9..0c61268fd2 100755
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
@@ -9,7 +9,7 @@ cache-tree extension.
 
 cmp_cache_tree () {
 	test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual &&
-	sed "s/$_x40/SHA/" <actual >filtered &&
+	sed "s/$OID_REGEX/SHA/" <actual >filtered &&
 	test_cmp "$1" filtered
 }
 
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
index 3c4d2d6045..013c5a7bc3 100755
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -128,7 +128,7 @@ cat >expected <<\EOF
 EOF
 
 check_result () {
-	git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
+	git ls-files --stage | sed -e 's/ '"$OID_REGEX"' / X /' >current &&
 	test_cmp expected current
 }
 
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 5ededd8e40..1057a96b24 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -30,7 +30,7 @@ read_tree_twoway () {
 compare_change () {
 	sed -n >current \
 	    -e '/^--- /d; /^+++ /d; /^@@ /d;' \
-	    -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
+	    -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$OID_REGEX"' /\1 X /p' \
 	    "$1"
 	test_cmp expected current
 }
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index 7ca2e65d10..9c05f5e1f5 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -16,7 +16,7 @@ compare_change () {
 	    -e '1{/^diff --git /d;}' \
 	    -e '2{/^index /d;}' \
 	    -e '/^--- /d; /^+++ /d; /^@@ /d;' \
-	    -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
+	    -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$OID_REGEX"' /\1 X /' "$1"
 	test_cmp expected current
 }
 
diff --git a/t/t1012-read-tree-df.sh b/t/t1012-read-tree-df.sh
index a6a04b6b90..57f0770df1 100755
--- a/t/t1012-read-tree-df.sh
+++ b/t/t1012-read-tree-df.sh
@@ -32,7 +32,7 @@ settree () {
 
 checkindex () {
 	git ls-files -s |
-	sed "s|^[0-7][0-7]* $_x40 \([0-3]\)	|\1 |" >current &&
+	sed "s|^[0-7][0-7]* $OID_REGEX \([0-3]\)	|\1 |" >current &&
 	cat >expect &&
 	test_cmp expect current
 }
diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh
index 325114f8fe..18baf49a49 100755
--- a/t/t3100-ls-tree-restrict.sh
+++ b/t/t3100-ls-tree-restrict.sh
@@ -32,7 +32,7 @@ test_expect_success \
      echo $tree'
 
 test_output () {
-    sed -e "s/ $_x40	/ X	/" <current >check
+    sed -e "s/ $OID_REGEX	/ X	/" <current >check
     test_cmp expected check
 }
 
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 327ded4000..12bf31022a 100755
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -40,7 +40,7 @@ test_expect_success 'setup' '
 '
 
 test_output () {
-	sed -e "s/ $_x40	/ X	/" <current >check &&
+	sed -e "s/ $OID_REGEX	/ X	/" <current >check &&
 	test_cmp expected check
 }
 
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index 21b4f194a2..b42cd66d3a 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -122,7 +122,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	test_cmp expect actual
 '
@@ -220,7 +220,7 @@ test_expect_success 'cherry-pick still writes sequencer state when one commit is
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	cat >expect <<-\EOF &&
 	OBJID
@@ -317,7 +317,7 @@ test_expect_success '--continue after resolving conflicts' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual.log &&
 	test_cmp expect foo &&
 	test_cmp expect.log actual.log
@@ -334,7 +334,7 @@ test_expect_success '--continue after resolving conflicts and committing' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	cat >expect <<-\EOF &&
 	OBJID
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 5af773d6f7..3a6c21e825 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -131,7 +131,7 @@ cmp_diff_files_output () {
     # object ID for the changed files because it wants you to look at the
     # filesystem.
     sed <"$2" >.test-tmp \
-	-e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
+	-e '/^:000000 /d;s/'$OID_REGEX'\( [MCRNDU][0-9]*\)	/'$ZERO_OID'\1	/' &&
     test_cmp "$1" .test-tmp
 }
 
diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh
index 76f643b2c2..a8e01eccd1 100755
--- a/t/t4006-diff-mode.sh
+++ b/t/t4006-diff-mode.sh
@@ -8,7 +8,7 @@ test_description='Test mode change diffs.
 '
 . ./test-lib.sh
 
-sed_script='s/\(:100644 100755\) \('"$_x40"'\) \2 /\1 X X /'
+sed_script='s/\(:100644 100755\) \('"$OID_REGEX"'\) \2 /\1 X X /'
 
 test_expect_success 'setup' '
 	echo frotz >rezrov &&
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 0dbf7d5b4b..dac3f349a3 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1530,7 +1530,7 @@ test_expect_success 'format-patch --zero-commit' '
 test_expect_success 'From line has expected format' '
 	git format-patch --stdout v2..v1 >patch2 &&
 	grep "^From " patch2 >from &&
-	grep "^From $_x40 Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
+	grep "^From $OID_REGEX Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
 	test_cmp from filtered
 '
 
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index ff6649ed9a..58c2773676 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -59,7 +59,7 @@ test_expect_success 'setup' '
 fuzz() {
 	file=$1 &&
 	sed "
-			s/$_x40/OBJECT_NAME/g
+			s/$OID_REGEX/OBJECT_NAME/g
 			s/$_x35/OBJID/g
 			s/^ \{6\}[CTa].*/      SUBJECT/g
 			s/^ \{8\}[^ ].*/        CONTINUATION/g
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index 08c210f035..fca001eb9b 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -81,7 +81,7 @@ test_expect_success 'setup: two scripts for reading pull requests' '
 	cat <<-EOT >fuzz.sed
 	#!/bin/sed -nf
 	s/$downstream_url_for_sed/URL/g
-	s/$_x40/OBJECT_NAME/g
+	s/$OID_REGEX/OBJECT_NAME/g
 	s/A U Thor/AUTHOR/g
 	s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
 	s/        [^ ].*/        SUBJECT/g
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 98be78b4a2..ec42c2f779 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -447,8 +447,8 @@ test_expect_success '--abbrev' '
 	git log -1 --format="%h %h %h" HEAD >actual1 &&
 	git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 &&
 	git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 &&
-	sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
-	sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
+	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual2 >fuzzy2 &&
+	sed -e "s/$OID_REGEX/LONG/g" -e "s/$_x05/SHORT/g" <actual3 >fuzzy3 &&
 	test_cmp expect2 fuzzy2 &&
 	test_cmp expect3 fuzzy3 &&
 	! test_cmp actual1 actual2
diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
index 2a0fbb87b1..b5a1190ffe 100755
--- a/t/t6012-rev-list-simplify.sh
+++ b/t/t6012-rev-list-simplify.sh
@@ -9,7 +9,7 @@ note () {
 }
 
 unnote () {
-	git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
+	git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g"
 }
 
 test_expect_success setup '
diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh
index 32474c23d3..4244638285 100755
--- a/t/t6111-rev-list-treesame.sh
+++ b/t/t6111-rev-list-treesame.sh
@@ -20,7 +20,7 @@ note () {
 }
 
 unnote () {
-	git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\))\([ 	]\)|\1\2|g"
+	git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ 	]\)|\1\2|g"
 }
 
 test_expect_success setup '
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
index 9edf6572ed..b4b74dbe29 100755
--- a/t/t7506-status-submodule.sh
+++ b/t/t7506-status-submodule.sh
@@ -18,7 +18,7 @@ test_create_repo_with_commit () {
 }
 
 sanitize_output () {
-	sed -e "s/$_x40/HASH/" -e "s/$_x40/HASH/" output >output2 &&
+	sed -e "s/$OID_REGEX/HASH/" -e "s/$OID_REGEX/HASH/" output >output2 &&
 	mv output2 output
 }
 
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index 8eaaca6f99..0b20b07e68 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -473,7 +473,7 @@ test_expect_failure 'change file mode but keep old content' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	git show HEAD:greeting >actual.blob &&
 	git show HEAD^:greeting >actual.target &&
@@ -573,7 +573,7 @@ test_expect_success 'NUL in log message, file content, and property name' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	{
 		git cat-file commit HEAD | nul_to_q &&
@@ -659,7 +659,7 @@ test_expect_success 'change file mode and reiterate content' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	git show HEAD:greeting >actual.blob &&
 	git show HEAD^:greeting >actual.target &&
@@ -792,7 +792,7 @@ test_expect_success 'property deltas supported' '
 	{
 		git rev-list HEAD |
 		git diff-tree --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	test_cmp expect actual
 '
@@ -846,7 +846,7 @@ test_expect_success 'properties on /' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --always --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	test_cmp expect actual
 '
@@ -931,7 +931,7 @@ test_expect_success 'deltas for typechange' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	test_cmp expect actual
 '
@@ -1030,7 +1030,7 @@ test_expect_success 'deltas need not consume the whole preimage' '
 	{
 		git rev-list HEAD |
 		git diff-tree --root --stdin |
-		sed "s/$_x40/OBJID/g"
+		sed "s/$OID_REGEX/OBJID/g"
 	} >actual &&
 	test_cmp expect actual &&
 	git show HEAD:postimage >actual.3 &&
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index dc79df7b04..9e7f96223d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1185,7 +1185,7 @@ test_expect_success PIPE 'N: empty directory reads as missing' '
 	test_cmp expect.response response &&
 	git rev-list read-empty |
 	git diff-tree -r --root --stdin |
-	sed "s/$_x40/OBJNAME/g" >actual &&
+	sed "s/$OID_REGEX/OBJNAME/g" >actual &&
 	test_cmp expect actual
 '
 
@@ -1271,7 +1271,7 @@ test_expect_success 'N: delete directory by copying' '
 	git fast-import <input &&
 	git rev-list N-delete |
 		git diff-tree -r --stdin --root --always |
-		sed -e "s/$_x40/OBJID/g" >actual &&
+		sed -e "s/$OID_REGEX/OBJID/g" >actual &&
 	test_cmp expect actual
 '
 
@@ -2602,7 +2602,7 @@ test_expect_success 'R: terminating "done" within commit' '
 	EOF
 	git rev-list done-ends |
 	git diff-tree -r --stdin --root --always |
-	sed -e "s/$_x40/OBJID/g" >actual &&
+	sed -e "s/$OID_REGEX/OBJID/g" >actual &&
 	test_cmp expect actual
 '
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 06/28] t0000: annotate with SHA1 prerequisite
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (4 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 05/28] t: switch $_x40 to $OID_REGEX brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 07/28] t1007: " brian m. carlson
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Since this is a core test that tests basic functionality, annotate the
assertions that have dependencies on SHA-1 with the appropriate
prerequisite.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t0000-basic.sh | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 7fd87dd544..af61d083b4 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -839,7 +839,7 @@ test_expect_success 'writing tree out with git write-tree' '
 '
 
 # we know the shape and contents of the tree and know the object ID for it.
-test_expect_success 'validate object ID of a known tree' '
+test_expect_success SHA1 'validate object ID of a known tree' '
 	test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a
     '
 
@@ -882,7 +882,7 @@ test_expect_success 'showing stage with git ls-files --stage' '
 	git ls-files --stage >current
 '
 
-test_expect_success 'validate git ls-files output for a known tree' '
+test_expect_success SHA1 'validate git ls-files output for a known tree' '
 	cat >expected <<-\EOF &&
 	100644 f87290f8eb2cbbea7857214459a0739927eab154 0	path0
 	120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0	path0sym
@@ -900,7 +900,7 @@ test_expect_success 'writing tree out with git write-tree' '
 	tree=$(git write-tree)
 '
 
-test_expect_success 'validate object ID for a known tree' '
+test_expect_success SHA1 'validate object ID for a known tree' '
 	test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b
 '
 
@@ -908,7 +908,7 @@ test_expect_success 'showing tree with git ls-tree' '
     git ls-tree $tree >current
 '
 
-test_expect_success 'git ls-tree output for a known tree' '
+test_expect_success SHA1 'git ls-tree output for a known tree' '
 	cat >expected <<-\EOF &&
 	100644 blob f87290f8eb2cbbea7857214459a0739927eab154	path0
 	120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
@@ -924,7 +924,7 @@ test_expect_success 'showing tree with git ls-tree -r' '
 	git ls-tree -r $tree >current
 '
 
-test_expect_success 'git ls-tree -r output for a known tree' '
+test_expect_success SHA1 'git ls-tree -r output for a known tree' '
 	cat >expected <<-\EOF &&
 	100644 blob f87290f8eb2cbbea7857214459a0739927eab154	path0
 	120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
@@ -943,7 +943,7 @@ test_expect_success 'showing tree with git ls-tree -r -t' '
 	git ls-tree -r -t $tree >current
 '
 
-test_expect_success 'git ls-tree -r output for a known tree' '
+test_expect_success SHA1 'git ls-tree -r output for a known tree' '
 	cat >expected <<-\EOF &&
 	100644 blob f87290f8eb2cbbea7857214459a0739927eab154	path0
 	120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
@@ -964,7 +964,7 @@ test_expect_success 'writing partial tree out with git write-tree --prefix' '
 	ptree=$(git write-tree --prefix=path3)
 '
 
-test_expect_success 'validate object ID for a known tree' '
+test_expect_success SHA1 'validate object ID for a known tree' '
 	test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3
 '
 
@@ -972,7 +972,7 @@ test_expect_success 'writing partial tree out with git write-tree --prefix' '
 	ptree=$(git write-tree --prefix=path3/subp3)
 '
 
-test_expect_success 'validate object ID for a known tree' '
+test_expect_success SHA1 'validate object ID for a known tree' '
 	test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2
 '
 
@@ -1006,7 +1006,7 @@ test_expect_success 'git read-tree followed by write-tree should be idempotent'
 	test "$newtree" = "$tree"
 '
 
-test_expect_success 'validate git diff-files output for a know cache/work tree state' '
+test_expect_success SHA1 'validate git diff-files output for a know cache/work tree state' '
 	cat >expected <<\EOF &&
 :100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M	path0
 :120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M	path0sym
@@ -1033,21 +1033,21 @@ test_expect_success 'no diff after checkout and git update-index --refresh' '
 ################################################################
 P=087704a96baf1c2d1c869a8b084481e121c88b5b
 
-test_expect_success 'git commit-tree records the correct tree in a commit' '
+test_expect_success SHA1 'git commit-tree records the correct tree in a commit' '
 	commit0=$(echo NO | git commit-tree $P) &&
 	tree=$(git show --pretty=raw $commit0 |
 		 sed -n -e "s/^tree //p" -e "/^author /q") &&
 	test "z$tree" = "z$P"
 '
 
-test_expect_success 'git commit-tree records the correct parent in a commit' '
+test_expect_success SHA1 'git commit-tree records the correct parent in a commit' '
 	commit1=$(echo NO | git commit-tree $P -p $commit0) &&
 	parent=$(git show --pretty=raw $commit1 |
 		sed -n -e "s/^parent //p" -e "/^author /q") &&
 	test "z$commit0" = "z$parent"
 '
 
-test_expect_success 'git commit-tree omits duplicated parent in a commit' '
+test_expect_success SHA1 'git commit-tree omits duplicated parent in a commit' '
 	commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
 	     parent=$(git show --pretty=raw $commit2 |
 		sed -n -e "s/^parent //p" -e "/^author /q" |

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 07/28] t1007: annotate with SHA1 prerequisite
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (5 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 06/28] t0000: annotate with SHA1 prerequisite brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 08/28] t1512: skip test if not using SHA-1 brian m. carlson
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Since this is a core test that tests basic functionality, annotate the
assertions that have dependencies on SHA-1 with the appropriate
prerequisite.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t1007-hash-object.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index 532682f51c..a37753047e 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -9,13 +9,13 @@ echo_without_newline() {
 }
 
 test_blob_does_not_exist() {
-	test_expect_success 'blob does not exist in database' "
+	test_expect_success SHA1 'blob does not exist in database' "
 		test_must_fail git cat-file blob $1
 	"
 }
 
 test_blob_exists() {
-	test_expect_success 'blob exists in database' "
+	test_expect_success SHA1 'blob exists in database' "
 		git cat-file blob $1
 	"
 }
@@ -73,19 +73,19 @@ test_expect_success "Can't use --path with --no-filters" '
 
 push_repo
 
-test_expect_success 'hash a file' '
+test_expect_success SHA1 'hash a file' '
 	test $hello_sha1 = $(git hash-object hello)
 '
 
 test_blob_does_not_exist $hello_sha1
 
-test_expect_success 'hash from stdin' '
+test_expect_success SHA1 'hash from stdin' '
 	test $example_sha1 = $(git hash-object --stdin < example)
 '
 
 test_blob_does_not_exist $example_sha1
 
-test_expect_success 'hash a file and write to database' '
+test_expect_success SHA1 'hash a file and write to database' '
 	test $hello_sha1 = $(git hash-object -w hello)
 '
 
@@ -161,7 +161,7 @@ pop_repo
 for args in "-w --stdin" "--stdin -w"; do
 	push_repo
 
-	test_expect_success "hash from stdin and write to database ($args)" '
+	test_expect_success SHA1 "hash from stdin and write to database ($args)" '
 		test $example_sha1 = $(git hash-object $args < example)
 	'
 
@@ -176,14 +176,14 @@ example"
 sha1s="$hello_sha1
 $example_sha1"
 
-test_expect_success "hash two files with names on stdin" '
+test_expect_success SHA1 "hash two files with names on stdin" '
 	test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
 '
 
 for args in "-w --stdin-paths" "--stdin-paths -w"; do
 	push_repo
 
-	test_expect_success "hash two files with names on stdin and write to database ($args)" '
+	test_expect_success SHA1 "hash two files with names on stdin and write to database ($args)" '
 		test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object $args)"
 	'
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 08/28] t1512: skip test if not using SHA-1
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (6 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 07/28] t1007: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 09/28] t4044: " brian m. carlson
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

This test relies on objects with colliding short names which are
necessarily dependent on the hash used.  Skip the test if we're not
using SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t1512-rev-parse-disambiguation.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 711704ba5a..6537f30c9e 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -22,6 +22,12 @@ one tagged as v1.0.0.  They all have one regular file each.
 
 . ./test-lib.sh
 
+if ! test_have_prereq SHA1
+then
+	skip_all='not using SHA-1 for objects'
+	test_done
+fi
+
 test_expect_success 'blob and tree' '
 	test_tick &&
 	(

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 09/28] t4044: skip test if not using SHA-1
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (7 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 08/28] t1512: skip test if not using SHA-1 brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 10/28] t: skip pack tests " brian m. carlson
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

This test relies on objects with colliding short names which are
necessarily dependent on the hash used.  Skip the test if we're not
using SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4044-diff-index-unique-abbrev.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/t4044-diff-index-unique-abbrev.sh b/t/t4044-diff-index-unique-abbrev.sh
index d5ce72be63..647905e01f 100755
--- a/t/t4044-diff-index-unique-abbrev.sh
+++ b/t/t4044-diff-index-unique-abbrev.sh
@@ -3,6 +3,12 @@
 test_description='test unique sha1 abbreviation on "index from..to" line'
 . ./test-lib.sh
 
+if ! test_have_prereq SHA1
+then
+       skip_all='not using SHA-1 for objects'
+       test_done
+fi
+
 cat >expect_initial <<EOF
 100644 blob 51d2738463ea4ca66f8691c91e33ce64b7d41bb1	foo
 EOF

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 10/28] t: skip pack tests if not using SHA-1
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (8 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 09/28] t4044: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 11/28] t2203: abstract away SHA-1-specific constants brian m. carlson
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

These tests rely on creating packs with specially named objects which
are necessarily dependent on the hash used.  Skip these tests if we're
not using SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t5308-pack-detect-duplicates.sh | 6 ++++++
 t/t5309-pack-delta-cycles.sh      | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/t/t5308-pack-detect-duplicates.sh b/t/t5308-pack-detect-duplicates.sh
index 156ae9e9d3..6845c1f3c3 100755
--- a/t/t5308-pack-detect-duplicates.sh
+++ b/t/t5308-pack-detect-duplicates.sh
@@ -4,6 +4,12 @@ test_description='handling of duplicate objects in incoming packfiles'
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-pack.sh
 
+if ! test_have_prereq SHA1
+then
+       skip_all='not using SHA-1 for objects'
+       test_done
+fi
+
 # The sha1s we have in our pack. It's important that these have the same
 # starting byte, so that they end up in the same fanout section of the index.
 # That lets us make sure we are exercising the binary search with both sets.
diff --git a/t/t5309-pack-delta-cycles.sh b/t/t5309-pack-delta-cycles.sh
index 3e7861b075..491556dad9 100755
--- a/t/t5309-pack-delta-cycles.sh
+++ b/t/t5309-pack-delta-cycles.sh
@@ -4,6 +4,12 @@ test_description='test index-pack handling of delta cycles in packfiles'
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-pack.sh
 
+if ! test_have_prereq SHA1
+then
+       skip_all='not using SHA-1 for objects'
+       test_done
+fi
+
 # Two similar-ish objects that we have computed deltas between.
 A=01d7713666f4de822776c7622c10f1b07de280dc
 B=e68fe8129b546b101aee9510c5328e7f21ca1d18

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 11/28] t2203: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (9 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 10/28] t: skip pack tests " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 12/28] t3103: " brian m. carlson
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t2203-add-intent.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 1797f946b9..04d840a544 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -27,8 +27,8 @@ test_expect_success 'git status' '
 
 test_expect_success 'git status with porcelain v2' '
 	git status --porcelain=v2 | grep -v "^?" >actual &&
-	nam1=d00491fd7e5bb6fa28c517a0bb32b8b506539d4d &&
-	nam2=ce013625030ba8dba906f756967f9e9ca394464a &&
+	nam1=$(echo 1 | git hash-object --stdin) &&
+	nam2=$(git hash-object elif) &&
 	cat >expect <<-EOF &&
 	1 DA N... 100644 000000 100644 $nam1 $ZERO_OID 1.t
 	1 A. N... 000000 100644 100644 $ZERO_OID $nam2 elif
@@ -181,7 +181,7 @@ test_expect_success 'rename detection finds the right names' '
 		EOF
 		test_cmp expected.2 actual.2 &&
 
-		hash=12f00e90b6ef79117ce6e650416b8cf517099b78 &&
+		hash=$(git hash-object third) &&
 		git status --porcelain=v2 | grep -v "^?" >actual.3 &&
 		cat >expected.3 <<-EOF &&
 		2 .R N... 100644 100644 100644 $hash $hash R100 third	first
@@ -212,7 +212,7 @@ test_expect_success 'double rename detection in status' '
 		EOF
 		test_cmp expected.2 actual.2 &&
 
-		hash=12f00e90b6ef79117ce6e650416b8cf517099b78 &&
+		hash=$(git hash-object third) &&
 		git status --porcelain=v2 | grep -v "^?" >actual.3 &&
 		cat >expected.3 <<-EOF &&
 		2 R. N... 100644 100644 100644 $hash $hash R100 second	first

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 12/28] t3103: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (10 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 11/28] t2203: abstract away SHA-1-specific constants brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 13/28] t3702: " brian m. carlson
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it uses variables and command substitution for
trees instead of hard-coded hashes.  This also has the benefit of making
it more obvious how the test works.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t3103-ls-tree-misc.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/t3103-ls-tree-misc.sh b/t/t3103-ls-tree-misc.sh
index 09dcf043fd..14520913af 100755
--- a/t/t3103-ls-tree-misc.sh
+++ b/t/t3103-ls-tree-misc.sh
@@ -17,7 +17,8 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'ls-tree fails with non-zero exit code on broken tree' '
-	rm -f .git/objects/5f/cffbd6e4c5c5b8d81f5e9314b20e338e3ffff5 &&
+	tree=$(git rev-parse HEAD:a) &&
+	rm -f .git/objects/$(echo $tree | sed -e "s,^\(..\),\1/,") &&
 	test_must_fail git ls-tree -r HEAD
 '
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 13/28] t3702: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (11 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 12/28] t3103: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 14/28] t3905: " brian m. carlson
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Strip out the index lines in the diff before comparing them, as these
will differ between hash algorithms.  This leads to a smaller, simpler
change than editing the index line.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t3702-add-edit.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh
index 3cb74ca296..1be5cd5756 100755
--- a/t/t3702-add-edit.sh
+++ b/t/t3702-add-edit.sh
@@ -40,7 +40,6 @@ test_expect_success 'setup' '
 
 cat > expected-patch << EOF
 diff --git a/file b/file
-index b9834b5..9020acb 100644
 --- a/file
 +++ b/file
 @@ -1,11 +1,6 @@
@@ -80,7 +79,6 @@ EOF
 
 cat > expected << EOF
 diff --git a/file b/file
-index b9834b5..ef6e94c 100644
 --- a/file
 +++ b/file
 @@ -1,10 +1,12 @@
@@ -100,7 +98,7 @@ EOF
 
 echo "#!$SHELL_PATH" >fake-editor.sh
 cat >> fake-editor.sh <<\EOF
-mv -f "$1" orig-patch &&
+egrep -v '^index' "$1" >orig-patch &&
 mv -f patch "$1"
 EOF
 
@@ -113,7 +111,8 @@ test_expect_success 'add -e' '
 	git add -e &&
 	test_cmp second-part file &&
 	test_cmp orig-patch expected-patch &&
-	git diff --cached > out &&
+	git diff --cached >actual &&
+	egrep -v "^index " actual >out &&
 	test_cmp out expected
 
 '

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 14/28] t3905: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (12 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 13/28] t3702: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 15/28] t4007: " brian m. carlson
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t3905-stash-include-untracked.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 3ea5b9bb3f..597b0637d1 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -35,24 +35,26 @@ test_expect_success 'stash save --include-untracked cleaned the untracked files'
 	test_cmp expect actual
 '
 
+tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin))
+untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin))
 cat > expect.diff <<EOF
 diff --git a/HEAD b/HEAD
 new file mode 100644
-index 0000000..d00491f
+index 0000000..$tracked
 --- /dev/null
 +++ b/HEAD
 @@ -0,0 +1 @@
 +1
 diff --git a/file2 b/file2
 new file mode 100644
-index 0000000..d00491f
+index 0000000..$tracked
 --- /dev/null
 +++ b/file2
 @@ -0,0 +1 @@
 +1
 diff --git a/untracked/untracked b/untracked/untracked
 new file mode 100644
-index 0000000..5a72eb2
+index 0000000..$untracked
 --- /dev/null
 +++ b/untracked/untracked
 @@ -0,0 +1 @@
@@ -109,10 +111,11 @@ test_expect_success 'stash save -u dirty index' '
 	git stash -u
 '
 
+blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin))
 cat > expect <<EOF
 diff --git a/file3 b/file3
 new file mode 100644
-index 0000000..b8626c4
+index 0000000..$blob
 --- /dev/null
 +++ b/file3
 @@ -0,0 +1 @@

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 15/28] t4007: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (13 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 14/28] t3905: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 16/28] t4008: " brian m. carlson
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs and uses the
ZERO_OID variable instead of using hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4007-rename-3.sh | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh
index dae327fabb..b187b7f6c6 100755
--- a/t/t4007-rename-3.sh
+++ b/t/t4007-rename-3.sh
@@ -17,6 +17,7 @@ test_expect_success 'prepare reference tree' '
 	echo $tree
 '
 
+blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING")
 test_expect_success 'prepare work tree' '
 	cp path0/COPYING path1/COPYING &&
 	git update-index --add --remove path0/COPYING path1/COPYING
@@ -26,8 +27,8 @@ test_expect_success 'prepare work tree' '
 # path1 both have COPYING and the latter is a copy of path0/COPYING.
 # Comparing the full tree with cache should tell us so.
 
-cat >expected <<\EOF
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100	path0/COPYING	path1/COPYING
+cat >expected <<EOF
+:100644 100644 $blob $blob C100	path0/COPYING	path1/COPYING
 EOF
 
 test_expect_success 'copy detection' '
@@ -46,8 +47,8 @@ test_expect_success 'copy detection, cached' '
 # path1/COPYING suddenly appearing from nowhere, not detected as
 # a copy from path0/COPYING.
 
-cat >expected <<\EOF
-:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A	path1/COPYING
+cat >expected <<EOF
+:000000 100644 $ZERO_OID $blob A	path1/COPYING
 EOF
 
 test_expect_success 'copy, limited to a subtree' '
@@ -64,8 +65,8 @@ test_expect_success 'tweak work tree' '
 # path0/COPYING.  Showing the full tree with cache should tell us about
 # the rename.
 
-cat >expected <<\EOF
-:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100	path0/COPYING	path1/COPYING
+cat >expected <<EOF
+:100644 100644 $blob $blob R100	path0/COPYING	path1/COPYING
 EOF
 
 test_expect_success 'rename detection' '
@@ -78,8 +79,8 @@ test_expect_success 'rename detection' '
 # path0/COPYING.  When we say we care only about path1, we should just
 # see path1/COPYING appearing from nowhere.
 
-cat >expected <<\EOF
-:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A	path1/COPYING
+cat >expected <<EOF
+:000000 100644 $ZERO_OID $blob A	path1/COPYING
 EOF
 
 test_expect_success 'rename, limited to a subtree' '

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 16/28] t4008: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (14 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 15/28] t4007: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 17/28] t4014: " brian m. carlson
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4008-diff-break-rewrite.sh | 59 +++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 27 deletions(-)

diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh
index 9dd1bc5e16..b1ccd4102e 100755
--- a/t/t4008-diff-break-rewrite.sh
+++ b/t/t4008-diff-break-rewrite.sh
@@ -27,29 +27,32 @@ Further, with -B and -M together, these should turn into two renames.
 test_expect_success setup '
 	cat "$TEST_DIRECTORY"/diff-lib/README >file0 &&
 	cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 &&
+	blob0_id=$(git hash-object file0) &&
+	blob1_id=$(git hash-object file1) &&
 	git update-index --add file0 file1 &&
 	git tag reference $(git write-tree)
 '
 
 test_expect_success 'change file1 with copy-edit of file0 and remove file0' '
 	sed -e "s/git/GIT/" file0 >file1 &&
+	blob2_id=$(git hash-object file1) &&
 	rm -f file0 &&
 	git update-index --remove file0 file1
 '
 
 test_expect_success 'run diff with -B (#1)' '
 	git diff-index -B --cached reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100	file1
+	cat >expect <<-EOF &&
+	:100644 000000 $blob0_id $ZERO_OID D	file0
+	:100644 100644 $blob1_id $blob2_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B and -M (#2)' '
 	git diff-index -B -M reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec R100	file0	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob2_id R100	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -66,18 +69,18 @@ test_expect_success 'swap file0 and file1' '
 
 test_expect_success 'run diff with -B (#3)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob1_id M100	file0
+	:100644 100644 $blob1_id $blob0_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B and -M (#4)' '
 	git diff-index -B -M reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100	file1	file0
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 R100	file0	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob1_id $blob1_id R100	file1	file0
+	:100644 100644 $blob0_id $blob0_id R100	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -85,14 +88,15 @@ test_expect_success 'run diff with -B and -M (#4)' '
 test_expect_success 'make file0 into something completely different' '
 	rm -f file0 &&
 	test_ln_s_add frotz file0 &&
+	slink_id=$(printf frotz | git hash-object --stdin) &&
 	git update-index file1
 '
 
 test_expect_success 'run diff with -B (#5)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob1_id $blob0_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -103,9 +107,9 @@ test_expect_success 'run diff with -B -M (#6)' '
 	# file0 changed from regular to symlink.  file1 is the same as the preimage
 	# of file0.  Because the change does not make file0 disappear, file1 is
 	# denoted as a copy of file0
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 C	file0	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob0_id $blob0_id C	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -115,9 +119,9 @@ test_expect_success 'run diff with -M (#7)' '
 
 	# This should not mistake file0 as the copy source of new file1
 	# due to type differences.
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob1_id $blob0_id M	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -128,25 +132,26 @@ test_expect_success 'file1 edited to look like file0 and file0 rename-edited to
 	git checkout-index -f -u -a &&
 	sed -e "s/git/GIT/" file0 >file1 &&
 	sed -e "s/git/GET/" file0 >file2 &&
+	blob3_id=$(git hash-object file2) &&
 	rm -f file0 &&
 	git update-index --add --remove file0 file1 file2
 '
 
 test_expect_success 'run diff with -B (#8)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100	file1
-	:000000 100644 0000000000000000000000000000000000000000 69a939f651686f56322566e2fd76715947a24162 A	file2
+	cat >expect <<-EOF &&
+	:100644 000000 $blob0_id $ZERO_OID D	file0
+	:100644 100644 $blob1_id $blob2_id M100	file1
+	:000000 100644 $ZERO_OID $blob3_id A	file2
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B -C (#9)' '
 	git diff-index -B -C reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec C095	file0	file1
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 69a939f651686f56322566e2fd76715947a24162 R095	file0	file2
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob2_id C095	file0	file1
+	:100644 100644 $blob0_id $blob3_id R095	file0	file2
 	EOF
 	compare_diff_raw expect current
 '

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 17/28] t4014: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (15 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 16/28] t4008: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  7:34   ` Johannes Sixt
  2018-05-13  2:24 ` [PATCH v2 18/28] t4020: " brian m. carlson
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes values for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4014-format-patch.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index dac3f349a3..42b3e11207 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -578,7 +578,9 @@ test_expect_success 'excessive subject' '
 
 	rm -rf patches/ &&
 	git checkout side &&
+	before=$(git rev-parse --short $(git hash-object file)) &&
 	for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
+	after=$(git rev-parse --short $(git hash-object file)) &&
 	git update-index file &&
 	git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." &&
 	git format-patch -o patches/ master..side &&
@@ -586,7 +588,6 @@ test_expect_success 'excessive subject' '
 '
 
 test_expect_success 'cover-letter inherits diff options' '
-
 	git mv file foo &&
 	git commit -m foo &&
 	git format-patch --no-renames --cover-letter -1 &&
@@ -616,7 +617,7 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 '
 
 cat > expect << EOF
-index 40f36c6..2dc5c23 100644
+index $before..$after 100644
 --- a/file
 +++ b/file
 @@ -13,4 +13,20 @@ C
@@ -640,7 +641,7 @@ test_expect_success 'format-patch respects -U' '
 cat > expect << EOF
 
 diff --git a/file b/file
-index 40f36c6..2dc5c23 100644
+index $before..$after 100644
 --- a/file
 +++ b/file
 @@ -14,3 +14,19 @@ C

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 18/28] t4020: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (16 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 17/28] t4014: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 19/28] t4022: " brian m. carlson
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4020-diff-external.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 49d3f54b29..fd2140700e 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -13,6 +13,7 @@ test_expect_success setup '
 
 	test_tick &&
 	echo second >file &&
+	before=$(git rev-parse --short $(git hash-object file)) &&
 	git add file &&
 	git commit -m second &&
 
@@ -180,9 +181,12 @@ test_expect_success 'no diff with -diff' '
 echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
 
 test_expect_success 'force diff with "diff"' '
+	after=$(git rev-parse --short $(git hash-object file)) &&
 	echo >.gitattributes "file diff" &&
 	git diff >actual &&
-	test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
+	sed -e "s/^index .*/index $before..$after 100644/" \
+		"$TEST_DIRECTORY"/t4020/diff.NUL >expected-diff &&
+	test_cmp expected-diff actual
 '
 
 test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '
@@ -237,7 +241,7 @@ test_expect_success 'diff --cached' '
 	git update-index --assume-unchanged file &&
 	echo second >file &&
 	git diff --cached >actual &&
-	test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
+	test_cmp expected-diff actual
 '
 
 test_expect_success 'clean up crlf leftovers' '

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 19/28] t4022: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (17 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 18/28] t4020: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 20/28] t4029: fix test indentation brian m. carlson
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4022-diff-rewrite.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh
index cb51d9f9d4..0f1287a8ce 100755
--- a/t/t4022-diff-rewrite.sh
+++ b/t/t4022-diff-rewrite.sh
@@ -13,6 +13,7 @@ test_expect_success setup '
 	  "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
 	  <"$TEST_DIRECTORY"/../COPYING >test &&
 	echo "to be deleted" >test2 &&
+	blob=$(git rev-parse --short $(git hash-object test2)) &&
 	git add test2
 
 '
@@ -27,7 +28,7 @@ test_expect_success 'detect rewrite' '
 cat >expect <<EOF
 diff --git a/test2 b/test2
 deleted file mode 100644
-index 4202011..0000000
+index $blob..0000000
 --- a/test2
 +++ /dev/null
 @@ -1 +0,0 @@
@@ -43,7 +44,7 @@ test_expect_success 'show deletion diff without -D' '
 cat >expect <<EOF
 diff --git a/test2 b/test2
 deleted file mode 100644
-index 4202011..0000000
+index $blob..0000000
 EOF
 test_expect_success 'suppress deletion diff with -D' '
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 20/28] t4029: fix test indentation
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (18 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 19/28] t4022: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 21/28] t4029: abstract away SHA-1-specific constants brian m. carlson
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

We typically indent our tests with a single tab, partially so that we
can take advantage of indented heredocs.  Make this change and move the
quote marks to be in the typical position for our tests.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4029-diff-trailing-space.sh | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/t/t4029-diff-trailing-space.sh b/t/t4029-diff-trailing-space.sh
index 3ccc237a8d..f4e18cb8d3 100755
--- a/t/t4029-diff-trailing-space.sh
+++ b/t/t4029-diff-trailing-space.sh
@@ -18,22 +18,21 @@ index 5f6a263..8cb8bae 100644
 EOF
 exit 1
 
-test_expect_success \
-    "$test_description" \
-    'printf "\nx\n" > f &&
-     git add f &&
-     git commit -q -m. f &&
-     printf "\ny\n" > f &&
-     git config --bool diff.suppressBlankEmpty true &&
-     git diff f > actual &&
-     test_cmp exp actual &&
-     perl -i.bak -p -e "s/^\$/ /" exp &&
-     git config --bool diff.suppressBlankEmpty false &&
-     git diff f > actual &&
-     test_cmp exp actual &&
-     git config --bool --unset diff.suppressBlankEmpty &&
-     git diff f > actual &&
-     test_cmp exp actual
-     '
+test_expect_success "$test_description" '
+	printf "\nx\n" > f &&
+	git add f &&
+	git commit -q -m. f &&
+	printf "\ny\n" > f &&
+	git config --bool diff.suppressBlankEmpty true &&
+	git diff f > actual &&
+	test_cmp exp actual &&
+	perl -i.bak -p -e "s/^\$/ /" exp &&
+	git config --bool diff.suppressBlankEmpty false &&
+	git diff f > actual &&
+	test_cmp exp actual &&
+	git config --bool --unset diff.suppressBlankEmpty &&
+	git diff f > actual &&
+	test_cmp exp actual
+'
 
 test_done

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 21/28] t4029: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (19 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 20/28] t4029: fix test indentation brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 22/28] t4030: " brian m. carlson
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4029-diff-trailing-space.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/t/t4029-diff-trailing-space.sh b/t/t4029-diff-trailing-space.sh
index f4e18cb8d3..eaa56521e8 100755
--- a/t/t4029-diff-trailing-space.sh
+++ b/t/t4029-diff-trailing-space.sh
@@ -6,7 +6,7 @@ test_description='diff honors config option, diff.suppressBlankEmpty'
 
 . ./test-lib.sh
 
-cat <<\EOF > exp ||
+cat <<\EOF >expected ||
 diff --git a/f b/f
 index 5f6a263..8cb8bae 100644
 --- a/f
@@ -20,9 +20,12 @@ exit 1
 
 test_expect_success "$test_description" '
 	printf "\nx\n" > f &&
+	before=$(git rev-parse --short $(git hash-object f)) &&
 	git add f &&
 	git commit -q -m. f &&
 	printf "\ny\n" > f &&
+	after=$(git rev-parse --short $(git hash-object f)) &&
+	sed -e "s/^index .*/index $before..$after 100644/" expected >exp &&
 	git config --bool diff.suppressBlankEmpty true &&
 	git diff f > actual &&
 	test_cmp exp actual &&

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 22/28] t4030: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (20 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 21/28] t4029: abstract away SHA-1-specific constants brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 23/28] t/lib-diff-alternative: " brian m. carlson
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4030-diff-textconv.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index aad6c7f78d..4cb9f0e523 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -148,7 +148,8 @@ test_expect_success 'diffstat does not run textconv' '
 # restore working setup
 echo file diff=foo >.gitattributes
 
-cat >expect.typechange <<'EOF'
+symlink=$(git rev-parse --short $(printf frotz | git hash-object --stdin))
+cat >expect.typechange <<EOF
 --- a/file
 +++ /dev/null
 @@ -1,2 +0,0 @@
@@ -156,7 +157,7 @@ cat >expect.typechange <<'EOF'
 -1
 diff --git a/file b/file
 new file mode 120000
-index 0000000..67be421
+index 0000000..$symlink
 --- /dev/null
 +++ b/file
 @@ -0,0 +1 @@

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 23/28] t/lib-diff-alternative: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (21 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 22/28] t4030: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 24/28] t4205: sort log output in a hash-independent way brian m. carlson
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test code so that it computes variables for blobs instead of
using hard-coded hashes.  This makes t4033 and t4050 (the patience and
histogram tests) pass.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/lib-diff-alternative.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/t/lib-diff-alternative.sh b/t/lib-diff-alternative.sh
index 8b4dbf22d2..8d1e408bb5 100644
--- a/t/lib-diff-alternative.sh
+++ b/t/lib-diff-alternative.sh
@@ -59,9 +59,11 @@ int main(int argc, char **argv)
 }
 EOF
 
-	cat >expect <<\EOF
+	file1=$(git rev-parse --short $(git hash-object file1))
+	file2=$(git rev-parse --short $(git hash-object file2))
+	cat >expect <<EOF
 diff --git a/file1 b/file2
-index 6faa5a3..e3af329 100644
+index $file1..$file2 100644
 --- a/file1
 +++ b/file2
 @@ -1,26 +1,25 @@
@@ -136,9 +138,11 @@ e
 f
 EOF
 
-	cat >expect <<\EOF
+	uniq1=$(git rev-parse --short $(git hash-object uniq1))
+	uniq2=$(git rev-parse --short $(git hash-object uniq2))
+	cat >expect <<EOF
 diff --git a/uniq1 b/uniq2
-index b414108..0fdf397 100644
+index $uniq1..$uniq2 100644
 --- a/uniq1
 +++ b/uniq2
 @@ -1,6 +1,6 @@

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 24/28] t4205: sort log output in a hash-independent way
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (22 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 23/28] t/lib-diff-alternative: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 25/28] t4042: abstract away SHA-1-specific constants brian m. carlson
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

This test enumerates log entries and then sorts them.  For SHA-1, this
produces results that happen to sort in the order specified in the test,
but for other hash algorithms they sort differently.  Ensure we sort the
log entries in a hash-independent way by sorting on the ref name instead
of the object ID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4205-log-pretty-formats.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 591f35daaf..2052cadb11 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -516,22 +516,22 @@ test_expect_success 'log decoration properly follows tag chain' '
 	git commit --amend -m shorter &&
 	git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
 	cat <<-EOF >expected &&
-	$head1  (tag: refs/tags/tag2)
 	$head2  (tag: refs/tags/message-one)
 	$old_head1  (tag: refs/tags/message-two)
+	$head1  (tag: refs/tags/tag2)
 	EOF
-	sort actual >actual1 &&
+	sort -k3 actual >actual1 &&
 	test_cmp expected actual1
 '
 
 test_expect_success 'clean log decoration' '
 	git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
 	cat >expected <<-EOF &&
-	$head1 tag: refs/tags/tag2
 	$head2 tag: refs/tags/message-one
 	$old_head1 tag: refs/tags/message-two
+	$head1 tag: refs/tags/tag2
 	EOF
-	sort actual >actual1 &&
+	sort -k3 actual >actual1 &&
 	test_cmp expected actual1
 '
 

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 25/28] t4042: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (23 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 24/28] t4205: sort log output in a hash-independent way brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 26/28] t4045: " brian m. carlson
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4042-diff-textconv-caching.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh
index 04a44d5c61..bf33aedf4b 100755
--- a/t/t4042-diff-textconv-caching.sh
+++ b/t/t4042-diff-textconv-caching.sh
@@ -15,9 +15,13 @@ test_expect_success 'setup' '
 	echo bar content 1 >bar.bin &&
 	git add . &&
 	git commit -m one &&
+	foo1=$(git rev-parse --short HEAD:foo.bin) &&
+	bar1=$(git rev-parse --short HEAD:bar.bin) &&
 	echo foo content 2 >foo.bin &&
 	echo bar content 2 >bar.bin &&
 	git commit -a -m two &&
+	foo2=$(git rev-parse --short HEAD:foo.bin) &&
+	bar2=$(git rev-parse --short HEAD:bar.bin) &&
 	echo "*.bin diff=magic" >.gitattributes &&
 	git config diff.magic.textconv ./helper &&
 	git config diff.magic.cachetextconv true
@@ -25,14 +29,14 @@ test_expect_success 'setup' '
 
 cat >expect <<EOF
 diff --git a/bar.bin b/bar.bin
-index fcf9166..28283d5 100644
+index $bar1..$bar2 100644
 --- a/bar.bin
 +++ b/bar.bin
 @@ -1 +1 @@
 -converted: bar content 1
 +converted: bar content 2
 diff --git a/foo.bin b/foo.bin
-index d5b9fe3..1345db2 100644
+index $foo1..$foo2 100644
 --- a/foo.bin
 +++ b/foo.bin
 @@ -1 +1 @@
@@ -59,7 +63,7 @@ test_expect_success 'cached textconv does not run helper' '
 
 cat >expect <<EOF
 diff --git a/bar.bin b/bar.bin
-index fcf9166..28283d5 100644
+index $bar1..$bar2 100644
 --- a/bar.bin
 +++ b/bar.bin
 @@ -1,2 +1,2 @@
@@ -67,7 +71,7 @@ index fcf9166..28283d5 100644
 -converted: bar content 1
 +converted: bar content 2
 diff --git a/foo.bin b/foo.bin
-index d5b9fe3..1345db2 100644
+index $foo1..$foo2 100644
 --- a/foo.bin
 +++ b/foo.bin
 @@ -1,2 +1,2 @@
@@ -84,7 +88,7 @@ test_expect_success 'changing textconv invalidates cache' '
 
 cat >expect <<EOF
 diff --git a/bar.bin b/bar.bin
-index fcf9166..28283d5 100644
+index $bar1..$bar2 100644
 --- a/bar.bin
 +++ b/bar.bin
 @@ -1,2 +1,2 @@
@@ -92,7 +96,7 @@ index fcf9166..28283d5 100644
 -converted: bar content 1
 +converted: bar content 2
 diff --git a/foo.bin b/foo.bin
-index d5b9fe3..1345db2 100644
+index $foo1..$foo2 100644
 --- a/foo.bin
 +++ b/foo.bin
 @@ -1 +1 @@

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 26/28] t4045: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (24 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 25/28] t4042: abstract away SHA-1-specific constants brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 27/28] t4208: " brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 28/28] t5300: " brian m. carlson
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4045-diff-relative.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
index 6471a68701..36f8ed8a81 100755
--- a/t/t4045-diff-relative.sh
+++ b/t/t4045-diff-relative.sh
@@ -8,6 +8,7 @@ test_expect_success 'setup' '
 	echo content >file1 &&
 	mkdir subdir &&
 	echo other content >subdir/file2 &&
+	blob=$(git hash-object subdir/file2) &&
 	git add . &&
 	git commit -m one
 '
@@ -17,10 +18,11 @@ check_diff () {
 	shift
 	expect=$1
 	shift
+	short_blob=$(git rev-parse --short $blob)
 	cat >expected <<-EOF
 	diff --git a/$expect b/$expect
 	new file mode 100644
-	index 0000000..25c05ef
+	index 0000000..$short_blob
 	--- /dev/null
 	+++ b/$expect
 	@@ -0,0 +1 @@
@@ -68,7 +70,7 @@ check_raw () {
 	expect=$1
 	shift
 	cat >expected <<-EOF
-	:000000 100644 0000000000000000000000000000000000000000 25c05ef3639d2d270e7fe765a67668f098092bc5 A	$expect
+	:000000 100644 0000000000000000000000000000000000000000 $blob A	$expect
 	EOF
 	test_expect_success "--raw $*" "
 		git -C '$dir' diff --no-abbrev --raw $* HEAD^ >actual &&

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 27/28] t4208: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (25 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 26/28] t4045: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  2018-05-13  2:24 ` [PATCH v2 28/28] t5300: " brian m. carlson
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4208-log-magic-pathspec.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh
index a1705f70cf..62f335b2d9 100755
--- a/t/t4208-log-magic-pathspec.sh
+++ b/t/t4208-log-magic-pathspec.sh
@@ -45,8 +45,9 @@ test_expect_success 'git log -- :' '
 '
 
 test_expect_success 'git log HEAD -- :/' '
+	initial=$(git rev-parse --short HEAD^) &&
 	cat >expected <<-EOF &&
-	24b24cf initial
+	$initial initial
 	EOF
 	(cd sub && git log --oneline HEAD -- :/ >../actual) &&
 	test_cmp expected actual

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 28/28] t5300: abstract away SHA-1-specific constants
  2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
                   ` (26 preceding siblings ...)
  2018-05-13  2:24 ` [PATCH v2 27/28] t4208: " brian m. carlson
@ 2018-05-13  2:24 ` brian m. carlson
  27 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13  2:24 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t5300-pack-object.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 65ff60f2ee..9e66637a19 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -466,9 +466,11 @@ test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.
 
 test_expect_success \
     'fake a SHA1 hash collision' \
-    'test -f	.git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67 &&
-     cp -f	.git/objects/9d/235ed07cd19811a6ceb342de82f190e49c9f68 \
-		.git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67'
+    'long_a=$(git hash-object a | sed -e "s!^..!&/!") &&
+     long_b=$(git hash-object b | sed -e "s!^..!&/!") &&
+     test -f	.git/objects/$long_b &&
+     cp -f	.git/objects/$long_a \
+		.git/objects/$long_b'
 
 test_expect_success \
     'make sure index-pack detects the SHA1 collision' \

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 17/28] t4014: abstract away SHA-1-specific constants
  2018-05-13  2:24 ` [PATCH v2 17/28] t4014: " brian m. carlson
@ 2018-05-13  7:34   ` Johannes Sixt
  2018-05-13 17:46     ` brian m. carlson
  0 siblings, 1 reply; 31+ messages in thread
From: Johannes Sixt @ 2018-05-13  7:34 UTC (permalink / raw)
  To: brian m. carlson
  Cc: git, Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

Am 13.05.2018 um 04:24 schrieb brian m. carlson:
> Adjust the test so that it computes values for blobs instead of using
> hard-coded hashes.
> 
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>   t/t4014-format-patch.sh | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index dac3f349a3..42b3e11207 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -578,7 +578,9 @@ test_expect_success 'excessive subject' '
>   
>   	rm -rf patches/ &&
>   	git checkout side &&
> +	before=$(git rev-parse --short $(git hash-object file)) &&
>   	for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
> +	after=$(git rev-parse --short $(git hash-object file)) &&

It would be better to avoid process expansion in command arguments, 
because the shell does not diagnose failures. This is preferable:

	before=$(git hash-object file) &&
	before=$(git rev-parse --short $before) &&

-- Hannes

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 17/28] t4014: abstract away SHA-1-specific constants
  2018-05-13  7:34   ` Johannes Sixt
@ 2018-05-13 17:46     ` brian m. carlson
  0 siblings, 0 replies; 31+ messages in thread
From: brian m. carlson @ 2018-05-13 17:46 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: git, Junio C Hamano, Nguyễn Thái Ngọc Duy,
	Martin Ågren, Eric Sunshine

[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]

On Sun, May 13, 2018 at 09:34:03AM +0200, Johannes Sixt wrote:
> Am 13.05.2018 um 04:24 schrieb brian m. carlson:
> > diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> > index dac3f349a3..42b3e11207 100755
> > --- a/t/t4014-format-patch.sh
> > +++ b/t/t4014-format-patch.sh
> > @@ -578,7 +578,9 @@ test_expect_success 'excessive subject' '
> >   	rm -rf patches/ &&
> >   	git checkout side &&
> > +	before=$(git rev-parse --short $(git hash-object file)) &&
> >   	for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
> > +	after=$(git rev-parse --short $(git hash-object file)) &&
> 
> It would be better to avoid process expansion in command arguments, because
> the shell does not diagnose failures. This is preferable:
> 
> 	before=$(git hash-object file) &&
> 	before=$(git rev-parse --short $before) &&

I considered that and assumed it would be all right because if git
hash-object failed, we wouldn't get anything on stdout.  However, I
agree that your approach is more robust, so I'll reroll with that
change.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2018-05-13 17:46 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13  2:24 [PATCH v2 00/28] Hash-independent tests (part 2) brian m. carlson
2018-05-13  2:24 ` [PATCH v2 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
2018-05-13  2:24 ` [PATCH v2 02/28] t/test-lib: introduce ZERO_OID brian m. carlson
2018-05-13  2:24 ` [PATCH v2 03/28] t: switch $_z40 to $ZERO_OID brian m. carlson
2018-05-13  2:24 ` [PATCH v2 04/28] t/test-lib: introduce OID_REGEX brian m. carlson
2018-05-13  2:24 ` [PATCH v2 05/28] t: switch $_x40 to $OID_REGEX brian m. carlson
2018-05-13  2:24 ` [PATCH v2 06/28] t0000: annotate with SHA1 prerequisite brian m. carlson
2018-05-13  2:24 ` [PATCH v2 07/28] t1007: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 08/28] t1512: skip test if not using SHA-1 brian m. carlson
2018-05-13  2:24 ` [PATCH v2 09/28] t4044: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 10/28] t: skip pack tests " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 11/28] t2203: abstract away SHA-1-specific constants brian m. carlson
2018-05-13  2:24 ` [PATCH v2 12/28] t3103: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 13/28] t3702: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 14/28] t3905: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 15/28] t4007: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 16/28] t4008: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 17/28] t4014: " brian m. carlson
2018-05-13  7:34   ` Johannes Sixt
2018-05-13 17:46     ` brian m. carlson
2018-05-13  2:24 ` [PATCH v2 18/28] t4020: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 19/28] t4022: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 20/28] t4029: fix test indentation brian m. carlson
2018-05-13  2:24 ` [PATCH v2 21/28] t4029: abstract away SHA-1-specific constants brian m. carlson
2018-05-13  2:24 ` [PATCH v2 22/28] t4030: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 23/28] t/lib-diff-alternative: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 24/28] t4205: sort log output in a hash-independent way brian m. carlson
2018-05-13  2:24 ` [PATCH v2 25/28] t4042: abstract away SHA-1-specific constants brian m. carlson
2018-05-13  2:24 ` [PATCH v2 26/28] t4045: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 27/28] t4208: " brian m. carlson
2018-05-13  2:24 ` [PATCH v2 28/28] t5300: " brian m. carlson

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).