threads / patch / 64563

patch, 4 partsdocs: update show-index hash algorithm for breaking changes mode

Subject: [PATCH 4/4] docs: update show-index hash algorithm for breaking changes mode

## tl;dr

8 messages between Dec 2, 2025 and Dec 2, 2025. Diffs are folded; open one to read it.

replies: 7people: 3as markdown or json

brian m. carlson· Dec 2, 2025, 01:46 UTC · lore

[PATCH 0/4] Fix doc default hash algorithm in WITH_BREAKING_CHANGES mode

When WITH_BREAKING_CHANGES is defined, the default hash algorithm is not SHA-1, but SHA-256. However, our documentation was never updated to reflect this, and as a result, we end up misinforming users.

This series fixes four places where we indicate a default hash algorithm in our documentation such that they conditionally say that either SHA-1 or SHA-256 is the default, based on the the with-breaking-changes attribute. This both improves accuracy now and also makes it less likely that we'll forget to update these places when we hit Git 3.0.

brian m. carlson (4):
  docs: update git hash algorithm for breaking changes mode
  docs: update index-pack hash algorithm for breaking changes mode
  docs: update init hash algorithm for breaking changes mode
  docs: update show-index hash algorithm for breaking changes mode
 Documentation/git-index-pack.adoc | 14 +++++++++++---
 Documentation/git-init.adoc       |  8 +++++++-
 Documentation/git-show-index.adoc | 14 +++++++++++---
 Documentation/git.adoc            |  8 +++++++-
 4 files changed, 36 insertions(+), 8 deletions(-)
brian m. carlson· Dec 2, 2025, 01:46 UTC · re: brian m. carlson · lore

When compiled with WITH_BREAKING_CHANGES, the default hash algorithm switches to SHA-256, but the documentation doesn't reflect this. Update the show-index manual page to reflect the correct algorithm in this case.

Be sure to conditionalize only full sentences to aid in localization.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git-show-index.adoc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Show changes to Documentation/git-show-index.adoc +11 −3
diff --git a/Documentation/git-show-index.adoc b/Documentation/git-show-index.adoc
index 00b3a908cd..af5c114bb8 100644
--- a/Documentation/git-show-index.adoc
+++ b/Documentation/git-show-index.adoc
@@ -41,9 +41,17 @@ OPTIONS
 
 --object-format=<hash-algorithm>::
 	Specify the given object format (hash algorithm) for the index file.  The
-	valid values are 'sha1' and (if enabled) 'sha256'.  The default is the
-	algorithm for the current repository (set by `extensions.objectFormat`), or
-	'sha1' if no value is set or outside a repository..
+	valid values are 'sha1' and (if enabled) 'sha256'.
+ifndef::with-breaking-changes[]
+	The default is the algorithm for the current repository (set by
+	`extensions.objectFormat`), or 'sha1' if no value is set or outside a
+	repository.
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+	The default is the algorithm for the current repository (set by
+	`extensions.objectFormat`), or 'sha256' if no value is set or outside a
+	repository.
+endif::with-breaking-changes[]
 +
 include::object-format-disclaimer.adoc[]
 
brian m. carlson· Dec 2, 2025, 01:46 UTC · re: brian m. carlson · lore

[PATCH 1/4] docs: update git hash algorithm for breaking changes mode

When compiled with WITH_BREAKING_CHANGES, the default hash algorithm switches to SHA-256, but the documentation doesn't reflect this. Update the main git manual page to reflect the correct algorithm in this case.

Be sure to conditionalize only full sentences to aid in localization.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git.adoc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Show changes to Documentation/git.adoc +7 −1
diff --git a/Documentation/git.adoc b/Documentation/git.adoc
index ce099e78b8..6123ebcb1b 100644
--- a/Documentation/git.adoc
+++ b/Documentation/git.adoc
@@ -576,7 +576,13 @@ double-quotes and respecting backslash escapes. E.g., the value
 	If this variable is set, the default hash algorithm for new
 	repositories will be set to this value. This value is
 	ignored when cloning and the setting of the remote repository
-	is always used. The default is "sha1".
+	is always used.
+ifndef::with-breaking-changes[]
+	The default is "sha1".
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+	The default is "sha256".
+endif::with-breaking-changes[]
 	See `--object-format` in linkgit:git-init[1].
 
 `GIT_DEFAULT_REF_FORMAT`::
Junio C Hamano· Dec 2, 2025, 07:04 UTC · re: brian m. carlson · lore

Re: [PATCH 1/4] docs: update git hash algorithm for breaking changes mode

"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 9 quoted lines
> +ifndef::with-breaking-changes[]
> +	The default is "sha1".
> +endif::with-breaking-changes[]
> +ifdef::with-breaking-changes[]
> +	The default is "sha256".
> +endif::with-breaking-changes[]
>  	See `--object-format` in linkgit:git-init[1].
>  
>  `GIT_DEFAULT_REF_FORMAT`::

