git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH 00/15] SHA-256 test fixes, part 6
@ 2019-10-05 21:11 brian m. carlson
  2019-10-05 21:11 ` [PATCH 01/15] t/oid-info: allow looking up hash algorithm name brian m. carlson
                   ` (15 more replies)
  0 siblings, 16 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

This series consists mostly of additional test fixes for SHA-256, plus
some test framework improvements and a new option to rev-parse.

Up until now, most of the test changes have been directly related to
fixing hash values or sizes in some way.  In other words, previous test
fixes would be required even for a Git binary that supported only
SHA-256 and not SHA-1.

In this series, we also introduce some test changes that deal with the
extension that will allow the same binary to handle both.  The changes
themselves are relatively uninteresting, but changes like these will be
making appearances in future test fix series as well.  They may appear
bizarre and out of place at times, but rest assured that they will be
useful in the future.

The other notable thing in this series is the introduction of a new
rev-parse option, --object-format.  We know, according to the transition
plan, that we'll need to support users working with input and output
in different hash algorithms.  Since we're starting to see this kind of
code appear in the codebase, it makes sense to introduce a helper that
lets scripters determine the appropriate value, and we should introduce
this code sooner, rather than later, so people can start using it.

We had had some discussions about the name of options to be used for
hash algorithms but I don't recall us coming to a definitive conclusion.
Opinions about the name[0] are of course welcome.  I'm not particularly
attached to any name, so whatever the consensus is works for me.

[0] Possibilities include --object-format, --show-object-format, --hash,
--show-hash, --hash-algorithm, --show-hash-algorithm, and more.

brian m. carlson (15):
  t/oid-info: allow looking up hash algorithm name
  t/oid-info: add empty tree and empty blob values
  rev-parse: add an --object-format option
  t1305: avoid comparing extensions
  t3429: remove SHA1 annotation
  t4010: abstract away SHA-1-specific constants
  t4011: abstract away SHA-1-specific constants
  t4015: abstract away SHA-1-specific constants
  t4027: make hash-size independent
  t4034: abstract away SHA-1-specific constants
  t4038: abstract away SHA-1 specific constants
  t4039: abstract away SHA-1-specific constants
  t4044: update test to work with SHA-256
  t4045: make hash-size independent
  t4048: abstract away SHA-1-specific constants

 Documentation/git-rev-parse.txt     |  7 +++
 builtin/rev-parse.c                 | 11 ++++
 t/oid-info/hash-info                |  9 +++
 t/t1305-config-include.sh           |  2 +-
 t/t1500-rev-parse.sh                | 15 +++++
 t/t3429-rebase-edit-todo.sh         |  2 +-
 t/t4010-diff-pathspec.sh            | 20 ++++---
 t/t4011-diff-symlink.sh             | 31 ++++++----
 t/t4015-diff-whitespace.sh          | 89 ++++++++++++++++-----------
 t/t4027-diff-submodule.sh           | 16 ++---
 t/t4034-diff-words.sh               | 93 +++++++++++++++++------------
 t/t4038-diff-combined.sh            | 19 ++++--
 t/t4039-diff-assume-unchanged.sh    |  3 +-
 t/t4044-diff-index-unique-abbrev.sh | 46 +++++++++-----
 t/t4045-diff-relative.sh            |  2 +-
 t/t4048-diff-combined-binary.sh     | 58 ++++++++++--------
 16 files changed, 268 insertions(+), 155 deletions(-)


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

* [PATCH 01/15] t/oid-info: allow looking up hash algorithm name
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
@ 2019-10-05 21:11 ` brian m. carlson
  2019-10-05 21:11 ` [PATCH 02/15] t/oid-info: add empty tree and empty blob values brian m. carlson
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

The test_oid function provides a mechanism for looking up hash algorithm
information, but it doesn't specify a way to discover the hash algorithm
name.  Knowing this information is useful if one wants to invoke the
test-tool helper for the algorithm in use, such as in our pack
generation library.

While it's currently possible to inspect the global variable holding
this value, in the future we'll allow specifying an algorithm for
storage and an algorithm for display, so it's better to abstract this
value away.  To assist with this, provide a named entry in the
algorithm-specific lookup table that prints the algorithm in use.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/oid-info/hash-info | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/t/oid-info/hash-info b/t/oid-info/hash-info
index ccdbfdf974..6b5ded0b34 100644
--- a/t/oid-info/hash-info
+++ b/t/oid-info/hash-info
@@ -6,3 +6,6 @@ hexsz sha256:64
 
 zero sha1:0000000000000000000000000000000000000000
 zero sha256:0000000000000000000000000000000000000000000000000000000000000000
+
+algo sha1:sha1
+algo sha256:sha256

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

* [PATCH 02/15] t/oid-info: add empty tree and empty blob values
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
  2019-10-05 21:11 ` [PATCH 01/15] t/oid-info: allow looking up hash algorithm name brian m. carlson
@ 2019-10-05 21:11 ` brian m. carlson
  2019-10-05 21:11 ` [PATCH 03/15] rev-parse: add an --object-format option brian m. carlson
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

The testsuite will eventually learn how to run using an algorithm other
than SHA-1. In preparation for this, teach the test_oid family of
functions how to look up the empty blob and empty tree values so they
can be used.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/oid-info/hash-info | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/oid-info/hash-info b/t/oid-info/hash-info
index 6b5ded0b34..d0736dd1a0 100644
--- a/t/oid-info/hash-info
+++ b/t/oid-info/hash-info
@@ -9,3 +9,9 @@ zero sha256:0000000000000000000000000000000000000000000000000000000000000000
 
 algo sha1:sha1
 algo sha256:sha256
+
+empty_blob sha1:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
+empty_blob sha256:473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813
+
+empty_tree sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904
+empty_tree sha256:6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321

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

* [PATCH 03/15] rev-parse: add an --object-format option
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
  2019-10-05 21:11 ` [PATCH 01/15] t/oid-info: allow looking up hash algorithm name brian m. carlson
  2019-10-05 21:11 ` [PATCH 02/15] t/oid-info: add empty tree and empty blob values brian m. carlson
@ 2019-10-05 21:11 ` brian m. carlson
  2019-10-08 11:51   ` Derrick Stolee
  2019-10-05 21:11 ` [PATCH 04/15] t1305: avoid comparing extensions brian m. carlson
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

Add an option to print the object format used for input, output, or
storage. This allows shell scripts to discover the hash algorithm in
use.

Since the transition plan allows for multiple input algorithms, document
that we may provide multiple results for input, and the format that the
results may take. While we don't support this now, documenting it early
means that script authors can future-proof their scripts for when we do.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git-rev-parse.txt |  7 +++++++
 builtin/rev-parse.c             | 11 +++++++++++
 t/t1500-rev-parse.sh            | 15 +++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index e72d332b83..8a72190940 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -274,6 +274,13 @@ print a message to stderr and exit with nonzero status.
 	Show the path to the shared index file in split index mode, or
 	empty if not in split-index mode.
 
+--object-format[=(storage|input|output)]::
+	Show the object format (hash algorithm) used for the repository
+	for storage inside the `.git` directory, input, or output. For
+	input, multiple algorithms may be printed, space-separated.
+	If not specified, the default is "storage".
+
+
 Other Options
 ~~~~~~~~~~~~~
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index f8bbe6d47e..8036219921 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -918,6 +918,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				show_datestring("--min-age=", arg);
 				continue;
 			}
