diff mbox series

[v5,36/39] t: make SHA1 prerequisite depend on default hash

Message ID 20200728233446.3066485-37-sandals@crustytoothpaste.net (mailing list archive)
State New, archived
Headers show
Series SHA-256, part 3/3 | expand

Commit Message

brian m. carlson July 28, 2020, 11:34 p.m. UTC
Currently, the SHA1 prerequisite depends on the output of git
hash-object.  However, in order for that to produce sane behavior, we
must be in a repository.  If we are not, the default will remain SHA-1,
and we'll produce wrong results if we're using SHA-256 for the testsuite
but the test assertion starts when we're not in a repository.

Check the environment variable we use for this purpose, leaving it to
default to SHA-1 if none is specified.

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

Comments

Eric Sunshine July 29, 2020, 3:01 a.m. UTC | #1
On Tue, Jul 28, 2020 at 7:36 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> Currently, the SHA1 prerequisite depends on the output of git
> hash-object.  However, in order for that to produce sane behavior, we
> must be in a repository.  If we are not, the default will remain SHA-1,
> and we'll produce wrong results if we're using SHA-256 for the testsuite
> but the test assertion starts when we're not in a repository.
>
> Check the environment variable we use for this purpose, leaving it to
> default to SHA-1 if none is specified.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> @@ -1689,7 +1689,11 @@ test_lazy_prereq CURL '
>  test_lazy_prereq SHA1 '
> -       test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> +       case "$GIT_DEFAULT_HASH" in
> +       sha1) true ;;
> +       "") test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ;;
> +       *) false ::
> +       esac
>  '

This deserves a s/::/;;/ in the final case arm. The "::" does work --
in a manner of speaking -- but only "by accident"; merely because it's
being interpreted as an argument to 'false' and it happens to be the
final case arm, but it still ought to be fixed.

(I'm pretty sure I typed ";;", not "::", when I gave this code as an
example in my previous review... {goes and checks...} indeed, I did
type ";;".)
diff mbox series

Patch

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 307bb2207e..b278d37d12 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1689,7 +1689,11 @@  test_lazy_prereq CURL '
 # 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
+	case "$GIT_DEFAULT_HASH" in
+	sha1) true ;;
+	"") test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ;;
+	*) false ::
+	esac
 '
 
 test_lazy_prereq REBASE_P '