git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: <git@vger.kernel.org>
Cc: Matthew DeVore <matvore@google.com>, Eric Wong <e@80x24.org>,
	Matthieu Moy <git@matthieu-moy.fr>
Subject: [PATCH 09/14] perl: make Git::IndexInfo work with SHA-256
Date: Fri, 19 Jun 2020 22:39:42 +0000	[thread overview]
Message-ID: <20200619223947.947067-10-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20200619223947.947067-1-sandals@crustytoothpaste.net>

Most of the Git modules, git-svn excepted, don't know anything about the
hash algorithm and mostly work.  However, when we're printing an
all-zero object ID in Git::IndexInfo, we need to know the hash length.

Since we don't want to change the API to have that information passed
in, let's query the config to find the hash algorithm and compute the
right value.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 perl/Git/IndexInfo.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/perl/Git/IndexInfo.pm b/perl/Git/IndexInfo.pm
index a43108c985..2a7b4908f3 100644
--- a/perl/Git/IndexInfo.pm
+++ b/perl/Git/IndexInfo.pm
@@ -5,13 +5,15 @@ package Git::IndexInfo;
 
 sub new {
 	my ($class) = @_;
+	my $hash_algo = Git::config('extensions.objectformat') || 'sha1';
 	my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);
-	bless { gui => $gui, ctx => $ctx, nr => 0}, $class;
+	bless { gui => $gui, ctx => $ctx, nr => 0, hash_algo => $hash_algo}, $class;
 }
 
 sub remove {
 	my ($self, $path) = @_;
-	if (print { $self->{gui} } '0 ', 0 x 40, "\t", $path, "\0") {
+	my $length = $self->{hash_algo} eq 'sha256' ? 64 : 40;
+	if (print { $self->{gui} } '0 ', 0 x $length, "\t", $path, "\0") {
 		return ++$self->{nr};
 	}
 	undef;

  parent reply	other threads:[~2020-06-19 22:51 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 22:39 [PATCH 00/14] SHA-256 CVS and SVN patches brian m. carlson
2020-06-19 22:39 ` [PATCH 01/14] t9109: make test hash independent brian m. carlson
2020-06-19 22:39 ` [PATCH 02/14] t9168: " brian m. carlson
2020-06-19 22:39 ` [PATCH 03/14] t9108: " brian m. carlson
2020-06-19 22:39 ` [PATCH 04/14] t9100: make test work with SHA-256 brian m. carlson
2020-06-19 22:39 ` [PATCH 05/14] t9104: make hash size independent brian m. carlson
2020-06-19 22:39 ` [PATCH 06/14] t9101: make hash independent brian m. carlson
2020-06-19 22:39 ` [PATCH 07/14] t/lib-git-svn: make hash size independent brian m. carlson
2020-06-20  8:02   ` Andreas Schwab
2020-06-20 13:18     ` brian m. carlson
2020-06-19 22:39 ` [PATCH 08/14] perl: create and switch variables for hash constants brian m. carlson
2020-06-19 22:39 ` brian m. carlson [this message]
2020-06-19 22:39 ` [PATCH 10/14] perl: make SVN code hash independent brian m. carlson
2020-06-19 22:39 ` [PATCH 11/14] git-svn: set the OID length based on hash algorithm brian m. carlson
2020-06-19 22:39 ` [PATCH 12/14] git-cvsserver: port to SHA-256 brian m. carlson
2020-06-19 22:39 ` [PATCH 13/14] git-cvsimport: " brian m. carlson
2020-06-19 22:39 ` [PATCH 14/14] git-cvsexportcommit: " brian m. carlson
2020-06-20  0:21 ` [PATCH 00/14] SHA-256 CVS and SVN patches Eric Wong
2020-06-22 16:50 ` Junio C Hamano
2020-06-22 17:46   ` brian m. carlson
2020-06-22 18:04 ` [PATCH v2 " brian m. carlson
2020-06-22 18:04   ` [PATCH v2 01/14] t9109: make test hash independent brian m. carlson
2020-06-22 18:04   ` [PATCH v2 02/14] t9168: " brian m. carlson
2020-06-22 18:04   ` [PATCH v2 03/14] t9108: " brian m. carlson
2020-06-22 18:04   ` [PATCH v2 04/14] t9100: make test work with SHA-256 brian m. carlson
2020-06-22 18:04   ` [PATCH v2 05/14] t9104: make hash size independent brian m. carlson
2020-06-22 18:04   ` [PATCH v2 06/14] t9101: make hash independent brian m. carlson
2020-06-22 18:04   ` [PATCH v2 07/14] t/lib-git-svn: make hash size independent brian m. carlson
2020-06-22 18:04   ` [PATCH v2 08/14] perl: create and switch variables for hash constants brian m. carlson
2020-06-22 18:04   ` [PATCH v2 09/14] perl: make Git::IndexInfo work with SHA-256 brian m. carlson
2020-06-22 18:04   ` [PATCH v2 10/14] perl: make SVN code hash independent brian m. carlson
2020-06-22 18:04   ` [PATCH v2 11/14] git-svn: set the OID length based on hash algorithm brian m. carlson
2020-06-22 18:04   ` [PATCH v2 12/14] git-cvsserver: port to SHA-256 brian m. carlson
2020-06-22 18:04   ` [PATCH v2 13/14] git-cvsimport: " brian m. carlson
2020-06-22 18:04   ` [PATCH v2 14/14] git-cvsexportcommit: " brian m. carlson
2020-08-03 18:37     ` Andreas Schwab
2020-08-03 23:50       ` brian m. carlson
2020-08-04  0:13         ` Eric Wong
2020-08-04  0:44           ` brian m. carlson
2020-08-05 17:29         ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200619223947.947067-10-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=e@80x24.org \
    --cc=git@matthieu-moy.fr \
    --cc=git@vger.kernel.org \
    --cc=matvore@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).