+			if (opt_with_value(arg, "--object-format", &arg)) {
+				const char *val = arg ? arg : "storage";
+
+				if (strcmp(val, "storage") &&
+				    strcmp(val, "input") &&
+				    strcmp(val, "output"))
+					die("unknown mode for --object-format: %s",
+					    arg);
+				puts(the_hash_algo->name);
+				continue;
+			}
 			if (show_flag(arg) && verify)
 				die_no_single_rev(quiet);
 			continue;
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 01abee533d..fb3d81df4c 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -59,6 +59,7 @@ test_rev_parse () {
 ROOT=$(pwd)
 
 test_expect_success 'setup' '
+	test_oid_init &&
 	mkdir -p sub/dir work &&
 	cp -R .git repo.git
 '
@@ -131,6 +132,20 @@ test_expect_success 'rev-parse --is-shallow-repository in non-shallow repo' '
 	test_cmp expect actual
 '
 
+test_expect_success 'rev-parse --object-format in repo' '
+	echo "$(test_oid algo)" >expect &&
+	git rev-parse --object-format >actual &&
+	test_cmp expect actual &&
+	git rev-parse --object-format=storage >actual &&
+	test_cmp expect actual &&
+	git rev-parse --object-format=input >actual &&
+	test_cmp expect actual &&
+	git rev-parse --object-format=output >actual &&
+	test_cmp expect actual &&
+	test_must_fail git rev-parse --object-format=squeamish-ossifrage 2>err &&
+	grep "unknown mode for --object-format: squeamish-ossifrage" err
+'
+
 test_expect_success 'showing the superproject correctly' '
 	git rev-parse --show-superproject-working-tree >out &&
 	test_must_be_empty out &&

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

* [PATCH 04/15] t1305: avoid comparing extensions
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (2 preceding siblings ...)
  2019-10-05 21:11 ` [PATCH 03/15] rev-parse: add an --object-format option brian m. carlson
@ 2019-10-05 21:11 ` brian m. carlson
  2019-10-05 21:11 ` [PATCH 05/15] t3429: remove SHA1 annotation brian m. carlson
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

A repository using a hash other than SHA-1 will need to have an
extension in the config file.  Ignore any extensions when comparing
config files, since they don't usefully contribute to the goal of the
test.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t1305-config-include.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index d20b4d150d..f1e1b289f9 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -63,7 +63,7 @@ test_expect_success 'listing includes option and expansion' '
 	test.one=1
 	EOF
 	git config --list >actual.full &&
-	grep -v ^core actual.full >actual &&
+	grep -v -e ^core -e ^extensions actual.full >actual &&
 	test_cmp expect actual
 '
 

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

* [PATCH 05/15] t3429: remove SHA1 annotation
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (3 preceding siblings ...)
  2019-10-05 21:11 ` [PATCH 04/15] t1305: avoid comparing extensions brian m. carlson
@ 2019-10-05 21:11 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 06/15] t4010: abstract away SHA-1-specific constants brian m. carlson
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:11 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

This test passes successfully with SHA-256, so remove the annotation
which limits it to SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t3429-rebase-edit-todo.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh
index 76f6d306ea..63edf17114 100755
--- a/t/t3429-rebase-edit-todo.sh
+++ b/t/t3429-rebase-edit-todo.sh
@@ -11,7 +11,7 @@ test_expect_success 'rebase exec modifies rebase-todo' '
 	test -e F
 '
 
-test_expect_success SHA1 'loose object cache vs re-reading todo list' '
+test_expect_success 'loose object cache vs re-reading todo list' '
 	GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo &&
 	export GIT_REBASE_TODO &&
 	write_script append-todo.sh <<-\EOS &&

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

* [PATCH 06/15] t4010: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (4 preceding siblings ...)
  2019-10-05 21:11 ` [PATCH 05/15] t3429: remove SHA1 annotation brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 07/15] t4011: " brian m. carlson
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

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/t4010-diff-pathspec.sh | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index 281f8fad0c..e5ca359edf 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -17,11 +17,15 @@ test_expect_success \
     'echo frotz >file0 &&
      mkdir path1 &&
      echo rezrov >path1/file1 &&
+     before0=$(git hash-object file0) &&
+     before1=$(git hash-object path1/file1) &&
      git update-index --add file0 path1/file1 &&
      tree=$(git write-tree) &&
      echo "$tree" &&
      echo nitfol >file0 &&
      echo yomin >path1/file1 &&
+     after0=$(git hash-object file0) &&
+     after1=$(git hash-object path1/file1) &&
      git update-index file0 path1/file1'
 
 cat >expected <<\EOF
@@ -31,32 +35,32 @@ test_expect_success \
     'git diff-index --cached $tree -- path >current &&
      compare_diff_raw current expected'
 
-cat >expected <<\EOF
-:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M	path1/file1
+cat >expected <<EOF
+:100644 100644 $before1 $after1 M	path1/file1
 EOF
 test_expect_success \
     'limit to path1 should show path1/file1' \
     'git diff-index --cached $tree -- path1 >current &&
      compare_diff_raw current expected'
 
-cat >expected <<\EOF
-:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M	path1/file1
+cat >expected <<EOF
+:100644 100644 $before1 $after1 M	path1/file1
 EOF
 test_expect_success \
     'limit to path1/ should show path1/file1' \
     'git diff-index --cached $tree -- path1/ >current &&
      compare_diff_raw current expected'
 
-cat >expected <<\EOF
-:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M	path1/file1
+cat >expected <<EOF
+:100644 100644 $before1 $after1 M	path1/file1
 EOF
 test_expect_success \
     '"*file1" should show path1/file1' \
     'git diff-index --cached $tree -- "*file1" >current &&
      compare_diff_raw current expected'
 
-cat >expected <<\EOF
-:100644 100644 8e4020bb5a8d8c873b25de15933e75cc0fc275df dca6b92303befc93086aa025d90a5facd7eb2812 M	file0
+cat >expected <<EOF
+:100644 100644 $before0 $after0 M	file0
 EOF
 test_expect_success \
     'limit to file0 should show file0' \

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

* [PATCH 07/15] t4011: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (5 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 06/15] t4010: abstract away SHA-1-specific constants brian m. carlson
@ 2019-10-05 21:12 ` " brian m. carlson
  2019-10-08 12:21   ` Derrick Stolee
  2019-10-05 21:12 ` [PATCH 08/15] t4015: " brian m. carlson
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

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/t4011-diff-symlink.sh | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh
index 5ae19b987d..b6934da266 100755
--- a/t/t4011-diff-symlink.sh
+++ b/t/t4011-diff-symlink.sh
@@ -10,10 +10,12 @@ test_description='Test diff of symlinks.
 . "$TEST_DIRECTORY"/diff-lib.sh
 
 test_expect_success 'diff new symlink and file' '
-	cat >expected <<-\EOF &&
+	symlink=$(git rev-parse --short \
+		$(printf xyzzy | git hash-object --stdin)) &&
+	cat >expected <<-EOF &&
 	diff --git a/frotz b/frotz
 	new file mode 120000
-	index 0000000..7c465af
+	index 0000000..$symlink
 	--- /dev/null
 	+++ b/frotz
 	@@ -0,0 +1 @@
@@ -21,7 +23,7 @@ test_expect_success 'diff new symlink and file' '
 	\ No newline at end of file
 	diff --git a/nitfol b/nitfol
 	new file mode 100644
-	index 0000000..7c465af
+	index 0000000..$symlink
 	--- /dev/null
 	+++ b/nitfol
 	@@ -0,0 +1 @@
@@ -46,10 +48,10 @@ test_expect_success 'diff unchanged symlink and file'  '
 '
 
 test_expect_success 'diff removed symlink and file' '
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	diff --git a/frotz b/frotz
 	deleted file mode 120000
-	index 7c465af..0000000
+	index $symlink..0000000
 	--- a/frotz
 	+++ /dev/null
 	@@ -1 +0,0 @@
@@ -57,7 +59,7 @@ test_expect_success 'diff removed symlink and file' '
 	\ No newline at end of file
 	diff --git a/nitfol b/nitfol
 	deleted file mode 100644
-	index 7c465af..0000000
+	index $symlink..0000000
 	--- a/nitfol
 	+++ /dev/null
 	@@ -1 +0,0 @@
@@ -90,9 +92,11 @@ test_expect_success 'diff identical, but newly created symlink and file' '
 '
 
 test_expect_success 'diff different symlink and file' '
-	cat >expected <<-\EOF &&
+	new=$(git rev-parse --short \
+		$(printf yxyyz | git hash-object --stdin)) &&
+	cat >expected <<-EOF &&
 	diff --git a/frotz b/frotz
-	index 7c465af..df1db54 120000
+	index $symlink..$new 120000
 	--- a/frotz
 	+++ b/frotz
 	@@ -1 +1 @@
@@ -101,7 +105,7 @@ test_expect_success 'diff different symlink and file' '
 	+yxyyz
 	\ No newline at end of file
 	diff --git a/nitfol b/nitfol
-	index 7c465af..df1db54 100644
+	index $symlink..$new 100644
 	--- a/nitfol
 	+++ b/nitfol
 	@@ -1 +1 @@
@@ -137,14 +141,17 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
 '
 
 test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
-	cat >expect <<-\EOF &&
+	file=$(git rev-parse --short $(git hash-object file.bin)) &&
+	link=$(git rev-parse --short \
+		$(printf file.bin | git hash-object --stdin)) &&
+	cat >expect <<-EOF &&
 	diff --git a/file.bin b/file.bin
 	new file mode 100644
-	index 0000000..d95f3ad
+	index 0000000..$file
 	Binary files /dev/null and b/file.bin differ
 	diff --git a/link.bin b/link.bin
 	new file mode 120000
