diff mbox series

[v4,20/39] t8011: make hash size independent

Message ID 20200726195424.626969-21-sandals@crustytoothpaste.net (mailing list archive)
State New, archived
Headers show
Series [v4,01/39] t: make test-bloom initialize repository | expand

Commit Message

brian m. carlson July 26, 2020, 7:54 p.m. UTC
Allow lines which start with either a 40- or 64-character hex object ID,
to allow for both SHA-1 and SHA-256.

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

Comments

Eric Sunshine July 26, 2020, 11 p.m. UTC | #1
On Sun, Jul 26, 2020 at 3:55 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> Allow lines which start with either a 40- or 64-character hex object ID,
> to allow for both SHA-1 and SHA-256.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> diff --git a/t/t8011-blame-split-file.sh b/t/t8011-blame-split-file.sh
> @@ -54,7 +54,7 @@ test_expect_success 'setup simulated porcelain' '
>         while (<>) {
> -               if (/^[0-9a-f]{40} /) {
> +               if (/^[0-9a-f]{40,64} /) {

Although this helps the current cases of SHA-1 and SHA-256, it doesn't
necessarily help people experimenting with other hash algorithms. I
wonder if it makes sense to loosen it a bit to simply look for
something that is likely to be an OID. Perhaps like this:

    if (/^[0-9a-f]{40,} /) {
diff mbox series

Patch

diff --git a/t/t8011-blame-split-file.sh b/t/t8011-blame-split-file.sh
index 831125047b..8a4626d496 100755
--- a/t/t8011-blame-split-file.sh
+++ b/t/t8011-blame-split-file.sh
@@ -54,7 +54,7 @@  test_expect_success 'setup simulated porcelain' '
 	cat >read-porcelain.pl <<-\EOF
 	my $field = shift;
 	while (<>) {
-		if (/^[0-9a-f]{40} /) {
+		if (/^[0-9a-f]{40,64} /) {
 			flush();
 			$hash = $&;
 		} elsif (/^$field (.*)/) {