Re: [PATCH v2] gitk: Add support of SHA256 repo
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Jul 14, 2025, 16:52 UTC
- Message-ID
- <878b4335-873c-4bc5-a7c1-581d3a71901e@kdbg.org>
- In-Reply-To
- <20250617055957.9794-1-tiwai@suse.de>
Am 17.06.25 um 07:59 schrieb Takashi Iwai:
Show 30 quoted lines
> This patch adds a basic support of SHA256 Git repository to Gitk, so > that Gitk can show and operate on both SHA1 and SHA256 repos > gracefully. Since SHA256 has a longer ID length (64 char) than SHA1 > (40 char), many field widths are adjusted to fit with it. > > A caveat is that the configuration of auto selection length is shared > between SHA1 and SHA256 repos. That is, once when this value is saved > and read, it's applied to both repo types, which may result in shorter > selection than the full SHA256 ID. We may introduce another > individual config for sha256 (actually I did write in the first > version), but for simplicity, the common config is used as of writing > this. > > Many lines still refer "sha1" although they may point to both SHA1 and > SHA256. They are left untouched for making the changes simpler. > > This patch is based on the early work by Rostislav Krasny: > https://patchwork.kernel.org/project/git/patch/pull.979.git.1623687519832.gitgitgadget@gmail.com > I refreshed, revised and extended to the latest state. > > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > > v1: https://lore.kernel.org/20250320154136.23262-1-tiwai@suse.de > v1->v2: > - Fix other procs using fixed 40 length > - Don't use tabs > - Drop autosellensha256 config > - Some code simplification > - Fix patch description
Thank you for the update. I'll queue this patch, but...
Show 18 quoted lines
> @@ -12491,6 +12513,17 @@ if {$tclencoding == {}} {
> puts stderr "Warning: encoding $gitencoding is not supported by Tcl/Tk"
> }
>
> +# 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
> +}
> +
> set gui_encoding [encoding system]
> catch {
> set enc [exec git config --get gui.encoding]... I'll move the setup of $hashlength after the gui_encoding setup that is visible in the context, so that the new code is not in the middle of the encoding section.
-- Hannes