-	index 0000000..dce41ec
+	index 0000000..$link
 	--- /dev/null
 	+++ b/link.bin
 	@@ -0,0 +1 @@

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

* [PATCH 08/15] t4015: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (6 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 07/15] t4011: " brian m. carlson
@ 2019-10-05 21:12 ` " brian m. carlson
  2019-10-08 12:31   ` Derrick Stolee
  2019-10-05 21:12 ` [PATCH 09/15] t4027: make hash-size independent brian m. carlson
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

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/t4015-diff-whitespace.sh | 89 +++++++++++++++++++++++---------------
 1 file changed, 53 insertions(+), 36 deletions(-)

diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 6b087df3dc..eadaf57262 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -16,6 +16,7 @@ test_expect_success "Ray Lehtiniemi's example" '
 	} while (0);
 	EOF
 	git update-index --add x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 
 	cat <<-\EOF >x &&
 	do
@@ -24,10 +25,11 @@ test_expect_success "Ray Lehtiniemi's example" '
 	}
 	while (0);
 	EOF
+	after=$(git rev-parse --short $(git hash-object x)) &&
 
-	cat <<-\EOF >expect &&
+	cat <<-EOF >expect &&
 	diff --git a/x b/x
-	index adf3937..6edc172 100644
+	index $before..$after 100644
 	--- a/x
 	+++ b/x
 	@@ -1,3 +1,5 @@
@@ -61,6 +63,7 @@ test_expect_success 'another test, without options' '
 	EOF
 
 	git update-index x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 
 	tr "_" " " <<-\EOF >x &&
 	_	whitespace at beginning
@@ -70,10 +73,11 @@ test_expect_success 'another test, without options' '
 	unchanged line
 	CR at end
 	EOF
+	after=$(git rev-parse --short $(git hash-object x)) &&
 
-	tr "Q_" "\015 " <<-\EOF >expect &&
+	tr "Q_" "\015 " <<-EOF >expect &&
 	diff --git a/x b/x
-	index d99af23..22d9f73 100644
+	index $before..$after 100644
 	--- a/x
 	+++ b/x
 	@@ -1,6 +1,6 @@
@@ -108,9 +112,9 @@ test_expect_success 'another test, without options' '
 	git diff -w --ignore-cr-at-eol >out &&
 	test_must_be_empty out &&
 
-	tr "Q_" "\015 " <<-\EOF >expect &&
+	tr "Q_" "\015 " <<-EOF >expect &&
 	diff --git a/x b/x
-	index d99af23..22d9f73 100644
+	index $before..$after 100644
 	--- a/x
 	+++ b/x
 	@@ -1,6 +1,6 @@
@@ -132,9 +136,9 @@ test_expect_success 'another test, without options' '
 	git diff -b --ignore-cr-at-eol >out &&
 	test_cmp expect out &&
 
-	tr "Q_" "\015 " <<-\EOF >expect &&
+	tr "Q_" "\015 " <<-EOF >expect &&
 	diff --git a/x b/x
-	index d99af23..22d9f73 100644
+	index $before..$after 100644
 	--- a/x
 	+++ b/x
 	@@ -1,6 +1,6 @@
@@ -154,9 +158,9 @@ test_expect_success 'another test, without options' '
 	git diff --ignore-space-at-eol --ignore-cr-at-eol >out &&
 	test_cmp expect out &&
 
-	tr "Q_" "\015 " <<-\EOF >expect &&
+	tr "Q_" "\015 " <<-EOF >expect &&
 	diff --git a/x b/x
-	index_d99af23..22d9f73 100644
+	index_$before..$after 100644
 	--- a/x
 	+++ b/x
 	@@ -1,6 +1,6 @@
@@ -786,23 +790,25 @@ test_expect_success 'whitespace-only changes not reported' '
 	test_must_be_empty actual
 '
 
-cat <<EOF >expect
-diff --git a/x b/z
-similarity index NUM%
-rename from x
-rename to z
-index 380c32a..a97b785 100644
-EOF
 test_expect_success 'whitespace-only changes reported across renames' '
 	git reset --hard &&
 	for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x &&
 	git add x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 	git commit -m "base" &&
 	sed -e "5s/^/ /" x >z &&
 	git rm x &&
 	git add z &&
+	after=$(git rev-parse --short $(git hash-object z)) &&
 	git diff -w -M --cached |
 	sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual &&
+	cat <<-EOF >expect &&
+	diff --git a/x b/z
+	similarity index NUM%
+	rename from x
+	rename to z
+	index $before..$after 100644
+	EOF
 	test_cmp expect actual
 '
 
@@ -858,13 +864,15 @@ test_expect_success 'diff that introduces a line with only tabs' '
 	git config core.whitespace blank-at-eol &&
 	git reset --hard &&
 	echo "test" >x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 	git commit -m "initial" x &&
 	echo "{NTN}" | tr "NT" "\n\t" >>x &&
+	after=$(git rev-parse --short $(git hash-object x)) &&
 	git diff --color | test_decode_color >current &&
 
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	<BOLD>diff --git a/x b/x<RESET>
-	<BOLD>index 9daeafb..2874b91 100644<RESET>
+	<BOLD>index $before..$after 100644<RESET>
 	<BOLD>--- a/x<RESET>
 	<BOLD>+++ b/x<RESET>
 	<CYAN>@@ -1 +1,4 @@<RESET>
@@ -883,19 +891,21 @@ test_expect_success 'diff that introduces and removes ws breakages' '
 		echo "0. blank-at-eol " &&
 		echo "1. blank-at-eol "
 	} >x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 	git commit -a --allow-empty -m preimage &&
 	{
 		echo "0. blank-at-eol " &&
 		echo "1. still-blank-at-eol " &&
 		echo "2. and a new line "
 	} >x &&
+	after=$(git rev-parse --short $(git hash-object x)) &&
 
 	git diff --color |
 	test_decode_color >current &&
 
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	<BOLD>diff --git a/x b/x<RESET>
-	<BOLD>index d0233a2..700886e 100644<RESET>
+	<BOLD>index $before..$after 100644<RESET>
 	<BOLD>--- a/x<RESET>
 	<BOLD>+++ b/x<RESET>
 	<CYAN>@@ -1,2 +1,3 @@<RESET>
@@ -915,16 +925,18 @@ test_expect_success 'ws-error-highlight test setup' '
 		echo "0. blank-at-eol " &&
 		echo "1. blank-at-eol "
 	} >x &&
+	before=$(git rev-parse --short $(git hash-object x)) &&
 	git commit -a --allow-empty -m preimage &&
 	{
 		echo "0. blank-at-eol " &&
 		echo "1. still-blank-at-eol " &&
 		echo "2. and a new line "
 	} >x &&
+	after=$(git rev-parse --short $(git hash-object x)) &&
 
-	cat >expect.default-old <<-\EOF &&
+	cat >expect.default-old <<-EOF &&
 	<BOLD>diff --git a/x b/x<RESET>
-	<BOLD>index d0233a2..700886e 100644<RESET>
+	<BOLD>index $before..$after 100644<RESET>
 	<BOLD>--- a/x<RESET>
 	<BOLD>+++ b/x<RESET>
 	<CYAN>@@ -1,2 +1,3 @@<RESET>
@@ -934,9 +946,9 @@ test_expect_success 'ws-error-highlight test setup' '
 	<GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
 	EOF
 
-	cat >expect.all <<-\EOF &&
+	cat >expect.all <<-EOF &&
 	<BOLD>diff --git a/x b/x<RESET>
-	<BOLD>index d0233a2..700886e 100644<RESET>
+	<BOLD>index $before..$after 100644<RESET>
 	<BOLD>--- a/x<RESET>
 	<BOLD>+++ b/x<RESET>
 	<CYAN>@@ -1,2 +1,3 @@<RESET>
@@ -946,9 +958,9 @@ test_expect_success 'ws-error-highlight test setup' '
 	<GREEN>+<RESET><GREEN>2. and a new line<RESET><BLUE> <RESET>
 	EOF
 
-	cat >expect.none <<-\EOF
+	cat >expect.none <<-EOF
 	<BOLD>diff --git a/x b/x<RESET>
-	<BOLD>index d0233a2..700886e 100644<RESET>
+	<BOLD>index $before..$after 100644<RESET>
 	<BOLD>--- a/x<RESET>
 	<BOLD>+++ b/x<RESET>
 	<CYAN>@@ -1,2 +1,3 @@<RESET>
@@ -1022,14 +1034,15 @@ test_expect_success 'detect moved code, complete file' '
 	EOF
 	git add test.c &&
 	git commit -m "add main function" &&
+	file=$(git rev-parse --short HEAD:test.c) &&
 	git mv test.c main.c &&
 	test_config color.diff.oldMoved "normal red" &&
 	test_config color.diff.newMoved "normal green" &&
 	git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	<BOLD>diff --git a/main.c b/main.c<RESET>
 	<BOLD>new file mode 100644<RESET>
-	<BOLD>index 0000000..a986c57<RESET>
+	<BOLD>index 0000000..$file<RESET>
 	<BOLD>--- /dev/null<RESET>
 	<BOLD>+++ b/main.c<RESET>
 	<CYAN>@@ -0,0 +1,5 @@<RESET>
@@ -1040,7 +1053,7 @@ test_expect_success 'detect moved code, complete file' '
 	<BGREEN>+<RESET><BGREEN>}<RESET>
 	<BOLD>diff --git a/test.c b/test.c<RESET>
 	<BOLD>deleted file mode 100644<RESET>
-	<BOLD>index a986c57..0000000<RESET>
+	<BOLD>index $file..0000000<RESET>
 	<BOLD>--- a/test.c<RESET>
 	<BOLD>+++ /dev/null<RESET>
 	<CYAN>@@ -1,5 +0,0 @@<RESET>
@@ -1094,6 +1107,8 @@ test_expect_success 'detect malicious moved code, inside file' '
 	EOF
 	git add main.c test.c &&
 	git commit -m "add main and test file" &&
+	before_main=$(git rev-parse --short HEAD:main.c) &&
+	before_test=$(git rev-parse --short HEAD:test.c) &&
 	cat <<-\EOF >main.c &&
 		#include<stdio.h>
 		int stuff()
@@ -1126,10 +1141,12 @@ test_expect_success 'detect malicious moved code, inside file' '
 			bar();
 		}
 	EOF
+	after_main=$(git rev-parse --short $(git hash-object main.c)) &&
+	after_test=$(git rev-parse --short $(git hash-object test.c)) &&
 	git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual &&
-	cat <<-\EOF >expected &&
+	cat <<-EOF >expected &&
 	<BOLD>diff --git a/main.c b/main.c<RESET>
-	<BOLD>index 27a619c..7cf9336 100644<RESET>
+	<BOLD>index $before_main..$after_main 100644<RESET>
 	<BOLD>--- a/main.c<RESET>
 	<BOLD>+++ b/main.c<RESET>
 	<CYAN>@@ -5,13 +5,6 @@<RESET> <RESET>printf("Hello ");<RESET>
@@ -1147,7 +1164,7 @@ test_expect_success 'detect malicious moved code, inside file' '
 	 {<RESET>
 	 foo();<RESET>
 	<BOLD>diff --git a/test.c b/test.c<RESET>
-	<BOLD>index 1dc1d85..2bedec9 100644<RESET>
+	<BOLD>index $before_test..$after_test 100644<RESET>
 	<BOLD>--- a/test.c<RESET>
 	<BOLD>+++ b/test.c<RESET>
 	<CYAN>@@ -4,6 +4,13 @@<RESET> <RESET>int bar()<RESET>
@@ -1176,9 +1193,9 @@ test_expect_success 'plain moved code, inside file' '
 	test_config color.diff.newMovedAlternative "yellow" &&
 	# needs previous test as setup
 	git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual &&
-	cat <<-\EOF >expected &&
+	cat <<-EOF >expected &&
 	<BOLD>diff --git a/main.c b/main.c<RESET>
-	<BOLD>index 27a619c..7cf9336 100644<RESET>
+	<BOLD>index $before_main..$after_main 100644<RESET>
 	<BOLD>--- a/main.c<RESET>
 	<BOLD>+++ b/main.c<RESET>
 	<CYAN>@@ -5,13 +5,6 @@<RESET> <RESET>printf("Hello ");<RESET>
@@ -1196,7 +1213,7 @@ test_expect_success 'plain moved code, inside file' '
 	 {<RESET>
 	 foo();<RESET>
 	<BOLD>diff --git a/test.c b/test.c<RESET>
-	<BOLD>index 1dc1d85..2bedec9 100644<RESET>
+	<BOLD>index $before_test..$after_test 100644<RESET>
 	<BOLD>--- a/test.c<RESET>
 	<BOLD>+++ b/test.c<RESET>
 	<CYAN>@@ -4,6 +4,13 @@<RESET> <RESET>int bar()<RESET>

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

* [PATCH 09/15] t4027: make hash-size independent
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (7 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 08/15] t4015: " brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 10/15] t4034: abstract away SHA-1-specific constants brian m. carlson
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

Instead of hard-coding the length of an object ID, look this value up
using the translation tables.  Similarly, compute input data for invalid
submodule entries using the tables as well.

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

diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 9aa8e2b39b..e29deaf4a5 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -6,6 +6,7 @@ test_description='difference in submodules'
 . "$TEST_DIRECTORY"/diff-lib.sh
 
 test_expect_success setup '
+	test_oid_init &&
 	test_tick &&
 	test_create_repo sub &&
 	(
@@ -36,7 +37,8 @@ test_expect_success setup '
 '
 
 test_expect_success 'git diff --raw HEAD' '
-	git diff --raw --abbrev=40 HEAD >actual &&
+	hexsz=$(test_oid hexsz) &&
+	git diff --raw --abbrev=$hexsz HEAD >actual &&
 	test_cmp expect actual
 '
 
@@ -245,23 +247,21 @@ test_expect_success 'git diff (empty submodule dir)' '
 '
 
 test_expect_success 'conflicted submodule setup' '
-
-	# 39 efs
-	c=fffffffffffffffffffffffffffffffffffffff &&
+	c=$(test_oid ff_1) &&
 	(
 		echo "000000 $ZERO_OID 0	sub" &&
 		echo "160000 1$c 1	sub" &&
 		echo "160000 2$c 2	sub" &&
 		echo "160000 3$c 3	sub"
 	) | git update-index --index-info &&
-	echo >expect.nosub '\''diff --cc sub
+	echo >expect.nosub "diff --cc sub
 index 2ffffff,3ffffff..0000000
 --- a/sub
 +++ b/sub
 @@@ -1,1 -1,1 +1,1 @@@
-- Subproject commit 2fffffffffffffffffffffffffffffffffffffff
- -Subproject commit 3fffffffffffffffffffffffffffffffffffffff
-++Subproject commit 0000000000000000000000000000000000000000'\'' &&
+- Subproject commit 2$c
+ -Subproject commit 3$c
+++Subproject commit $ZERO_OID" &&
 
 	hh=$(git rev-parse HEAD) &&
 	sed -e "s/$ZERO_OID/$hh/" expect.nosub >expect.withsub

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

* [PATCH 10/15] t4034: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (8 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 09/15] t4027: make hash-size independent brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 11/15] t4038: abstract away SHA-1 specific constants brian m. carlson
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.  Move some expected result heredocs around so
that they can use computed variables.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4034-diff-words.sh | 93 +++++++++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 39 deletions(-)

diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 9a93c2a3e0..fb145aa173 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -19,9 +19,11 @@ cat >post.simple <<-\EOF
 
 	aeff = aeff * ( aaa )
 EOF
-cat >expect.letter-runs-are-words <<-\EOF
+pre=$(git rev-parse --short $(git hash-object pre.simple))
+post=$(git rev-parse --short $(git hash-object post.simple))
+cat >expect.letter-runs-are-words <<-EOF
 	<BOLD>diff --git a/pre b/post<RESET>
-	<BOLD>index 330b04f..5ed8eff 100644<RESET>
+	<BOLD>index $pre..$post 100644<RESET>
 	<BOLD>--- a/pre<RESET>
 	<BOLD>+++ b/post<RESET>
 	<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -33,9 +35,9 @@ cat >expect.letter-runs-are-words <<-\EOF
 
 	<GREEN>aeff = aeff * ( aaa<RESET> )
 EOF
-cat >expect.non-whitespace-is-word <<-\EOF
+cat >expect.non-whitespace-is-word <<-EOF
 	<BOLD>diff --git a/pre b/post<RESET>
-	<BOLD>index 330b04f..5ed8eff 100644<RESET>
+	<BOLD>index $pre..$post 100644<RESET>
 	<BOLD>--- a/pre<RESET>
 	<BOLD>+++ b/post<RESET>
 	<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -49,9 +51,12 @@ cat >expect.non-whitespace-is-word <<-\EOF
 EOF
 
 word_diff () {
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
 	test_must_fail git diff --no-index "$@" pre post >output &&
 	test_decode_color <output >output.decrypted &&
-	test_cmp expect output.decrypted
+	sed -e "2s/index [^ ]*/index $pre..$post/" expect >expected
+	test_cmp expected output.decrypted
 }
 
 test_language_driver () {
@@ -77,9 +82,9 @@ test_expect_success 'set up pre and post with runs of whitespace' '
 '
 
 test_expect_success 'word diff with runs of whitespace' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 330b04f..5ed8eff 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -97,9 +102,9 @@ test_expect_success 'word diff with runs of whitespace' '
 '
 
 test_expect_success '--word-diff=porcelain' '
-	sed 's/#.*$//' >expect <<-\EOF &&
+	sed 's/#.*$//' >expect <<-EOF &&
 		diff --git a/pre b/post
-		index 330b04f..5ed8eff 100644
+		index $pre..$post 100644
 		--- a/pre
 		+++ b/post
 		@@ -1,3 +1,7 @@
@@ -121,9 +126,9 @@ test_expect_success '--word-diff=porcelain' '
 '
 
 test_expect_success '--word-diff=plain' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		diff --git a/pre b/post
-		index 330b04f..5ed8eff 100644
+		index $pre..$post 100644
 		--- a/pre
 		+++ b/post
 		@@ -1,3 +1,7 @@
@@ -140,9 +145,9 @@ test_expect_success '--word-diff=plain' '
 '
 
 test_expect_success '--word-diff=plain --color' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 330b04f..5ed8eff 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -158,9 +163,9 @@ test_expect_success '--word-diff=plain --color' '
 '
 
 test_expect_success 'word diff without context' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 330b04f..5ed8eff 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1 +1 @@<RESET>
@@ -207,9 +212,9 @@ test_expect_success 'command-line overrides config' '
 '
 
 test_expect_success 'command-line overrides config: --word-diff-regex' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 330b04f..5ed8eff 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -234,9 +239,9 @@ test_expect_success 'setup: remove diff driver regex' '
 '
 
 test_expect_success 'use configured regex' '
-	cat >expect <<-\EOF &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 330b04f..5ed8eff 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -254,9 +259,11 @@ test_expect_success 'use configured regex' '
 test_expect_success 'test parsing words for newline' '
 	echo "aaa (aaa)" >pre &&
 	echo "aaa (aaa) aaa" >post &&
-	cat >expect <<-\EOF &&
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index c29453b..be22f37 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1 +1 @@<RESET>
@@ -268,9 +275,11 @@ test_expect_success 'test parsing words for newline' '
 test_expect_success 'test when words are only removed at the end' '
 	echo "(:" >pre &&
 	echo "(" >post &&
-	cat >expect <<-\EOF &&
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
+	cat >expect <<-EOF &&
 		<BOLD>diff --git a/pre b/post<RESET>
-		<BOLD>index 289cb9d..2d06f37 100644<RESET>
+		<BOLD>index $pre..$post 100644<RESET>
 		<BOLD>--- a/pre<RESET>
 		<BOLD>+++ b/post<RESET>
 		<CYAN>@@ -1 +1 @@<RESET>
@@ -282,9 +291,11 @@ test_expect_success 'test when words are only removed at the end' '
 test_expect_success '--word-diff=none' '
 	echo "(:" >pre &&
 	echo "(" >post &&
-	cat >expect <<-\EOF &&
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
+	cat >expect <<-EOF &&
 		diff --git a/pre b/post
-		index 289cb9d..2d06f37 100644
+		index $pre..$post 100644
 		--- a/pre
 		+++ b/post
 		@@ -1 +1 @@
@@ -317,16 +328,6 @@ test_language_driver ruby
 test_language_driver tex
 
 test_expect_success 'word-diff with diff.sbe' '
-	cat >expect <<-\EOF &&
-	diff --git a/pre b/post
-	index a1a53b5..bc8fe6d 100644
-	--- a/pre
-	+++ b/post
-	@@ -1,3 +1,3 @@
-	a
-
-	[-b-]{+c+}
-	EOF
 	cat >pre <<-\EOF &&
 	a
 
@@ -337,21 +338,35 @@ test_expect_success 'word-diff with diff.sbe' '
 
 	c
 	EOF
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
+	cat >expect <<-EOF &&
+	diff --git a/pre b/post
+	index $pre..$post 100644
+	--- a/pre
+	+++ b/post
+	@@ -1,3 +1,3 @@
+	a
+
+	[-b-]{+c+}
+	EOF
 	test_config diff.suppress-blank-empty true &&
 	word_diff --word-diff=plain
 '
 
 test_expect_success 'word-diff with no newline at EOF' '
-	cat >expect <<-\EOF &&
+	printf "%s" "a a a a a" >pre &&
+	printf "%s" "a a ab a a" >post &&
+	pre=$(git rev-parse --short $(git hash-object pre)) &&
+	post=$(git rev-parse --short $(git hash-object post)) &&
+	cat >expect <<-EOF &&
 	diff --git a/pre b/post
-	index 7bf316e..3dd0303 100644
+	index $pre..$post 100644
 	--- a/pre
 	+++ b/post
 	@@ -1 +1 @@
 	a a [-a-]{+ab+} a a
 	EOF
-	printf "%s" "a a a a a" >pre &&
-	printf "%s" "a a ab a a" >post &&
 	word_diff --word-diff=plain
 '
 

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

* [PATCH 11/15] t4038: abstract away SHA-1 specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (9 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 10/15] t4034: abstract away SHA-1-specific constants brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 12/15] t4039: abstract away SHA-1-specific constants brian m. carlson
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

Compute several object IDs that exist in expected output, since we don't
care about the specific object IDs, only that the format of the output
is syntactically correct.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4038-diff-combined.sh | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh
index d4afe12554..15fc054fdb 100755
--- a/t/t4038-diff-combined.sh
+++ b/t/t4038-diff-combined.sh
@@ -440,11 +440,13 @@ test_expect_success 'setup for --combined-all-paths' '
 	git branch side2c &&
 	git checkout side1c &&
 	test_seq 1 10 >filename-side1c &&
+	side1cf=$(git hash-object filename-side1c) &&
 	git add filename-side1c &&
 	git commit -m with &&
 	git checkout side2c &&
 	test_seq 1 9 >filename-side2c &&
 	echo ten >>filename-side2c &&
+	side2cf=$(git hash-object filename-side2c) &&
 	git add filename-side2c &&
 	git commit -m iam &&
 	git checkout -b mergery side1c &&
@@ -452,13 +454,14 @@ test_expect_success 'setup for --combined-all-paths' '
 	git rm filename-side1c &&
 	echo eleven >>filename-side2c &&
 	git mv filename-side2c filename-merged &&
+	mergedf=$(git hash-object filename-merged) &&
 	git add filename-merged &&
 	git commit
 '
 
 test_expect_success '--combined-all-paths and --raw' '
-	cat <<-\EOF >expect &&
-	::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR	filename-side1c	filename-side2c	filename-merged
+	cat <<-EOF >expect &&
+	::100644 100644 100644 $side1cf $side2cf $mergedf RR	filename-side1c	filename-side2c	filename-merged
 	EOF
 	git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp &&
 	sed 1d <actual.tmp >actual &&
@@ -482,11 +485,13 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names'
 	git checkout side1d &&
 	test_seq 1 10 >"$(printf "file\twith\ttabs")" &&
 	git add file* &&
+	side1df=$(git hash-object *tabs) &&
 	git commit -m with &&
 	git checkout side2d &&
 	test_seq 1 9 >"$(printf "i\tam\ttabbed")" &&
 	echo ten >>"$(printf "i\tam\ttabbed")" &&
 	git add *tabbed &&
+	side2df=$(git hash-object *tabbed) &&
 	git commit -m iam &&
 	git checkout -b funny-names-mergery side1d &&
 	git merge --no-commit side2d &&
@@ -494,12 +499,14 @@ test_expect_success FUNNYNAMES 'setup for --combined-all-paths with funny names'
 	echo eleven >>"$(printf "i\tam\ttabbed")" &&
 	git mv "$(printf "i\tam\ttabbed")" "$(printf "fickle\tnaming")" &&
 	git add fickle* &&
-	git commit
+	headf=$(git hash-object fickle*) &&
+	git commit &&
+	head=$(git rev-parse HEAD)
 '
 
 test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names' '
-	cat <<-\EOF >expect &&
-	::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR	"file\twith\ttabs"	"i\tam\ttabbed"	"fickle\tnaming"
+	cat <<-EOF >expect &&
+	::100644 100644 100644 $side1df $side2df $headf RR	"file\twith\ttabs"	"i\tam\ttabbed"	"fickle\tnaming"
 	EOF
 	git diff-tree -c -M --raw --combined-all-paths HEAD >actual.tmp &&
 	sed 1d <actual.tmp >actual &&
@@ -507,7 +514,7 @@ test_expect_success FUNNYNAMES '--combined-all-paths and --raw and funny names'
 '
 
 test_expect_success FUNNYNAMES '--combined-all-paths and --raw -and -z and funny names' '
-	printf "aaf8087c3cbd4db8e185a2d074cf27c53cfb75d7\0::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect &&
+	printf "$head\0::100644 100644 100644 $side1df $side2df $headf RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect &&
 	git diff-tree -c -M --raw --combined-all-paths -z HEAD >actual &&
 	test_cmp -a expect actual
 '

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

* [PATCH 12/15] t4039: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (10 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 11/15] t4038: abstract away SHA-1 specific constants brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 13/15] t4044: update test to work with SHA-256 brian m. carlson
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

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/t4039-diff-assume-unchanged.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/t4039-diff-assume-unchanged.sh b/t/t4039-diff-assume-unchanged.sh
index 53ac44b0f0..0eb0314a8b 100755
--- a/t/t4039-diff-assume-unchanged.sh
+++ b/t/t4039-diff-assume-unchanged.sh
@@ -12,6 +12,7 @@ test_expect_success 'setup' '
 	git commit -m zero &&
 	echo one > one &&
 	echo two > two &&
+	blob=$(git hash-object one) &&
 	git add one two &&
 	git commit -m onetwo &&
 	git update-index --assume-unchanged one &&
@@ -20,7 +21,7 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'diff-index does not examine assume-unchanged entries' '
-	git diff-index HEAD^ -- one | grep -q 5626abf0f72e58d7a153368ba57db4c673c0e171
+	git diff-index HEAD^ -- one | grep -q $blob
 '
 
 test_expect_success 'diff-files does not examine assume-unchanged entries' '

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

* [PATCH 13/15] t4044: update test to work with SHA-256
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (11 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 12/15] t4039: abstract away SHA-1-specific constants brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 14/15] t4045: make hash-size independent brian m. carlson
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

This test produces pseudo-collisions and tests git diff's behavior with
them, and is therefore sensitive to the hash in use. Update the test to
compute the collisions for both SHA-1 and SHA-256 using appropriate
constants. Move the heredocs inside the setup block so that all of the
setup code can be tested for failure.

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

diff --git a/t/t4044-diff-index-unique-abbrev.sh b/t/t4044-diff-index-unique-abbrev.sh
index 647905e01f..4701796d10 100755
--- a/t/t4044-diff-index-unique-abbrev.sh
+++ b/t/t4044-diff-index-unique-abbrev.sh
@@ -3,34 +3,48 @@
 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
+test_expect_success 'setup' '
+	test_oid_cache <<-EOF &&
+	val1 sha1:4827
+	val1 sha256:5664
 
-cat >expect_update <<EOF
-100644 blob 51d2738efb4ad8a1e40bed839ab8e116f0a15e47	foo
-EOF
+	val2 sha1:11742
+	val2 sha256:10625
 
-test_expect_success 'setup' '
-	echo 4827 > foo &&
+	hash1 sha1:51d2738463ea4ca66f8691c91e33ce64b7d41bb1
+	hash1 sha256:ae31dfff0af93b2c62b0098a039b38569c43b0a7e97b873000ca42d128f27350
+
+	hasht1 sha1:51d27384
+	hasht1 sha256:ae31dfff
+
+	hash2 sha1:51d2738efb4ad8a1e40bed839ab8e116f0a15e47
+	hash2 sha256:ae31dffada88a46fd5f53c7ed5aa25a7a8951f1d5e88456c317c8d5484d263e5
+
+	hasht2 sha1:51d2738e
+	hasht2 sha256:ae31dffa
+	EOF
+
+	cat >expect_initial <<-EOF &&
+	100644 blob $(test_oid hash1)	foo
+	EOF
+
+	cat >expect_update <<-EOF &&
+	100644 blob $(test_oid hash2)	foo
+	EOF
+
+	echo "$(test_oid val1)" > foo &&
 	git add foo &&
 	git commit -m "initial" &&
 	git cat-file -p HEAD: > actual &&
 	test_cmp expect_initial actual &&
-	echo 11742 > foo &&
+	echo "$(test_oid val2)" > foo &&
 	git commit -a -m "update" &&
 	git cat-file -p HEAD: > actual &&
 	test_cmp expect_update actual
 '
 
 cat >expect <<EOF
-index 51d27384..51d2738e 100644
+index $(test_oid hasht1)..$(test_oid hasht2) 100644
 EOF
 
 test_expect_success 'diff does not produce ambiguous index line' '

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

* [PATCH 14/15] t4045: make hash-size independent
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (12 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 13/15] t4044: update test to work with SHA-256 brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-05 21:12 ` [PATCH 15/15] t4048: abstract away SHA-1-specific constants brian m. carlson
  2019-10-08 12:40 ` [PATCH 00/15] SHA-256 test fixes, part 6 Derrick Stolee
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

Replace a hard-coded all-zeros object ID with a use of $ZERO_OID.

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

diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
index 36f8ed8a81..258808708e 100755
--- a/t/t4045-diff-relative.sh
+++ b/t/t4045-diff-relative.sh
@@ -70,7 +70,7 @@ check_raw () {
 	expect=$1
 	shift
 	cat >expected <<-EOF
-	:000000 100644 0000000000000000000000000000000000000000 $blob A	$expect
+	:000000 100644 $ZERO_OID $blob A	$expect
 	EOF
 	test_expect_success "--raw $*" "
 		git -C '$dir' diff --no-abbrev --raw $* HEAD^ >actual &&

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

* [PATCH 15/15] t4048: abstract away SHA-1-specific constants
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (13 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 14/15] t4045: make hash-size independent brian m. carlson
@ 2019-10-05 21:12 ` brian m. carlson
  2019-10-08 12:40 ` [PATCH 00/15] SHA-256 test fixes, part 6 Derrick Stolee
  15 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-05 21:12 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin

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/t4048-diff-combined-binary.sh | 58 ++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/t/t4048-diff-combined-binary.sh b/t/t4048-diff-combined-binary.sh
index 87a8949500..7f9ad9fa3d 100755
--- a/t/t4048-diff-combined-binary.sh
+++ b/t/t4048-diff-combined-binary.sh
@@ -9,24 +9,27 @@ test_expect_success 'setup binary merge conflict' '
 	git commit -m one &&
 	echo twoQ2 | q_to_nul >binary &&
 	git commit -a -m two &&
+	two=$(git rev-parse --short HEAD:binary) &&
 	git checkout -b branch-binary HEAD^ &&
 	echo threeQ3 | q_to_nul >binary &&
 	git commit -a -m three &&
+	three=$(git rev-parse --short HEAD:binary) &&
 	test_must_fail git merge master &&
 	echo resolvedQhooray | q_to_nul >binary &&
-	git commit -a -m resolved
+	git commit -a -m resolved &&
+	res=$(git rev-parse --short HEAD:binary)
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --git a/binary b/binary
-index 7ea6ded..9563691 100644
+index $three..$res 100644
 Binary files a/binary and b/binary differ
 resolved
 
 diff --git a/binary b/binary
-index 6197570..9563691 100644
+index $two..$res 100644
 Binary files a/binary and b/binary differ
 EOF
 test_expect_success 'diff -m indicates binary-ness' '
@@ -34,11 +37,11 @@ test_expect_success 'diff -m indicates binary-ness' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --combined binary
-index 7ea6ded,6197570..9563691
+index $three,$two..$res
 Binary files differ
 EOF
 test_expect_success 'diff -c indicates binary-ness' '
@@ -46,11 +49,11 @@ test_expect_success 'diff -c indicates binary-ness' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --cc binary
-index 7ea6ded,6197570..9563691
+index $three,$two..$res
 Binary files differ
 EOF
 test_expect_success 'diff --cc indicates binary-ness' '
@@ -62,23 +65,26 @@ test_expect_success 'setup non-binary with binary attribute' '
 	git checkout master &&
 	test_commit one text &&
 	test_commit two text &&
+	two=$(git rev-parse --short HEAD:text) &&
 	git checkout -b branch-text HEAD^ &&
 	test_commit three text &&
+	three=$(git rev-parse --short HEAD:text) &&
 	test_must_fail git merge master &&
 	test_commit resolved text &&
+	res=$(git rev-parse --short HEAD:text) &&
 	echo text -diff >.gitattributes
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --git a/text b/text
-index 2bdf67a..2ab19ae 100644
+index $three..$res 100644
 Binary files a/text and b/text differ
 resolved
 
 diff --git a/text b/text
-index f719efd..2ab19ae 100644
+index $two..$res 100644
 Binary files a/text and b/text differ
 EOF
 test_expect_success 'diff -m respects binary attribute' '
@@ -86,11 +92,11 @@ test_expect_success 'diff -m respects binary attribute' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --combined text
-index 2bdf67a,f719efd..2ab19ae
+index $three,$two..$res
 Binary files differ
 EOF
 test_expect_success 'diff -c respects binary attribute' '
@@ -98,11 +104,11 @@ test_expect_success 'diff -c respects binary attribute' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --cc text
-index 2bdf67a,f719efd..2ab19ae
+index $three,$two..$res
 Binary files differ
 EOF
 test_expect_success 'diff --cc respects binary attribute' '
@@ -115,11 +121,11 @@ test_expect_success 'setup textconv attribute' '
 	git config diff.upcase.textconv "tr a-z A-Z <"
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --git a/text b/text
-index 2bdf67a..2ab19ae 100644
+index $three..$res 100644
 --- a/text
 +++ b/text
 @@ -1 +1 @@
@@ -128,7 +134,7 @@ index 2bdf67a..2ab19ae 100644
 resolved
 
 diff --git a/text b/text
-index f719efd..2ab19ae 100644
+index $two..$res 100644
 --- a/text
 +++ b/text
 @@ -1 +1 @@
@@ -140,11 +146,11 @@ test_expect_success 'diff -m respects textconv attribute' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --combined text
-index 2bdf67a,f719efd..2ab19ae
+index $three,$two..$res
 --- a/text
 +++ b/text
 @@@ -1,1 -1,1 +1,1 @@@
@@ -157,11 +163,11 @@ test_expect_success 'diff -c respects textconv attribute' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 resolved
 
 diff --cc text
-index 2bdf67a,f719efd..2ab19ae
+index $three,$two..$res
 --- a/text
 +++ b/text
 @@@ -1,1 -1,1 +1,1 @@@
@@ -174,9 +180,9 @@ test_expect_success 'diff --cc respects textconv attribute' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 diff --combined text
-index 2bdf67a,f719efd..2ab19ae
+index $three,$two..$res
 --- a/text
 +++ b/text
 @@@ -1,1 -1,1 +1,1 @@@
@@ -190,9 +196,9 @@ test_expect_success 'diff-tree plumbing does not respect textconv' '
 	test_cmp expect actual
 '
 
-cat >expect <<'EOF'
+cat >expect <<EOF
 diff --cc text
-index 2bdf67a,f719efd..0000000
+index $three,$two..0000000
 --- a/text
 +++ b/text
 @@@ -1,1 -1,1 +1,5 @@@

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

* Re: [PATCH 03/15] rev-parse: add an --object-format option
  2019-10-05 21:11 ` [PATCH 03/15] rev-parse: add an --object-format option brian m. carlson
