* [PATCH v2] git-gui: Add support of SHA256 repo
@ 2025-07-03 12:04 Takashi Iwai
2025-07-14 16:28 ` Johannes Sixt
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2025-07-03 12:04 UTC (permalink / raw)
To: git
This patch adds the basic support of SHA256 Git repositories.
The needed changes were mostly about adjusting the fixed ID length of
SHA1 (40) to be variable depending on the repo type.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v1->v2: Fix the handling in commit_committree, too
git-gui/git-gui.sh | 13 ++++++++++++-
git-gui/lib/blame.tcl | 12 ++++++++----
git-gui/lib/choose_repository.tcl | 8 ++++++--
git-gui/lib/commit.tcl | 3 ++-
git-gui/lib/remote_branch_delete.tcl | 4 +++-
5 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 28572c889c0e..206981190535 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1275,6 +1275,17 @@ if {[catch {
set picked 1
}
+# Use object format as hash algorightm (either "sha1" or "sha256")
+set hashalgorithm [exec git rev-parse --show-object-format]
+if {$hashalgorithm eq "sha1"} {
+ set hashlength 40
+} elseif {$hashalgorithm eq "sha256"} {
+ set hashlength 64
+} else {
+ puts stderr "Unknown hash algorithm: $hashalgorithm"
+ exit 1
+}
+
# we expand the _gitdir when it's just a single dot (i.e. when we're being
# run from the .git dir itself) lest the routines to find the worktree
# get confused
@@ -1822,7 +1833,7 @@ proc short_path {path} {
}
set next_icon_id 0
-set null_sha1 [string repeat 0 40]
+set null_sha1 [string repeat 0 $hashlength]
proc merge_state {path new_state {head_info {}} {index_info {}}} {
global file_states next_icon_id null_sha1
diff --git a/git-gui/lib/blame.tcl b/git-gui/lib/blame.tcl
index 8441e109be32..1f0b8ea28504 100644
--- a/git-gui/lib/blame.tcl
+++ b/git-gui/lib/blame.tcl
@@ -426,6 +426,7 @@ method _kill {} {
method _load {jump} {
variable group_colors
+ global hashlength
_hide_tooltip $this
@@ -436,7 +437,7 @@ method _load {jump} {
$i conf -state normal
$i delete 0.0 end
foreach g [$i tag names] {
- if {[regexp {^g[0-9a-f]{40}$} $g]} {
+ if {[regexp [string map "@@ $hashlength" {^g[0-9a-f]{@@}$}] $g]} {
$i tag delete $g
}
}
@@ -500,6 +501,8 @@ method _load {jump} {
}
method _history_menu {} {
+ global hashlength
+
set m $w.backmenu
if {[winfo exists $m]} {
$m delete 0 end
@@ -513,7 +516,7 @@ method _history_menu {} {
set c [lindex $e 0]
set f [lindex $e 1]
- if {[regexp {^[0-9a-f]{40}$} $c]} {
+ if {[regexp [string map "@@ $hashlength" {^[0-9a-f]{@@}$}] $c]} {
set t [string range $c 0 8]...
} elseif {$c eq {}} {
set t {Working Directory}
@@ -627,6 +630,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
method _read_blame {fd cur_w cur_d} {
upvar #0 $cur_d line_data
variable group_colors
+ global hashlength
if {$fd ne $current_fd} {
catch {close $fd}
@@ -635,7 +639,7 @@ method _read_blame {fd cur_w cur_d} {
$cur_w conf -state normal
while {[gets $fd line] >= 0} {
- if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
+ if {[regexp [string map "@@ $hashlength" {^([a-z0-9]{@@}) (\d+) (\d+) (\d+)$}] $line line \
cmit original_line final_line line_count]} {
set r_commit $cmit
set r_orig_line $original_line
@@ -648,7 +652,7 @@ method _read_blame {fd cur_w cur_d} {
set oln $r_orig_line
set cmit $r_commit
- if {[regexp {^0{40}$} $cmit]} {
+ if {[regexp [string map "@@ $hashlength" {^0{@@}$}] $cmit]} {
set commit_abbr work
set commit_type curr_commit
} elseif {$cmit eq $commit} {
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index d23abedcb36f..6078b1c7e2c4 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -870,6 +870,8 @@ method _do_clone_HEAD {ok} {
}
method _do_clone_full_end {ok} {
+ global hashlength
+
$o_cons done $ok
if {$ok} {
@@ -879,7 +881,7 @@ method _do_clone_full_end {ok} {
if {[file exists [gitdir FETCH_HEAD]]} {
set fd [open [gitdir FETCH_HEAD] r]
while {[gets $fd line] >= 0} {
- if {[regexp "^(.{40})\t\t" $line line HEAD]} {
+ if {[regexp [string map "@@ $hashlength" "^(.{@@})\t\t"] $line line HEAD]} {
break
}
}
@@ -965,6 +967,8 @@ method _do_clone_checkout {HEAD} {
}
method _readtree_wait {fd} {
+ global hashlength
+
set buf [read $fd]
$o_status_op update_meter $buf
append readtree_err $buf
@@ -986,7 +990,7 @@ method _readtree_wait {fd} {
# -- Run the post-checkout hook.
#
- set fd_ph [githook_read post-checkout [string repeat 0 40] \
+ set fd_ph [githook_read post-checkout [string repeat 0 $hashlength] \
[git rev-parse HEAD] 1]
if {$fd_ph ne {}} {
global pch_error
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index a570f9cdc6a4..7a7394a5c89c 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -348,6 +348,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]} {
@@ -367,7 +368,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]
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index 5ba9fcadd17f..8ea672479306 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -323,6 +323,8 @@ method _load {cache uri} {
}
method _read {cache fd} {
+ global hashlength
+
if {$fd ne $active_ls} {
catch {close $fd}
return
@@ -330,7 +332,7 @@ method _read {cache fd} {
while {[gets $fd line] >= 0} {
if {[string match {*^{}} $line]} continue
- if {[regexp {^([0-9a-f]{40}) (.*)$} $line _junk obj ref]} {
+ if {[regexp [string map "@@ $hashlength" {^([0-9a-f]{@@}) (.*)$}] $line _junk obj ref]} {
if {[regsub ^refs/heads/ $ref {} abr]} {
lappend head_list $abr
lappend head_cache($cache) $abr
--
2.50.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] git-gui: Add support of SHA256 repo
2025-07-03 12:04 [PATCH v2] git-gui: Add support of SHA256 repo Takashi Iwai
@ 2025-07-14 16:28 ` Johannes Sixt
2025-07-15 14:18 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2025-07-14 16:28 UTC (permalink / raw)
To: Takashi Iwai; +Cc: git
Am 03.07.25 um 14:04 schrieb Takashi Iwai:
> This patch adds the basic support of SHA256 Git repositories.
> The needed changes were mostly about adjusting the fixed ID length of
> SHA1 (40) to be variable depending on the repo type.
Thank you. Being precise in the commit message would be very
appreciated. You say "mostly", which makes me wonder what the cases are
that fall not under "mostly". How about:
Determine the hash length on startup, then replace the hard-coded
"40" by the variable value. Also fix <foo> to do <bar> so as to
account for <baz>.
Or make a bullet list if there is more to enumerate. Or make a
multi-patch series where each patch has its own topic if this is warranted.
Now reading on...
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> v1->v2: Fix the handling in commit_committree, too
>
> git-gui/git-gui.sh | 13 ++++++++++++-
> git-gui/lib/blame.tcl | 12 ++++++++----
> git-gui/lib/choose_repository.tcl | 8 ++++++--
> git-gui/lib/commit.tcl | 3 ++-
> git-gui/lib/remote_branch_delete.tcl | 4 +++-
> 5 files changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 28572c889c0e..206981190535 100755
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -1275,6 +1275,17 @@ if {[catch {
> set picked 1
> }
>
> +# Use object format as hash algorightm (either "sha1" or "sha256")
> +set hashalgorithm [exec git rev-parse --show-object-format]
Mental note: This raises the minimal requirement to Git 2.25.0.
> +if {$hashalgorithm eq "sha1"} {
> + set hashlength 40
> +} elseif {$hashalgorithm eq "sha256"} {
> + set hashlength 64
> +} else {
> + puts stderr "Unknown hash algorithm: $hashalgorithm"
> + exit 1
> +}
> +
> # we expand the _gitdir when it's just a single dot (i.e. when we're being
> # run from the .git dir itself) lest the routines to find the worktree
> # get confused
> @@ -1822,7 +1833,7 @@ proc short_path {path} {
> }
>
> set next_icon_id 0
> -set null_sha1 [string repeat 0 40]
> +set null_sha1 [string repeat 0 $hashlength]
>
> proc merge_state {path new_state {head_info {}} {index_info {}}} {
> global file_states next_icon_id null_sha1
BTW, there is a case
if {[regexp {^[0-9a-f]{1,39}$} $head]}
around line 3217 in git-gui.sh.
> diff --git a/git-gui/lib/blame.tcl b/git-gui/lib/blame.tcl
> index 8441e109be32..1f0b8ea28504 100644
> --- a/git-gui/lib/blame.tcl
> +++ b/git-gui/lib/blame.tcl
> @@ -426,6 +426,7 @@ method _kill {} {
>
> method _load {jump} {
> variable group_colors
> + global hashlength
>
> _hide_tooltip $this
>
> @@ -436,7 +437,7 @@ method _load {jump} {
> $i conf -state normal
> $i delete 0.0 end
> foreach g [$i tag names] {
> - if {[regexp {^g[0-9a-f]{40}$} $g]} {
> + if {[regexp [string map "@@ $hashlength" {^g[0-9a-f]{@@}$}] $g]} {
Github copilot insist that using 'string map' to replace parts of a
regular expression is idiomatic. However, I could not find a single
reference that it cited. Tsk, tsk, AI, what were you smoking today?
The alternatives that I tried could come up with were not any better, so
this is good.
> $i tag delete $g
> }
> }
> @@ -500,6 +501,8 @@ method _load {jump} {
> }
>
> method _history_menu {} {
> + global hashlength
> +
> set m $w.backmenu
> if {[winfo exists $m]} {
> $m delete 0 end
> @@ -513,7 +516,7 @@ method _history_menu {} {
> set c [lindex $e 0]
> set f [lindex $e 1]
>
> - if {[regexp {^[0-9a-f]{40}$} $c]} {
> + if {[regexp [string map "@@ $hashlength" {^[0-9a-f]{@@}$}] $c]} {
> set t [string range $c 0 8]...
> } elseif {$c eq {}} {
> set t {Working Directory}
> @@ -627,6 +630,7 @@ method _exec_blame {cur_w cur_d options cur_s} {
> method _read_blame {fd cur_w cur_d} {
> upvar #0 $cur_d line_data
> variable group_colors
> + global hashlength
>
> if {$fd ne $current_fd} {
> catch {close $fd}
> @@ -635,7 +639,7 @@ method _read_blame {fd cur_w cur_d} {
>
> $cur_w conf -state normal
> while {[gets $fd line] >= 0} {
> - if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
> + if {[regexp [string map "@@ $hashlength" {^([a-z0-9]{@@}) (\d+) (\d+) (\d+)$}] $line line \
> cmit original_line final_line line_count]} {
> set r_commit $cmit
> set r_orig_line $original_line
> @@ -648,7 +652,7 @@ method _read_blame {fd cur_w cur_d} {
> set oln $r_orig_line
> set cmit $r_commit
>
> - if {[regexp {^0{40}$} $cmit]} {
> + if {[regexp [string map "@@ $hashlength" {^0{@@}$}] $cmit]} {
This is a roundabout way to say 'if {$cmit eq $nullid}'.
> set commit_abbr work
> set commit_type curr_commit
> } elseif {$cmit eq $commit} {
> diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
> index d23abedcb36f..6078b1c7e2c4 100644
> --- a/git-gui/lib/choose_repository.tcl
> +++ b/git-gui/lib/choose_repository.tcl
> @@ -870,6 +870,8 @@ method _do_clone_HEAD {ok} {
> }
>
> method _do_clone_full_end {ok} {
> + global hashlength
> +
> $o_cons done $ok
>
> if {$ok} {
> @@ -879,7 +881,7 @@ method _do_clone_full_end {ok} {
> if {[file exists [gitdir FETCH_HEAD]]} {
> set fd [open [gitdir FETCH_HEAD] r]
> while {[gets $fd line] >= 0} {
> - if {[regexp "^(.{40})\t\t" $line line HEAD]} {
> + if {[regexp [string map "@@ $hashlength" "^(.{@@})\t\t"] $line line HEAD]} {
> break
> }
> }
The repository picker dialog runs before $hashlength is set. Therefore,
at the time that this function is executed, $hashlength is not available.
This procedure can depend on the file format, which is to have \t\t
after the hash regardless of its length.
> @@ -965,6 +967,8 @@ method _do_clone_checkout {HEAD} {
> }
>
> method _readtree_wait {fd} {
> + global hashlength
> +
> set buf [read $fd]
> $o_status_op update_meter $buf
> append readtree_err $buf
> @@ -986,7 +990,7 @@ method _readtree_wait {fd} {
>
> # -- Run the post-checkout hook.
> #
> - set fd_ph [githook_read post-checkout [string repeat 0 40] \
> + set fd_ph [githook_read post-checkout [string repeat 0 $hashlength] \
Yet another case where $nullid can be used.
> [git rev-parse HEAD] 1]
> if {$fd_ph ne {}} {
> global pch_error
> diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
> index a570f9cdc6a4..7a7394a5c89c 100644
> --- a/git-gui/lib/commit.tcl
> +++ b/git-gui/lib/commit.tcl
> @@ -348,6 +348,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]} {
> @@ -367,7 +368,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}]} {
Good find!
> set old_tree [string range $old_tree 5 end]
> } else {
> error [mc "Commit %s appears to be corrupt" $PARENT]
> diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
> index 5ba9fcadd17f..8ea672479306 100644
> --- a/git-gui/lib/remote_branch_delete.tcl
> +++ b/git-gui/lib/remote_branch_delete.tcl
> @@ -323,6 +323,8 @@ method _load {cache uri} {
> }
>
> method _read {cache fd} {
> + global hashlength
> +
> if {$fd ne $active_ls} {
> catch {close $fd}
> return
> @@ -330,7 +332,7 @@ method _read {cache fd} {
>
> while {[gets $fd line] >= 0} {
> if {[string match {*^{}} $line]} continue
> - if {[regexp {^([0-9a-f]{40}) (.*)$} $line _junk obj ref]} {
> + if {[regexp [string map "@@ $hashlength" {^([0-9a-f]{@@}) (.*)$}] $line _junk obj ref]} {
> if {[regsub ^refs/heads/ $ref {} abr]} {
> lappend head_list $abr
> lappend head_cache($cache) $abr
-- Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] git-gui: Add support of SHA256 repo
2025-07-14 16:28 ` Johannes Sixt
@ 2025-07-15 14:18 ` Takashi Iwai
2025-07-15 19:19 ` Johannes Sixt
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2025-07-15 14:18 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Takashi Iwai, git
On Mon, 14 Jul 2025 18:28:13 +0200,
Johannes Sixt wrote:
>
> Am 03.07.25 um 14:04 schrieb Takashi Iwai:
> > This patch adds the basic support of SHA256 Git repositories.
> > The needed changes were mostly about adjusting the fixed ID length of
> > SHA1 (40) to be variable depending on the repo type.
>
> Thank you. Being precise in the commit message would be very
> appreciated. You say "mostly", which makes me wonder what the cases are
> that fall not under "mostly". How about:
>
> Determine the hash length on startup, then replace the hard-coded
> "40" by the variable value. Also fix <foo> to do <bar> so as to
> account for <baz>.
>
> Or make a bullet list if there is more to enumerate. Or make a
> multi-patch series where each patch has its own topic if this is warranted.
Thanks for the review!
Sure, will add more descriptions in the next respin.
> BTW, there is a case
>
> if {[regexp {^[0-9a-f]{1,39}$} $head]}
>
> around line 3217 in git-gui.sh.
Obviously I didn't look for numbers less than 40 :)
I'll replace it, too.
But I don't understand why it matches up to only 39, not 40 in the
code above.
It seems trying to get the proper hash id if it's no full length id?
If so, the check should be rather like
if {![regexp {^[0-9a-f]{40}$} $head]}
?? It makes the conversion a bit simpler.
> > @@ -436,7 +437,7 @@ method _load {jump} {
> > $i conf -state normal
> > $i delete 0.0 end
> > foreach g [$i tag names] {
> > - if {[regexp {^g[0-9a-f]{40}$} $g]} {
> > + if {[regexp [string map "@@ $hashlength" {^g[0-9a-f]{@@}$}] $g]} {
>
> Github copilot insist that using 'string map' to replace parts of a
> regular expression is idiomatic. However, I could not find a single
> reference that it cited. Tsk, tsk, AI, what were you smoking today?
>
> The alternatives that I tried could come up with were not any better, so
> this is good.
To be honest, my knowledge of Tcl/Tk is decades old (and only casually
revisiting right now), so let me know if there is a better
expression.
> > @@ -648,7 +652,7 @@ method _read_blame {fd cur_w cur_d} {
> > set oln $r_orig_line
> > set cmit $r_commit
> >
> > - if {[regexp {^0{40}$} $cmit]} {
> > + if {[regexp [string map "@@ $hashlength" {^0{@@}$}] $cmit]} {
>
> This is a roundabout way to say 'if {$cmit eq $nullid}'.
OK, noted.
While we're at it, I found that $null_sha1 is identical with $nullid.
I'll prepare a cleanup patch as preliminary.
> > @@ -879,7 +881,7 @@ method _do_clone_full_end {ok} {
> > if {[file exists [gitdir FETCH_HEAD]]} {
> > set fd [open [gitdir FETCH_HEAD] r]
> > while {[gets $fd line] >= 0} {
> > - if {[regexp "^(.{40})\t\t" $line line HEAD]} {
> > + if {[regexp [string map "@@ $hashlength" "^(.{@@})\t\t"] $line line HEAD]} {
> > break
> > }
> > }
>
> The repository picker dialog runs before $hashlength is set. Therefore,
> at the time that this function is executed, $hashlength is not available.
>
> This procedure can depend on the file format, which is to have \t\t
> after the hash regardless of its length.
Oh that's bad. I'll rewrite without the reference to $hashlength.
I guess we can simply replace the above with a range check {40,64}.
> > @@ -965,6 +967,8 @@ method _do_clone_checkout {HEAD} {
> > }
> >
> > method _readtree_wait {fd} {
> > + global hashlength
> > +
> > set buf [read $fd]
> > $o_status_op update_meter $buf
> > append readtree_err $buf
> > @@ -986,7 +990,7 @@ method _readtree_wait {fd} {
> >
> > # -- Run the post-checkout hook.
> > #
> > - set fd_ph [githook_read post-checkout [string repeat 0 40] \
> > + set fd_ph [githook_read post-checkout [string repeat 0 $hashlength] \
>
> Yet another case where $nullid can be used.
But it's also in repo picker code, so we don't have $nullid yet?
I'll rewrite somehow without $hashlength reference here, too.
(e.g. use the length of "git-rev-parse HEAD" output that is called
below)
> > [git rev-parse HEAD] 1]
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] git-gui: Add support of SHA256 repo
2025-07-15 14:18 ` Takashi Iwai
@ 2025-07-15 19:19 ` Johannes Sixt
2025-07-16 7:24 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Sixt @ 2025-07-15 19:19 UTC (permalink / raw)
To: Takashi Iwai; +Cc: git
Am 15.07.25 um 16:18 schrieb Takashi Iwai:
> On Mon, 14 Jul 2025 18:28:13 +0200,
>> BTW, there is a case
>>
>> if {[regexp {^[0-9a-f]{1,39}$} $head]}
>>
>> around line 3217 in git-gui.sh.
>
> Obviously I didn't look for numbers less than 40 :)
> I'll replace it, too.
>
> But I don't understand why it matches up to only 39, not 40 in the
> code above.
> It seems trying to get the proper hash id if it's no full length id?
> If so, the check should be rather like
> if {![regexp {^[0-9a-f]{40}$} $head]}
> ?? It makes the conversion a bit simpler.
Obviously, the code wants to turn abbreviated hashes to full hashes.
That can be skipped if it is already the full length. I haven't analyzed
why this is needed or desirable.
>>> @@ -879,7 +881,7 @@ method _do_clone_full_end {ok} {
>>> if {[file exists [gitdir FETCH_HEAD]]} {
>>> set fd [open [gitdir FETCH_HEAD] r]
>>> while {[gets $fd line] >= 0} {
>>> - if {[regexp "^(.{40})\t\t" $line line HEAD]} {
>>> + if {[regexp [string map "@@ $hashlength" "^(.{@@})\t\t"] $line line HEAD]} {
>>> break
>>> }
>>> }
>>
>> The repository picker dialog runs before $hashlength is set. Therefore,
>> at the time that this function is executed, $hashlength is not available.
>>
>> This procedure can depend on the file format, which is to have \t\t
>> after the hash regardless of its length.
>
> Oh that's bad. I'll rewrite without the reference to $hashlength.
> I guess we can simply replace the above with a range check {40,64}.
Yes, let's do that.
I had something like
set pos [string find \t\t $line]
if {pos > 0} {
set HEAD [string range $line 0 $pos]
break
}
in mind.
>>> @@ -986,7 +990,7 @@ method _readtree_wait {fd} {
>>>
>>> # -- Run the post-checkout hook.
>>> #
>>> - set fd_ph [githook_read post-checkout [string repeat 0 40] \
>>> + set fd_ph [githook_read post-checkout [string repeat 0 $hashlength] \
>>
>> Yet another case where $nullid can be used.
>
> But it's also in repo picker code, so we don't have $nullid yet?
> I'll rewrite somehow without $hashlength reference here, too.
> (e.g. use the length of "git-rev-parse HEAD" output that is called
> below)
>
>>> [git rev-parse HEAD] 1]
Good call, and good idea for a fix!
-- Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] git-gui: Add support of SHA256 repo
2025-07-15 19:19 ` Johannes Sixt
@ 2025-07-16 7:24 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2025-07-16 7:24 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Takashi Iwai, git
On Tue, 15 Jul 2025 21:19:38 +0200,
Johannes Sixt wrote:
>
> Am 15.07.25 um 16:18 schrieb Takashi Iwai:
> > On Mon, 14 Jul 2025 18:28:13 +0200,
> >> BTW, there is a case
> >>
> >> if {[regexp {^[0-9a-f]{1,39}$} $head]}
> >>
> >> around line 3217 in git-gui.sh.
> >
> > Obviously I didn't look for numbers less than 40 :)
> > I'll replace it, too.
> >
> > But I don't understand why it matches up to only 39, not 40 in the
> > code above.
> > It seems trying to get the proper hash id if it's no full length id?
> > If so, the check should be rather like
> > if {![regexp {^[0-9a-f]{40}$} $head]}
> > ?? It makes the conversion a bit simpler.
>
> Obviously, the code wants to turn abbreviated hashes to full hashes.
> That can be skipped if it is already the full length. I haven't analyzed
> why this is needed or desirable.
Maybe it wants only the abbreviated hashes and no other refs?
I'll keep the logic in v3 patch. If any, we can clean up later.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-16 7:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 12:04 [PATCH v2] git-gui: Add support of SHA256 repo Takashi Iwai
2025-07-14 16:28 ` Johannes Sixt
2025-07-15 14:18 ` Takashi Iwai
2025-07-15 19:19 ` Johannes Sixt
2025-07-16 7:24 ` Takashi Iwai
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).