From dab92fe42fad87a2f7067589a32ee08e70d5354b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 16 Jul 2025 09:32:25 +0200 Subject: 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 Signed-off-by: Johannes Sixt --- lib/commit.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/commit.tcl') 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] -- cgit 1.2.3-korg