@ 2019-10-08 11:51   ` Derrick Stolee
  2019-10-08 19:31     ` brian m. carlson
  0 siblings, 1 reply; 24+ messages in thread
From: Derrick Stolee @ 2019-10-08 11:51 UTC (permalink / raw)
  To: brian m. carlson, git; +Cc: Stefan Beller, Johannes Schindelin

On 10/5/2019 5:11 PM, brian m. carlson wrote:
> Add an option to print the object format used for input, output, or
> storage. This allows shell scripts to discover the hash algorithm in
> use.

Why put this in 'rev-parse'? Is a test helper not an option for this?

-Stolee

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

* Re: [PATCH 07/15] t4011: abstract away SHA-1-specific constants
  2019-10-05 21:12 ` [PATCH 07/15] t4011: " brian m. carlson
@ 2019-10-08 12:21   ` Derrick Stolee
  2019-10-08 12:33     ` Bert Wesarg
  0 siblings, 1 reply; 24+ messages in thread
From: Derrick Stolee @ 2019-10-08 12:21 UTC (permalink / raw)
  To: brian m. carlson, git; +Cc: Stefan Beller, Johannes Schindelin

On 10/5/2019 5:12 PM, brian m. carlson wrote:
> Adjust the test so that it computes variables for object IDs instead of
> using hard-coded hashes.

[snip]

> @@ -137,14 +141,17 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
>  '
>  
>  test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
> -	cat >expect <<-\EOF &&
> +	file=$(git rev-parse --short $(git hash-object file.bin)) &&
> +	link=$(git rev-parse --short \
> +		$(printf file.bin | git hash-object --stdin)) &&

Why this change from $(git hash-object file.bin) to
$(printf file.bin | git hash-object --stdin)?

For that matter, why are you using the "printf|git hash-object"
pattern throughout your change? Seems like an unnecessary hurdle
to me.

-Stolee

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

* Re: [PATCH 08/15] t4015: abstract away SHA-1-specific constants
  2019-10-05 21:12 ` [PATCH 08/15] t4015: " brian m. carlson
