git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 2, 2025, 07:04 UTC
Message-ID
<xmqqjyz58ivh.fsf@gitster.g>
In-Reply-To
<20251202014605.52110-2-sandals@crustytoothpaste.net>
"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(-)
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`::
Previous: brian m. carlsonNext: brian m. carlson
Message 4 of 8 in “Fix doc default hash algorithm in WITH_BREAKING_CHANGES mode”
  1. 0/4 Fix doc default hash algorithm in WITH_BREAKING_CHANGES modebrian m. carlson, Dec 2, 2025
  2. 4/4 docs: update show-index hash algorithm for breaking changes modebrian m. carlson, Dec 2, 2025
  3. 1/4 docs: update git hash algorithm for breaking changes modebrian m. carlson, Dec 2, 2025
  4. Junio C HamanoDec 2, 2025
  5. 2/4 docs: update index-pack hash algorithm for breaking changes modebrian m. carlson, Dec 2, 2025
  6. 3/4 docs: update init hash algorithm for breaking changes modebrian m. carlson, Dec 2, 2025
  7. Patrick SteinhardtDec 2, 2025
  8. brian m. carlsonDec 2, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.