threads / patch / 64434

patchmeson: make GIT_HTML_PATH configurable

Subject: [PATCH] meson: make GIT_HTML_PATH configurable

## tl;dr

10 messages between Nov 4, 2025 and Nov 11, 2025. Diffs are folded; open one to read it.

replies: 9people: 4as markdown or json

D. Ben Knoble· Nov 4, 2025, 13:58 UTC · lore

Makefile-based builds can configure Git's internal HTML_PATH by defining htmldir, which is useful for packagers that put documentation in different locations. Gentoo, for example, uses version-suffixed directories like ${prefix}/share/doc/git-2.51 and puts the HTML documentation in an 'html' subdirectory of the same.

Propagate the same configuration knob to Meson-based builds so that "git --html-path" on such systems can be configured to output the correct directory.

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
---
I've tested this with a modified live Gentoo ebuild [1] and had good results.
[1]: https://github.com/benknoble/gentoo-repo/commit/f2e6bbc8ec5e061a7f8151e56fa91a9d31b5b30b
 Documentation/howto/meson.build     |  4 ++--
 Documentation/meson.build           | 12 ++++++------
 Documentation/technical/meson.build |  4 ++--
 contrib/contacts/meson.build        |  2 +-
 contrib/subtree/meson.build         |  2 +-
 meson.build                         |  7 ++++++-
 meson_options.txt                   |  2 ++
 7 files changed, 20 insertions(+), 13 deletions(-)
Show changes to 7 files +20 −13

Documentation/howto/meson.build, Documentation/meson.build, Documentation/technical/meson.build, contrib/contacts/meson.build, contrib/subtree/meson.build, meson.build, meson_options.txt

diff --git a/Documentation/howto/meson.build b/Documentation/howto/meson.build
index ece20244af..16b9056f24 100644
--- a/Documentation/howto/meson.build
+++ b/Documentation/howto/meson.build
@@ -35,7 +35,7 @@ doc_targets += custom_target(
   output: 'howto-index.html',
   depends: documentation_deps,
   install: true,
-  install_dir: get_option('datadir') / 'doc/git-doc',
+  install_dir: htmldir,
 )
 
 foreach howto : howto_sources
@@ -57,6 +57,6 @@ foreach howto : howto_sources
     output: fs.stem(howto_stripped.full_path()) + '.html',
     depends: documentation_deps,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc/howto',
+    install_dir: htmldir / 'howto',
   )
 endforeach
diff --git a/Documentation/meson.build b/Documentation/meson.build
index 9d24f2da54..c00c9fe7f4 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -412,7 +412,7 @@ foreach manpage, category : manpages
       input: manpage,
       output: fs.stem(manpage) + '.html',
       install: true,
-      install_dir: get_option('datadir') / 'doc/git-doc',
+      install_dir: htmldir,
     )
   endif
 endforeach
@@ -423,7 +423,7 @@ if get_option('docs').contains('html')
     output: 'docinfo.html',
     copy: true,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   configure_file(
@@ -431,11 +431,11 @@ if get_option('docs').contains('html')
     output: 'docbook-xsl.css',
     copy: true,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   install_symlink('index.html',
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
     pointing_to: 'git.html',
   )
 
@@ -466,7 +466,7 @@ if get_option('docs').contains('html')
     input: 'docbook.xsl',
     output: 'user-manual.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   articles = [
@@ -492,7 +492,7 @@ if get_option('docs').contains('html')
       output: fs.stem(article) + '.html',
       depends: documentation_deps,
       install: true,
-      install_dir: get_option('datadir') / 'doc/git-doc',
+      install_dir: htmldir,
     )
   endforeach
 
diff --git a/Documentation/technical/meson.build b/Documentation/technical/meson.build
index be698ef22a..faff3964a9 100644
--- a/Documentation/technical/meson.build
+++ b/Documentation/technical/meson.build
@@ -53,7 +53,7 @@ doc_targets += custom_target(
   output: 'api-index.html',
   depends: documentation_deps,
   install: true,
-  install_dir: get_option('datadir') / 'doc/git-doc/technical',
+  install_dir: htmldir / 'technical',
 )
 
 foreach article : api_docs + articles