@ 2019-10-08 12:31   ` Derrick Stolee
  0 siblings, 0 replies; 24+ messages in thread
From: Derrick Stolee @ 2019-10-08 12:31 UTC (permalink / raw)
  To: brian m. carlson, git; +Cc: Stefan Beller, Johannes Schindelin

On 10/5/2019 5:12 PM, brian m. carlson wrote:
> 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/t4015-diff-whitespace.sh | 89 +++++++++++++++++++++++---------------
>  1 file changed, 53 insertions(+), 36 deletions(-)
> 
> diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
> index 6b087df3dc..eadaf57262 100755
> --- a/t/t4015-diff-whitespace.sh
> +++ b/t/t4015-diff-whitespace.sh
> @@ -16,6 +16,7 @@ test_expect_success "Ray Lehtiniemi's example" '
>  	} while (0);
>  	EOF
>  	git update-index --add x &&
> +	before=$(git rev-parse --short $(git hash-object x)) &&

I see you are using $(git hash-object <name>) here (no printf). Seems
like you could use the same pattern in the previous patch.

-Stolee


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

* Re: [PATCH 07/15] t4011: abstract away SHA-1-specific constants
  2019-10-08 12:21   ` Derrick Stolee
@ 2019-10-08 12:33     ` Bert Wesarg
  2019-10-08 12:38       ` Derrick Stolee
  2019-10-08 19:40       ` brian m. carlson
  0 siblings, 2 replies; 24+ messages in thread
From: Bert Wesarg @ 2019-10-08 12:33 UTC (permalink / raw)
  To: Derrick Stolee
  Cc: brian m. carlson, Git Mailing List, Stefan Beller, Johannes Schindelin

On Tue, Oct 8, 2019 at 2:21 PM Derrick Stolee <stolee@gmail.com> wrote:
>
> On 10/5/2019 5:12 PM, brian m. carlson wrote:
> > Adjust the test so that it computes variables for object IDs instead of
> > using hard-coded hashes.
>
> [snip]
>
> > @@ -137,14 +141,17 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
> >  '
> >
> >  test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
> > -     cat >expect <<-\EOF &&
> > +     file=$(git rev-parse --short $(git hash-object file.bin)) &&
> > +     link=$(git rev-parse --short \
> > +             $(printf file.bin | git hash-object --stdin)) &&
>
> Why this change from $(git hash-object file.bin) to
> $(printf file.bin | git hash-object --stdin)?

thats two different things. The first hashes the content of file
"file.bin". The second hashes the literal string "file.bin". To avoid
this confusion, may I suggest to use 'printf "%s" "file.bin"', so that
it is clear, that the literal string is meant in this context?

Bert

>
> For that matter, why are you using the "printf|git hash-object"
> pattern throughout your change? Seems like an unnecessary hurdle
> to me.
>
> -Stolee

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

* Re: [PATCH 07/15] t4011: abstract away SHA-1-specific constants
  2019-10-08 12:33     ` Bert Wesarg
