aboutsummaryrefslogtreecommitdiffstats
path: root/lib/commit.tcl
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2025-07-16 09:32:25 +0200
committerJohannes Sixt <j6t@kdbg.org>2025-07-16 18:52:38 +0200
commitdab92fe42fad87a2f7067589a32ee08e70d5354b (patch)
tree0bc70a72792cbab31b9e651135ede55d6e0f4b9a /lib/commit.tcl
parentgit-gui: Replace null_sha1 with nullid (diff)
downloadgit-dab92fe42fad87a2f7067589a32ee08e70d5354b.tar.gz
git-dab92fe42fad87a2f7067589a32ee08e70d5354b.zip
git-gui: Add support of SHA256 repo
This patch adds the basic support of SHA256 Git repositories. Most of changes are idiomatic replacement of the hard-coded hash ID length, but there are subtle things: * The hash length is determined on startup, and stored in $hashlength global variable (either 40 or 64). * The hard-coded "40" are replaced with $hashlength; for regexp patterns, the ugly string map is used. * Some code have the fixed numbers like 39 and 45, and those are replaced with the $hashlength and the offset correction. * $nullid and $nullid2 are generated for the hash length. A caveat is that repository picker dialog is performed before evaluating the repo type, hence $hashlength isn't set there yet. So the code dealing with the hard-coded "40" are handled differently; namely, the regexp range is expanded, and the null id is generated from the HEAD id length locally. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Diffstat (limited to 'lib/commit.tcl')
-rw-r--r--lib/commit.tcl3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 37b3808f7e..2fd57a51fb 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -346,6 +346,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
global file_states selected_paths rescan_active
global repo_config
global env
+ global hashlength
gets $fd_wt tree_id
if {[catch {close $fd_wt} err]} {
@@ -365,7 +366,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] == [expr {$hashlength + 5}]} {
set old_tree [string range $old_tree 5 end]
} else {
error [mc "Commit %s appears to be corrupt" $PARENT]