I wonder if we can have a macro definition at a central location, so that we can refer to the text without "ifdef" everywhere?

Caution: this illustration of the idea seems to work with AsciiDoc
but it was typed in an airline lounge with rum-and-coke in my left
hand and haven't been tested with Asciidoctor at all.  I do not even
understand why many other [attributes] entries like {asterisk} can
successfully be grokked by Asciidoctor, but we seem to do -alitdd=<>
in the Makefile for Asciidoctor, so I mimicked it without fully
understanding what is going on.
But the patch should be good enough to illustrate the idea.
 Documentation/Makefile         | 5 +++++
 Documentation/asciidoc.conf.in | 6 ++++++
 Documentation/git.adoc         | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)
Show changes to diff +12 −1
diff --git c/Documentation/Makefile w/Documentation/Makefile
index 04e9e10b27..88b8ed55a2 100644
--- c/Documentation/Makefile
+++ w/Documentation/Makefile
@@ -222,6 +222,11 @@ ASCIIDOC_DOCBOOK = docbook5
 ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
+ifdef WITH_BREAKING_CHANGES
+ASCIIDOC_EXTRA += -adefaulthash=sha256
+else
+ASCIIDOC_EXTRA += -adefaulthash=sha1
+endif
 ASCIIDOC_EXTRA += -adocinfo=shared
 ASCIIDOC_DEPS = asciidoctor-extensions.rb GIT-ASCIIDOCFLAGS
 DBLATEX_COMMON =
diff --git c/Documentation/asciidoc.conf.in w/Documentation/asciidoc.conf.in
index ff9ea0a294..2de6b80197 100644
--- c/Documentation/asciidoc.conf.in
+++ w/Documentation/asciidoc.conf.in
@@ -24,6 +24,12 @@ litdd=&#45;&#45;
 manmanual=Git Manual
 mansource=Git @GIT_VERSION@
 revdate=@GIT_DATE@
+ifdef::with-breaking-changes[]
+defaulthash=sha256
+endif::with-breaking-changes[]
+ifndef::with-breaking-changes[]
+defaulthash=sha1
+endif::with-breaking-changes[]
 
 ifdef::doctype-book[]
 [titles]
diff --git c/Documentation/git.adoc w/Documentation/git.adoc
index 8c6a3f6042..f21dbba5a1 100644
--- c/Documentation/git.adoc
+++ w/Documentation/git.adoc
@@ -576,7 +576,7 @@ double-quotes and respecting backslash escapes. E.g., the value
 	If this variable is set, the default hash algorithm for new
 	repositories will be set to this value. This value is
 	ignored when cloning and the setting of the remote repository
-	is always used. The default is "sha1".
+	is always used. The default is "{defaulthash}".
 	See `--object-format` in linkgit:git-init[1].
 
 `GIT_DEFAULT_REF_FORMAT`::
brian m. carlson· Dec 2, 2025, 01:46 UTC · re: brian m. carlson · lore

[PATCH 2/4] docs: update index-pack hash algorithm for breaking changes mode

When compiled with WITH_BREAKING_CHANGES, the default hash algorithm switches to SHA-256, but the documentation doesn't reflect this. Update the index-pack manual page to reflect the correct algorithm in this case.

Be sure to conditionalize only full sentences to aid in localization.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git-index-pack.adoc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Show changes to Documentation/git-index-pack.adoc +11 −3
diff --git a/Documentation/git-index-pack.adoc b/Documentation/git-index-pack.adoc
index 18036953c0..8f05f5494d 100644
--- a/Documentation/git-index-pack.adoc
+++ b/Documentation/git-index-pack.adoc
@@ -125,9 +125,17 @@ information on the possible values of `<msg-id>` and `<severity>`.
 
 --object-format=<hash-algorithm>::
 	Specify the given object format (hash algorithm) for the pack.  The valid
-	values are 'sha1' and (if enabled) 'sha256'.  The default is the algorithm for
-	the current repository (set by `extensions.objectFormat`), or 'sha1' if no
-	value is set or outside a repository.
+	values are 'sha1' and (if enabled) 'sha256'.
+ifndef::with-breaking-changes[]
+	The default is the algorithm for the current repository (set by
+	`extensions.objectFormat`), or 'sha1' if no value is set or outside a
+	repository.
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+	The default is the algorithm for the current repository (set by
+	`extensions.objectFormat`), or 'sha256' if no value is set or outside a
+	repository.
+endif::with-breaking-changes[]
 +
 This option cannot be used with --stdin.
 +
brian m. carlson· Dec 2, 2025, 01:46 UTC · re: brian m. carlson · lore

[PATCH 3/4] docs: update init hash algorithm for breaking changes mode

When compiled with WITH_BREAKING_CHANGES, the default hash algorithm switches to SHA-256, but the documentation doesn't reflect this. Update the init manual page to reflect the correct algorithm in this case.