@ 2019-10-08 12:38       ` Derrick Stolee
  2019-10-08 19:40       ` brian m. carlson
  1 sibling, 0 replies; 24+ messages in thread
From: Derrick Stolee @ 2019-10-08 12:38 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: brian m. carlson, Git Mailing List, Stefan Beller, Johannes Schindelin

On 10/8/2019 8:33 AM, Bert Wesarg wrote:
> On Tue, Oct 8, 2019 at 2:21 PM Derrick Stolee <stolee@gmail.com> wrote:
>>
>> On 10/5/2019 5:12 PM, brian m. carlson wrote:
>>> Adjust the test so that it computes variables for object IDs instead of
>>> using hard-coded hashes.
>>
>> [snip]
>>
>>> @@ -137,14 +141,17 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
>>>  '
>>>
>>>  test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
>>> -     cat >expect <<-\EOF &&
>>> +     file=$(git rev-parse --short $(git hash-object file.bin)) &&
>>> +     link=$(git rev-parse --short \
>>> +             $(printf file.bin | git hash-object --stdin)) &&
>>
>> Why this change from $(git hash-object file.bin) to
>> $(printf file.bin | git hash-object --stdin)?
> 
> thats two different things. The first hashes the content of file
> "file.bin". The second hashes the literal string "file.bin". To avoid
> this confusion, may I suggest to use 'printf "%s" "file.bin"', so that
> it is clear, that the literal string is meant in this context?