@@ -63,6 +63,6 @@ foreach article : api_docs + articles
     output: fs.stem(article) + '.html',
     depends: documentation_deps,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc/technical',
+    install_dir: htmldir / 'technical',
   )
 endforeach
diff --git a/contrib/contacts/meson.build b/contrib/contacts/meson.build
index c8fdb35ed9..4ae6b32a03 100644
--- a/contrib/contacts/meson.build
+++ b/contrib/contacts/meson.build
@@ -50,6 +50,6 @@ if get_option('docs').contains('html')
     input: 'git-contacts.adoc',
     output: 'git-contacts.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 endif
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
index 46cdbcc30c..161435abeb 100644
--- a/contrib/subtree/meson.build
+++ b/contrib/subtree/meson.build
@@ -68,6 +68,6 @@ if get_option('docs').contains('html')
     input: 'git-subtree.adoc',
     output: 'git-subtree.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 endif
diff --git a/meson.build b/meson.build
index 2b763f7c53..1f95a06edb 100644
--- a/meson.build
+++ b/meson.build
@@ -768,13 +768,18 @@ if test_output_directory == ''
   test_output_directory = meson.project_build_root() / 'test-output'
 endif
 
+htmldir = get_option('htmldir')
+if htmldir == ''
+  htmldir = get_option('datadir') / 'doc/git-doc'
+endif
+
 # These variables are used for building libgit.a.
 libgit_c_args = [
   '-DBINDIR="' + get_option('bindir') + '"',
   '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
   '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
   '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
-  '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
+  '-DGIT_HTML_PATH="' + htmldir + '"',
   '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
   '-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
   '-DGIT_MAN_PATH="' + get_option('mandir') + '"',
diff --git a/meson_options.txt b/meson_options.txt
index 143dee9237..13d421c067 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,8 @@
 # Configuration for Git installation
 option('perllibdir', type: 'string', value: '',
   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
+option('htmldir', type: 'string', value: '',
+  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
 
 # Configuration for how Git behaves at runtime.
 option('default_pager', type: 'string', value: 'less',

base-commit: 7f278e958afbf9b7e0727631b4c26dcfa1c63d6e
-- 
2.48.1
Junio C Hamano· Nov 4, 2025, 14:41 UTC · re: D. Ben Knoble · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

"D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
Show 12 quoted lines
> Makefile-based builds can configure Git's internal HTML_PATH by defining
> htmldir, which is useful for packagers that put documentation in
> different locations. Gentoo, for example, uses version-suffixed
> directories like ${prefix}/share/doc/git-2.51 and puts the HTML
> documentation in an 'html' subdirectory of the same.
>
> Propagate the same configuration knob to Meson-based builds so that
> "git --html-path" on such systems can be configured to output the
> correct directory.
>
> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
> ---

Makes sense (a more meson-minded person needs to double check my knee-jerk reaction, though). It is surprising that

    $ git grep "dir', " meson_options.txt
    meson_options.txt:option('perllibdir', type: 'string', value: '',

has only a single hit (now two), though. I thought we have a lot more flexibility in our build process.

I am also a bit surprised that these things are of type 'string'; I somehow was expecting that more modern build system would offer richer (relative to Makefile, that is) types like 'filename' or 'path'.

> I've tested this with a modified live Gentoo ebuild [1] and had good results.
Thanks.  Will queue and wait for others to chime in.
>
> [1]: https://github.com/benknoble/gentoo-repo/commit/f2e6bbc8ec5e061a7f8151e56fa91a9d31b5b30b
Show 169 quoted lines
>
>  Documentation/howto/meson.build     |  4 ++--
>  Documentation/meson.build           | 12 ++++++------
>  Documentation/technical/meson.build |  4 ++--
>  contrib/contacts/meson.build        |  2 +-
>  contrib/subtree/meson.build         |  2 +-
>  meson.build                         |  7 ++++++-
>  meson_options.txt                   |  2 ++
>  7 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/howto/meson.build b/Documentation/howto/meson.build
> index ece20244af..16b9056f24 100644
> --- a/Documentation/howto/meson.build
> +++ b/Documentation/howto/meson.build
> @@ -35,7 +35,7 @@ doc_targets += custom_target(
>    output: 'howto-index.html',
>    depends: documentation_deps,
>    install: true,
> -  install_dir: get_option('datadir') / 'doc/git-doc',
> +  install_dir: htmldir,
>  )
>  
>  foreach howto : howto_sources
> @@ -57,6 +57,6 @@ foreach howto : howto_sources
>      output: fs.stem(howto_stripped.full_path()) + '.html',
>      depends: documentation_deps,
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc/howto',
> +    install_dir: htmldir / 'howto',
>    )
>  endforeach
> diff --git a/Documentation/meson.build b/Documentation/meson.build
> index 9d24f2da54..c00c9fe7f4 100644
> --- a/Documentation/meson.build
> +++ b/Documentation/meson.build
> @@ -412,7 +412,7 @@ foreach manpage, category : manpages
>        input: manpage,
>        output: fs.stem(manpage) + '.html',
>        install: true,
> -      install_dir: get_option('datadir') / 'doc/git-doc',
> +      install_dir: htmldir,
>      )
>    endif
>  endforeach
> @@ -423,7 +423,7 @@ if get_option('docs').contains('html')
>      output: 'docinfo.html',
>      copy: true,
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>    )
>  
>    configure_file(
> @@ -431,11 +431,11 @@ if get_option('docs').contains('html')
>      output: 'docbook-xsl.css',
>      copy: true,
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>    )
>  
>    install_symlink('index.html',
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>      pointing_to: 'git.html',
>    )
>  
> @@ -466,7 +466,7 @@ if get_option('docs').contains('html')
>      input: 'docbook.xsl',
>      output: 'user-manual.html',
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>    )
>  
>    articles = [
> @@ -492,7 +492,7 @@ if get_option('docs').contains('html')
>        output: fs.stem(article) + '.html',
>        depends: documentation_deps,
>        install: true,
> -      install_dir: get_option('datadir') / 'doc/git-doc',
> +      install_dir: htmldir,
>      )
>    endforeach
>  
> diff --git a/Documentation/technical/meson.build b/Documentation/technical/meson.build
> index be698ef22a..faff3964a9 100644
> --- a/Documentation/technical/meson.build
> +++ b/Documentation/technical/meson.build
> @@ -53,7 +53,7 @@ doc_targets += custom_target(
>    output: 'api-index.html',
>    depends: documentation_deps,
>    install: true,
> -  install_dir: get_option('datadir') / 'doc/git-doc/technical',
> +  install_dir: htmldir / 'technical',
>  )
>  
>  foreach article : api_docs + articles
> @@ -63,6 +63,6 @@ foreach article : api_docs + articles
>      output: fs.stem(article) + '.html',
>      depends: documentation_deps,
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc/technical',
> +    install_dir: htmldir / 'technical',
>    )
>  endforeach
> diff --git a/contrib/contacts/meson.build b/contrib/contacts/meson.build
> index c8fdb35ed9..4ae6b32a03 100644
> --- a/contrib/contacts/meson.build
> +++ b/contrib/contacts/meson.build
> @@ -50,6 +50,6 @@ if get_option('docs').contains('html')
>      input: 'git-contacts.adoc',
>      output: 'git-contacts.html',
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>    )
>  endif
> diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
> index 46cdbcc30c..161435abeb 100644
> --- a/contrib/subtree/meson.build
> +++ b/contrib/subtree/meson.build
> @@ -68,6 +68,6 @@ if get_option('docs').contains('html')
>      input: 'git-subtree.adoc',
>      output: 'git-subtree.html',
>      install: true,
> -    install_dir: get_option('datadir') / 'doc/git-doc',
> +    install_dir: htmldir,
>    )
>  endif
> diff --git a/meson.build b/meson.build
> index 2b763f7c53..1f95a06edb 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -768,13 +768,18 @@ if test_output_directory == ''
>    test_output_directory = meson.project_build_root() / 'test-output'
>  endif
>  
> +htmldir = get_option('htmldir')
> +if htmldir == ''
> +  htmldir = get_option('datadir') / 'doc/git-doc'
> +endif
> +
>  # These variables are used for building libgit.a.
>  libgit_c_args = [
>    '-DBINDIR="' + get_option('bindir') + '"',
>    '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
>    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
>    '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
> -  '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
> +  '-DGIT_HTML_PATH="' + htmldir + '"',
>    '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
>    '-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
>    '-DGIT_MAN_PATH="' + get_option('mandir') + '"',
> diff --git a/meson_options.txt b/meson_options.txt
> index 143dee9237..13d421c067 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,6 +1,8 @@
>  # Configuration for Git installation
>  option('perllibdir', type: 'string', value: '',
>    description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
> +option('htmldir', type: 'string', value: '',
> +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
>  
>  # Configuration for how Git behaves at runtime.
>  option('default_pager', type: 'string', value: 'less',
>
> base-commit: 7f278e958afbf9b7e0727631b4c26dcfa1c63d6e
Ben Knoble· Nov 4, 2025, 16:47 UTC · re: Junio C Hamano · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

Show 25 quoted lines
> Le 4 nov. 2025 à 09:41, Junio C Hamano <gitster@pobox.com> a écrit :
> 
> "D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
> 
>> Makefile-based builds can configure Git's internal HTML_PATH by defining
>> htmldir, which is useful for packagers that put documentation in
>> different locations. Gentoo, for example, uses version-suffixed
>> directories like ${prefix}/share/doc/git-2.51 and puts the HTML
>> documentation in an 'html' subdirectory of the same.
>> 
>> Propagate the same configuration knob to Meson-based builds so that
>> "git --html-path" on such systems can be configured to output the
>> correct directory.
>> 
>> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
>> ---
> 
> Makes sense (a more meson-minded person needs to double check my
> knee-jerk reaction, though).  It is surprising that
> 
>    $ git grep "dir', " meson_options.txt
>    meson_options.txt:option('perllibdir', type: 'string', value: '',
> 
> has only a single hit (now two), though.  I thought we have a lot
> more flexibility in our build process.
I learned just enough Meson to write this; many of the other “dir” options are builtin for it. Try “meson configure”
Show 5 quoted lines
> 
> I am also a bit surprised that these things are of type 'string'; I
> somehow was expecting that more modern build system would offer
> richer (relative to Makefile, that is) types like 'filename' or
> 'path'.
Yea. At least there is a / operator to concatenate paths, but it looks like they are just strings on either side.  
> 
>> I've tested this with a modified live Gentoo ebuild [1] and had good results.
> 
> Thanks.  Will queue and wait for others to chime in.
Looking forward to it. 
Patrick Steinhardt· Nov 6, 2025, 07:51 UTC · re: Junio C Hamano · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

On Tue, Nov 04, 2025 at 06:41:06AM -0800, Junio C Hamano wrote:
Show 23 quoted lines
> "D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
> 
> > Makefile-based builds can configure Git's internal HTML_PATH by defining
> > htmldir, which is useful for packagers that put documentation in
> > different locations. Gentoo, for example, uses version-suffixed
> > directories like ${prefix}/share/doc/git-2.51 and puts the HTML
> > documentation in an 'html' subdirectory of the same.
> >
> > Propagate the same configuration knob to Meson-based builds so that
> > "git --html-path" on such systems can be configured to output the
> > correct directory.
> >
> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
> > ---
> 
> Makes sense (a more meson-minded person needs to double check my
> knee-jerk reaction, though).  It is surprising that 
> 
>     $ git grep "dir', " meson_options.txt
>     meson_options.txt:option('perllibdir', type: 'string', value: '',
> 
> has only a single hit (now two), though.  I thought we have a lot
> more flexibility in our build process.

That was a concious decision when I introduced Meson. The discussion back then was whether most of the build options that we have are even used anywhere, so we eventually agreed to only add options on an as-needed basis.

> I am also a bit surprised that these things are of type 'string'; I
> somehow was expecting that more modern build system would offer
> richer (relative to Makefile, that is) types like 'filename' or
> 'path'.

Meson provides tools to handle paths nicely [1], but it ultimately ends up using strings indeed.

[1]: https://mesonbuild.com/Fs-module.html
Patrick
Patrick Steinhardt· Nov 6, 2025, 07:51 UTC · re: D. Ben Knoble · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

On Tue, Nov 04, 2025 at 08:58:29AM -0500, D. Ben Knoble wrote:
Show 9 quoted lines
> Makefile-based builds can configure Git's internal HTML_PATH by defining
> htmldir, which is useful for packagers that put documentation in
> different locations. Gentoo, for example, uses version-suffixed
> directories like ${prefix}/share/doc/git-2.51 and puts the HTML
> documentation in an 'html' subdirectory of the same.
> 
> Propagate the same configuration knob to Meson-based builds so that
> "git --html-path" on such systems can be configured to output the
> correct directory.
Makes sense.
> diff --git a/Documentation/meson.build b/Documentation/meson.build
> index 9d24f2da54..c00c9fe7f4 100644
> --- a/Documentation/meson.build
> +++ b/Documentation/meson.build
All of the conversions look sensible to me.
Show 12 quoted lines
> diff --git a/meson.build b/meson.build
> index 2b763f7c53..1f95a06edb 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -768,13 +768,18 @@ if test_output_directory == ''
>    test_output_directory = meson.project_build_root() / 'test-output'
>  endif
>  
> +htmldir = get_option('htmldir')
> +if htmldir == ''
> +  htmldir = get_option('datadir') / 'doc/git-doc'
> +endif
This retains the status quo, good.
Show 10 quoted lines
> diff --git a/meson_options.txt b/meson_options.txt
> index 143dee9237..13d421c067 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,6 +1,8 @@
>  # Configuration for Git installation
>  option('perllibdir', type: 'string', value: '',
>    description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
> +option('htmldir', type: 'string', value: '',
> +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
Tiny nit: let's keep these options ordered lexicographically.
Other than that the patch looks good to me, thanks!
Patrick
Ben Knoble· Nov 6, 2025, 14:08 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

Show 50 quoted lines
> 
> Le 6 nov. 2025 à 02:51, Patrick Steinhardt <ps@pks.im> a écrit :
> 
> On Tue, Nov 04, 2025 at 08:58:29AM -0500, D. Ben Knoble wrote:
>> Makefile-based builds can configure Git's internal HTML_PATH by defining
>> htmldir, which is useful for packagers that put documentation in
>> different locations. Gentoo, for example, uses version-suffixed
>> directories like ${prefix}/share/doc/git-2.51 and puts the HTML
>> documentation in an 'html' subdirectory of the same.
>> 
>> Propagate the same configuration knob to Meson-based builds so that
>> "git --html-path" on such systems can be configured to output the
>> correct directory.
> 
> Makes sense.
> 
>> diff --git a/Documentation/meson.build b/Documentation/meson.build
>> index 9d24f2da54..c00c9fe7f4 100644
>> --- a/Documentation/meson.build
>> +++ b/Documentation/meson.build
> 
> All of the conversions look sensible to me.
> 
>> diff --git a/meson.build b/meson.build
>> index 2b763f7c53..1f95a06edb 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -768,13 +768,18 @@ if test_output_directory == ''
>>   test_output_directory = meson.project_build_root() / 'test-output'
>> endif
>> 
>> +htmldir = get_option('htmldir')
>> +if htmldir == ''
>> +  htmldir = get_option('datadir') / 'doc/git-doc'
>> +endif
> 
> This retains the status quo, good.
> 
>> diff --git a/meson_options.txt b/meson_options.txt
>> index 143dee9237..13d421c067 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -1,6 +1,8 @@
>> # Configuration for Git installation
>> option('perllibdir', type: 'string', value: '',
>>   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>> +option('htmldir', type: 'string', value: '',
>> +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
> 
> Tiny nit: let's keep these options ordered lexicographically.
Can do. Shall I send v2, Junio?
> 
> Other than that the patch looks good to me, thanks!
> 
> Patrick
Thank you!
Junio C Hamano· Nov 6, 2025, 15:29 UTC · re: Ben Knoble · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

Ben Knoble <ben.knoble@gmail.com> writes:
>> Tiny nit: let's keep these options ordered lexicographically.
>
> Can do. Shall I send v2, Junio?

We would soon be in pre-release freeze starting with -rc1 that would happen in a few hours, so there is no need to hurry. v2 after the final release is good enough.

D. Ben Knoble· Nov 11, 2025, 00:25 UTC · re: D. Ben Knoble · lore

Makefile-based builds can configure Git's internal HTML_PATH by defining htmldir, which is useful for packagers that put documentation in different locations. Gentoo, for example, uses version-suffixed directories like ${prefix}/share/doc/git-2.51 and puts the HTML documentation in an 'html' subdirectory of the same.

Propagate the same configuration knob to Meson-based builds so that "git --html-path" on such systems can be configured to output the correct directory.

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
---
Reorder options lexicographically for Patrick ;)
v1: https://lore.kernel.org/git/85992f6020703558f0ba75a1be6c4f9dae08b83.1762264709.git.ben.knoble+github@gmail.com
 Documentation/howto/meson.build     |  4 ++--
 Documentation/meson.build           | 12 ++++++------
 Documentation/technical/meson.build |  4 ++--
 contrib/contacts/meson.build        |  2 +-
 contrib/subtree/meson.build         |  2 +-
 meson.build                         |  7 ++++++-
 meson_options.txt                   |  2 ++
 7 files changed, 20 insertions(+), 13 deletions(-)
Show changes to 7 files +20 −13

Documentation/howto/meson.build, Documentation/meson.build, Documentation/technical/meson.build, contrib/contacts/meson.build, contrib/subtree/meson.build, meson.build, meson_options.txt

diff --git a/Documentation/howto/meson.build b/Documentation/howto/meson.build
index ece20244af..16b9056f24 100644
--- a/Documentation/howto/meson.build
+++ b/Documentation/howto/meson.build
@@ -35,7 +35,7 @@ doc_targets += custom_target(
   output: 'howto-index.html',
   depends: documentation_deps,
   install: true,
-  install_dir: get_option('datadir') / 'doc/git-doc',
+  install_dir: htmldir,
 )
 
 foreach howto : howto_sources
@@ -57,6 +57,6 @@ foreach howto : howto_sources
     output: fs.stem(howto_stripped.full_path()) + '.html',
     depends: documentation_deps,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc/howto',
+    install_dir: htmldir / 'howto',
   )
 endforeach
diff --git a/Documentation/meson.build b/Documentation/meson.build
index 9d24f2da54..c00c9fe7f4 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -412,7 +412,7 @@ foreach manpage, category : manpages
       input: manpage,
       output: fs.stem(manpage) + '.html',
       install: true,
-      install_dir: get_option('datadir') / 'doc/git-doc',
+      install_dir: htmldir,
     )
   endif
 endforeach
@@ -423,7 +423,7 @@ if get_option('docs').contains('html')
     output: 'docinfo.html',
     copy: true,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   configure_file(
@@ -431,11 +431,11 @@ if get_option('docs').contains('html')
     output: 'docbook-xsl.css',
     copy: true,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   install_symlink('index.html',
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
     pointing_to: 'git.html',
   )
 
@@ -466,7 +466,7 @@ if get_option('docs').contains('html')
     input: 'docbook.xsl',
     output: 'user-manual.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 
   articles = [
@@ -492,7 +492,7 @@ if get_option('docs').contains('html')
       output: fs.stem(article) + '.html',
       depends: documentation_deps,
       install: true,
-      install_dir: get_option('datadir') / 'doc/git-doc',
+      install_dir: htmldir,
     )
   endforeach
 
diff --git a/Documentation/technical/meson.build b/Documentation/technical/meson.build
index be698ef22a..faff3964a9 100644
--- a/Documentation/technical/meson.build
+++ b/Documentation/technical/meson.build
@@ -53,7 +53,7 @@ doc_targets += custom_target(
   output: 'api-index.html',
   depends: documentation_deps,
   install: true,
-  install_dir: get_option('datadir') / 'doc/git-doc/technical',
+  install_dir: htmldir / 'technical',
 )
 
 foreach article : api_docs + articles
@@ -63,6 +63,6 @@ foreach article : api_docs + articles
     output: fs.stem(article) + '.html',
     depends: documentation_deps,
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc/technical',
+    install_dir: htmldir / 'technical',
   )
 endforeach
diff --git a/contrib/contacts/meson.build b/contrib/contacts/meson.build
index c8fdb35ed9..4ae6b32a03 100644
--- a/contrib/contacts/meson.build
+++ b/contrib/contacts/meson.build
@@ -50,6 +50,6 @@ if get_option('docs').contains('html')
     input: 'git-contacts.adoc',
     output: 'git-contacts.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 endif
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
index 46cdbcc30c..161435abeb 100644
--- a/contrib/subtree/meson.build
+++ b/contrib/subtree/meson.build
@@ -68,6 +68,6 @@ if get_option('docs').contains('html')
     input: 'git-subtree.adoc',
     output: 'git-subtree.html',
     install: true,
-    install_dir: get_option('datadir') / 'doc/git-doc',
+    install_dir: htmldir,
   )
 endif
diff --git a/meson.build b/meson.build
index 2b763f7c53..1f95a06edb 100644
--- a/meson.build
+++ b/meson.build
@@ -768,13 +768,18 @@ if test_output_directory == ''
   test_output_directory = meson.project_build_root() / 'test-output'
 endif
 
+htmldir = get_option('htmldir')
+if htmldir == ''
+  htmldir = get_option('datadir') / 'doc/git-doc'
+endif
+
 # These variables are used for building libgit.a.
 libgit_c_args = [
   '-DBINDIR="' + get_option('bindir') + '"',
   '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
   '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
   '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
-  '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
+  '-DGIT_HTML_PATH="' + htmldir + '"',
   '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
   '-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
   '-DGIT_MAN_PATH="' + get_option('mandir') + '"',
diff --git a/meson_options.txt b/meson_options.txt
index 143dee9237..e0be260ae1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,6 @@
 # Configuration for Git installation
+option('htmldir', type: 'string', value: '',
+  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
 option('perllibdir', type: 'string', value: '',
   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
 

Diff-intervalle :
1:  385992f602 ! 1:  d6b86ed23e meson: make GIT_HTML_PATH configurable
    @@ meson.build: if test_output_directory == ''
      ## meson_options.txt ##
     @@
      # Configuration for Git installation
    - option('perllibdir', type: 'string', value: '',
    -   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
     +option('htmldir', type: 'string', value: '',
     +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
    + option('perllibdir', type: 'string', value: '',
    +   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
      
    - # Configuration for how Git behaves at runtime.
    - option('default_pager', type: 'string', value: 'less',

base-commit: 7f278e958afbf9b7e0727631b4c26dcfa1c63d6e
-- 
2.52.0.rc0.71.g03eda12af0.dirty
Karthik Nayak· Nov 11, 2025, 13:43 UTC · re: D. Ben Knoble · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

"D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
[snip]
Show 49 quoted lines
> diff --git a/meson.build b/meson.build
> index 2b763f7c53..1f95a06edb 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -768,13 +768,18 @@ if test_output_directory == ''
>    test_output_directory = meson.project_build_root() / 'test-output'
>  endif
>
> +htmldir = get_option('htmldir')
> +if htmldir == ''
> +  htmldir = get_option('datadir') / 'doc/git-doc'
> +endif
> +
>  # These variables are used for building libgit.a.
>  libgit_c_args = [
>    '-DBINDIR="' + get_option('bindir') + '"',
>    '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
>    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
>    '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
> -  '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
> +  '-DGIT_HTML_PATH="' + htmldir + '"',
>    '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
>    '-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
>    '-DGIT_MAN_PATH="' + get_option('mandir') + '"',
> diff --git a/meson_options.txt b/meson_options.txt
> index 143dee9237..e0be260ae1 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,4 +1,6 @@
>  # Configuration for Git installation
> +option('htmldir', type: 'string', value: '',
> +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
>  option('perllibdir', type: 'string', value: '',
>    description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>
>
> Diff-intervalle :
> 1:  385992f602 ! 1:  d6b86ed23e meson: make GIT_HTML_PATH configurable
>     @@ meson.build: if test_output_directory == ''
>       ## meson_options.txt ##
>      @@
>       # Configuration for Git installation
>     - option('perllibdir', type: 'string', value: '',
>     -   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>      +option('htmldir', type: 'string', value: '',
>      +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
>     + option('perllibdir', type: 'string', value: '',
>     +   description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>

I guess meson doesn't allow recursive dependency for build options? I was hoping we could do `value: get_option('datadir') / 'doc/git-doc'` and remove the custom block which checks for empty value above.

Anyways the patch looks good.
Show 6 quoted lines
>     - # Configuration for how Git behaves at runtime.
>     - option('default_pager', type: 'string', value: 'less',
>
> base-commit: 7f278e958afbf9b7e0727631b4c26dcfa1c63d6e
> --
> 2.52.0.rc0.71.g03eda12af0.dirty
D. Ben Knoble· Nov 11, 2025, 18:52 UTC · re: Karthik Nayak · lore

Re: [PATCH] meson: make GIT_HTML_PATH configurable

On Tue, Nov 11, 2025 at 8:43 AM Karthik Nayak <karthik.188@gmail.com> wrote:
Show 43 quoted lines
>
> "D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
>
> [snip]
>
> > diff --git a/meson.build b/meson.build
> > index 2b763f7c53..1f95a06edb 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -768,13 +768,18 @@ if test_output_directory == ''
> >    test_output_directory = meson.project_build_root() / 'test-output'
> >  endif
> >
> > +htmldir = get_option('htmldir')
> > +if htmldir == ''
> > +  htmldir = get_option('datadir') / 'doc/git-doc'
> > +endif
> > +
> >  # These variables are used for building libgit.a.
> >  libgit_c_args = [
> >    '-DBINDIR="' + get_option('bindir') + '"',
> >    '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
> >    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
> >    '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
> > -  '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
> > +  '-DGIT_HTML_PATH="' + htmldir + '"',
> >    '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
> >    '-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
> >    '-DGIT_MAN_PATH="' + get_option('mandir') + '"',
> > diff --git a/meson_options.txt b/meson_options.txt
> > index 143dee9237..e0be260ae1 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -1,4 +1,6 @@
> >  # Configuration for Git installation
> > +option('htmldir', type: 'string', value: '',
> > +  description: 'Directory to install HTML docs to. Defaults to <datadir>/doc/git-doc')
> >  option('perllibdir', type: 'string', value: '',
> >    description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>
> I guess meson doesn't allow recursive dependency for build options? I
> was hoping we could do `value: get_option('datadir') / 'doc/git-doc'`
> and remove the custom block which checks for empty value above.

The documentation [1] did not suggest that "default" could be evaluated as an expression here, and I copied the pattern from perllibdir [2]. If there's an alternative, I'm all ears.

[1]: https://mesonbuild.com/Build-options.html [2]: https://github.com/git/git/blob/4badef0c3503dc29059d678abba7fac0f042bc84/meson.build#L1972-L1975

> Anyways the patch looks good.
Thanks!

← back to recent threads