Be sure to conditionalize only full sentences to aid in localization.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git-init.adoc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Show changes to Documentation/git-init.adoc +7 −1
diff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc
index bab99b9b47..17dfef4654 100644
--- a/Documentation/git-init.adoc
+++ b/Documentation/git-init.adoc
@@ -53,7 +53,13 @@ current working directory.
 
 `--object-format=<format>`::
 Specify the given object _<format>_ (hash algorithm) for the repository.  The valid
-values are `sha1` and (if enabled) `sha256`.  `sha1` is the default.
+values are `sha1` and (if enabled) `sha256`.
+ifndef::with-breaking-changes[]
+	`sha1` is the default.
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+	`sha256` is the default.
+endif::with-breaking-changes[]
 +
 include::object-format-disclaimer.adoc[]
 
Patrick Steinhardt· Dec 2, 2025, 08:18 UTC · re: brian m. carlson · lore

Re: [PATCH 0/4] Fix doc default hash algorithm in WITH_BREAKING_CHANGES mode

On Tue, Dec 02, 2025 at 01:46:01AM +0000, brian m. carlson wrote:
Show 9 quoted lines
> When WITH_BREAKING_CHANGES is defined, the default hash algorithm is not
> SHA-1, but SHA-256.  However, our documentation was never updated to
> reflect this, and as a result, we end up misinforming users.
> 
> This series fixes four places where we indicate a default hash algorithm
> in our documentation such that they conditionally say that either SHA-1
> or SHA-256 is the default, based on the the with-breaking-changes
> attribute.  This both improves accuracy now and also makes it less
> likely that we'll forget to update these places when we hit Git 3.0.

All of these look good to me. One alternative would be to introduce an attribute that we can then reference in the docs. The below patch shows how to do this with Asciidoc, but of course we'd also have to do this for Asciidoctor.

I don't mind much which approach we use, but wanted to suggest this as an alternative.

Thanks!
Patrick
Show changes to 2 files +7 −1

Documentation/asciidoc.conf.in, Documentation/git-index-pack.adoc

diff --git a/Documentation/asciidoc.conf.in b/Documentation/asciidoc.conf.in
index ff9ea0a294..fe1c150ec6 100644
--- a/Documentation/asciidoc.conf.in
+++ b/Documentation/asciidoc.conf.in
@@ -24,6 +24,12 @@ litdd=&#45;&#45;
 manmanual=Git Manual
 mansource=Git @GIT_VERSION@
 revdate=@GIT_DATE@
+ifndef::with-breaking-changes[]
+default-hash-algo=sha1
+endif::with-breaking-changes[]
+ifdef::with-breaking-changes[]
+default-hash-algo=sha256
+endif::with-breaking-changes[]
 
 ifdef::doctype-book[]
 [titles]
diff --git a/Documentation/git-index-pack.adoc b/Documentation/git-index-pack.adoc
index 18036953c0..730c3835e6 100644
--- a/Documentation/git-index-pack.adoc
+++ b/Documentation/git-index-pack.adoc
@@ -126,7 +126,7 @@ information on the possible values of `<msg-id>` and `<severity>`.
 --object-format=<hash-algorithm>::
 	Specify the given object format (hash algorithm) for the pack.  The valid
 	values are 'sha1' and (if enabled) 'sha256'.  The default is the algorithm for
-	the current repository (set by `extensions.objectFormat`), or 'sha1' if no
+	the current repository (set by `extensions.objectFormat`), or '{default-hash-algo}' if no
 	value is set or outside a repository.
 +
 This option cannot be used with --stdin.
brian m. carlson· Dec 2, 2025, 11:52 UTC · re: Patrick Steinhardt · lore

Re: [PATCH 0/4] Fix doc default hash algorithm in WITH_BREAKING_CHANGES mode

On 2025-12-02 at 08:18:25, Patrick Steinhardt wrote:
Show 18 quoted lines
> On Tue, Dec 02, 2025 at 01:46:01AM +0000, brian m. carlson wrote:
> > When WITH_BREAKING_CHANGES is defined, the default hash algorithm is not
> > SHA-1, but SHA-256.  However, our documentation was never updated to
> > reflect this, and as a result, we end up misinforming users.
> > 
> > This series fixes four places where we indicate a default hash algorithm
> > in our documentation such that they conditionally say that either SHA-1
> > or SHA-256 is the default, based on the the with-breaking-changes
> > attribute.  This both improves accuracy now and also makes it less
> > likely that we'll forget to update these places when we hit Git 3.0.
> 
> All of these look good to me. One alternative would be to introduce an
> attribute that we can then reference in the docs. The below patch shows
> how to do this with Asciidoc, but of course we'd also have to do this
> for Asciidoctor.
> 
> I don't mind much which approach we use, but wanted to suggest this as
> an alternative.

I think it may be easier to set this in the Makefile and Meson config, but I'll try to see if I can adopt a similar approach here and if so, I'll send a v2.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

← back to recent threads