Ah, and because the resulting hash is for the contents of the symlink
(not the contents of the file), it makes sense to use printf here.

Thanks for the clarification!

-Stolee

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

* Re: [PATCH 00/15] SHA-256 test fixes, part 6
  2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
                   ` (14 preceding siblings ...)
  2019-10-05 21:12 ` [PATCH 15/15] t4048: abstract away SHA-1-specific constants brian m. carlson
@ 2019-10-08 12:40 ` Derrick Stolee
  15 siblings, 0 replies; 24+ messages in thread
From: Derrick Stolee @ 2019-10-08 12:40 UTC (permalink / raw)
  To: brian m. carlson, git; +Cc: Stefan Beller, Johannes Schindelin

On 10/5/2019 5:11 PM, brian m. carlson wrote:
> This series consists mostly of additional test fixes for SHA-256, plus
> some test framework improvements and a new option to rev-parse.
> 
> Up until now, most of the test changes have been directly related to
> fixing hash values or sizes in some way.  In other words, previous test
> fixes would be required even for a Git binary that supported only
> SHA-256 and not SHA-1.
> 
> In this series, we also introduce some test changes that deal with the
> extension that will allow the same binary to handle both.  The changes
> themselves are relatively uninteresting, but changes like these will be
> making appearances in future test fix series as well.  They may appear
> bizarre and out of place at times, but rest assured that they will be
> useful in the future.
> 
> The other notable thing in this series is the introduction of a new
> rev-parse option, --object-format.  We know, according to the transition
> plan, that we'll need to support users working with input and output
> in different hash algorithms.  Since we're starting to see this kind of
> code appear in the codebase, it makes sense to introduce a helper that
> lets scripters determine the appropriate value, and we should introduce
> this code sooner, rather than later, so people can start using it.
> 
> We had had some discussions about the name of options to be used for
> hash algorithms but I don't recall us coming to a definitive conclusion.
> Opinions about the name[0] are of course welcome.  I'm not particularly
> attached to any name, so whatever the consensus is works for me.
> 
> [0] Possibilities include --object-format, --show-object-format, --hash,
> --show-hash, --hash-algorithm, --show-hash-algorithm, and more.
Outside of a question regarding using a test-tool instead of adding an
option to 'git rev-parse', I found this series very readable.

My confusion around the printf|git hash-object stuff that is now
resolved. The error was in my reading, not in the presentation.

Thanks for your continued hard work on this subject!

-Stolee

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

* Re: [PATCH 03/15] rev-parse: add an --object-format option
  2019-10-08 11:51   ` Derrick Stolee
