git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org
Cc: angavrilov@gmail.com, me@yadavpratyush.com,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [RFC PATCH 4/4] track oid_size to allow for checks that are hash agnostic
Date: Mon, 11 Oct 2021 05:17:57 -0700	[thread overview]
Message-ID: <20211011121757.627-5-carenas@gmail.com> (raw)
In-Reply-To: <20211011121757.627-1-carenas@gmail.com>

This allows commit to work.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 git-gui.sh     | 5 +++--
 lib/commit.tcl | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index c0dc8ce..1646124 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1821,10 +1821,11 @@ proc short_path {path} {
 
 set next_icon_id 0
 if { [get_config extensions.objectformat] eq "sha256" } {
-	set null_oid [string repeat 0 64]
+	set oid_size 64
 } else {
-	set null_oid [string repeat 0 40]
+	set oid_size 40
 }
+set null_oid [string repeat 0 $oid_size]
 
 proc merge_state {path new_state {head_info {}} {index_info {}}} {
 	global file_states next_icon_id null_oid
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 11379f8..1306e8d 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -337,6 +337,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
 	global file_states selected_paths rescan_active
 	global repo_config
 	global env
+	global oid_size
 
 	gets $fd_wt tree_id
 	if {[catch {close $fd_wt} err]} {
@@ -356,7 +357,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
 		close $fd_ot
 
 		if {[string equal -length 5 {tree } $old_tree]
-			&& [string length $old_tree] == 45} {
+			&& [string length $old_tree] == 5 + oid_size} {
 			set old_tree [string range $old_tree 5 end]
 		} else {
 			error [mc "Commit %s appears to be corrupt" $PARENT]
-- 
2.33.0.1081.g099423f5b7


  parent reply	other threads:[~2021-10-11 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 12:17 [RFC PATCH 0/4] git-gui: support SHA-256 repositories Carlo Marcelo Arenas Belón
2021-10-11 12:17 ` [RFC PATCH 1/4] blame: prefer null_sha1 over nullid and retire later Carlo Marcelo Arenas Belón
2021-10-27 19:43   ` Pratyush Yadav
2021-10-11 12:17 ` [RFC PATCH 2/4] rename all *_sha1 variables and make null_oid hash aware Carlo Marcelo Arenas Belón
2021-10-11 20:07   ` Eric Sunshine
2021-11-13  6:54   ` Pratyush Yadav
2021-10-11 12:17 ` [RFC PATCH 3/4] expand regexp matching an oid to be hash agnostic Carlo Marcelo Arenas Belón
2021-11-13  7:55   ` Pratyush Yadav
2021-10-11 12:17 ` Carlo Marcelo Arenas Belón [this message]
2021-11-13  8:04   ` [RFC PATCH 4/4] track oid_size to allow for checks that are " Pratyush Yadav
2021-11-13  8:10     ` Pratyush Yadav
2021-10-11 14:15 ` [RFC PATCH 0/4] git-gui: support SHA-256 repositories Ævar Arnfjörð Bjarmason
2021-10-11 19:47   ` Carlo Arenas
2021-11-13  8:08 ` Pratyush Yadav

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

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

  git send-email \
    --in-reply-to=20211011121757.627-5-carenas@gmail.com \
    --to=carenas@gmail.com \
    --cc=angavrilov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@yadavpratyush.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.
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 NNTP newsgroup(s).