@ 2019-10-08 19:31     ` brian m. carlson
  0 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-08 19:31 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: git, Stefan Beller, Johannes Schindelin

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

On 2019-10-08 at 11:51:45, Derrick Stolee wrote:
> On 10/5/2019 5:11 PM, brian m. carlson wrote:
> > Add an option to print the object format used for input, output, or
> > storage. This allows shell scripts to discover the hash algorithm in
> > use.
> 
> Why put this in 'rev-parse'? Is a test helper not an option for this?

We do have a test helper for this, which is the first patch in the
series.  This rev-parse option is designed to be useful to scripters
more than anything else, and it will make an appearance in a later
series.

I sent it here since it's vaguely useful for tests and I also wanted to
make sure it was available sooner rather than later so folks can start
using it.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

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

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

* Re: [PATCH 07/15] t4011: abstract away SHA-1-specific constants
  2019-10-08 12:33     ` Bert Wesarg
  2019-10-08 12:38       ` Derrick Stolee
@ 2019-10-08 19:40       ` brian m. carlson
  1 sibling, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2019-10-08 19:40 UTC (permalink / raw)
  To: Bert Wesarg
  Cc: Derrick Stolee, Git Mailing List, Stefan Beller, Johannes Schindelin

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

On 2019-10-08 at 12:33:43, Bert Wesarg wrote:
> On Tue, Oct 8, 2019 at 2:21 PM Derrick Stolee <stolee@gmail.com> wrote:
> >
> > On 10/5/2019 5:12 PM, brian m. carlson wrote:
> > > Adjust the test so that it computes variables for object IDs instead of
> > > using hard-coded hashes.
> >
> > [snip]
> >
> > > @@ -137,14 +141,17 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
> > >  '
> > >
> > >  test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
> > > -     cat >expect <<-\EOF &&
> > > +     file=$(git rev-parse --short $(git hash-object file.bin)) &&
> > > +     link=$(git rev-parse --short \
> > > +             $(printf file.bin | git hash-object --stdin)) &&
> >
> > Why this change from $(git hash-object file.bin) to
> > $(printf file.bin | git hash-object --stdin)?
> 
> thats two different things. The first hashes the content of file
> "file.bin". The second hashes the literal string "file.bin". To avoid
> this confusion, may I suggest to use 'printf "%s" "file.bin"', so that
> it is clear, that the literal string is meant in this context?

This is completely correct, and, yes, I can definitely make that change.
In fact, the fact that this is confusing probably means I should use a
suitably named shell function for this, so I'll make that change when I
reroll.

> > For that matter, why are you using the "printf|git hash-object"
> > pattern throughout your change? Seems like an unnecessary hurdle
> > to me.

I would normally use echo for these types of things (because that's our
style and it's more customary), but in this case the symlink contents
don't contain a newline, so printf is required.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

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

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

end of thread, back to index

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-05 21:11 [PATCH 00/15] SHA-256 test fixes, part 6 brian m. carlson
2019-10-05 21:11 ` [PATCH 01/15] t/oid-info: allow looking up hash algorithm name brian m. carlson
2019-10-05 21:11 ` [PATCH 02/15] t/oid-info: add empty tree and empty blob values brian m. carlson
2019-10-05 21:11 ` [PATCH 03/15] rev-parse: add an --object-format option brian m. carlson
2019-10-08 11:51   ` Derrick Stolee
2019-10-08 19:31     ` brian m. carlson
2019-10-05 21:11 ` [PATCH 04/15] t1305: avoid comparing extensions brian m. carlson
2019-10-05 21:11 ` [PATCH 05/15] t3429: remove SHA1 annotation brian m. carlson
2019-10-05 21:12 ` [PATCH 06/15] t4010: abstract away SHA-1-specific constants brian m. carlson
2019-10-05 21:12 ` [PATCH 07/15] t4011: " brian m. carlson
2019-10-08 12:21   ` Derrick Stolee
2019-10-08 12:33     ` Bert Wesarg
2019-10-08 12:38       ` Derrick Stolee
2019-10-08 19:40       ` brian m. carlson
2019-10-05 21:12 ` [PATCH 08/15] t4015: " brian m. carlson
2019-10-08 12:31   ` Derrick Stolee
2019-10-05 21:12 ` [PATCH 09/15] t4027: make hash-size independent brian m. carlson
2019-10-05 21:12 ` [PATCH 10/15] t4034: abstract away SHA-1-specific constants brian m. carlson
2019-10-05 21:12 ` [PATCH 11/15] t4038: abstract away SHA-1 specific constants brian m. carlson
2019-10-05 21:12 ` [PATCH 12/15] t4039: abstract away SHA-1-specific constants brian m. carlson
2019-10-05 21:12 ` [PATCH 13/15] t4044: update test to work with SHA-256 brian m. carlson
2019-10-05 21:12 ` [PATCH 14/15] t4045: make hash-size independent brian m. carlson
2019-10-05 21:12 ` [PATCH 15/15] t4048: abstract away SHA-1-specific constants brian m. carlson
2019-10-08 12:40 ` [PATCH 00/15] SHA-256 test fixes, part 6 Derrick Stolee

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox