Skip to contentSkip to conversation

Modernize the build system

RFC PATCH Superseded Patrick Steinhardt 13 participants 386 messages Oct 2, 2024 – Jan 17, 2025 Page 1 of 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Modernize the build system

Hi,

this patch series wires up support for the Meson build system. It is intended as a request for comments and acts based on the feedback I've got during the Git contributor's summit and the discussion in [1].

The aim of the patch series is to modernize our build system and set us up such that we can eventually replace the autoconf- and Makefile-based build system that we have right now with a more modern alternative. As a result I'm hoping for the build system to become easier to hack on and use, have better integration and be faster.

This patch series is rather large. It is structured as follows:

- Patch 1 introduces a comparison of viable build systems. In its current form, the document is of course rather biased because I am its author. I am very happy to receive feedback on it to add factors that I didn't mention yet.

- Patches 2 to 9 fix various different bugs I have found while working on many different platforms. They can likely go into the tree separately, and I'm happy to split these out into a separate patch series if we want to.

- Patches 10 to 20 refactor parts of our preexisting build systems and testing infrastructure to provide better support for out-of-tree builds. While we already have CMake build instructions in our tree, they do not currently have "proper" out-of-tree builds as they still end up writing data into the source directory. So while these patches are written with Meson in mind, they should also help CMake. As a result of these patches, Meson builds and test runs are fully self-contained.

- Patch 21 implements support for Meson. This is a big change, but more than half of the lines can be attributed to file listings. I have tested the build instructions on Linux, FreeBSD, macOS and Windows. Not all of the platforms pass all of the tests, and I did not yet get to integrating all of this with MSVC on Windows. Windows is quite foreign to me, and I spent the last two days ripping my hair out trying to get everything set up there, so this port is still a bit more on the rough side. In any case, if we decide that Meson might be a viable build system for us I will address those shortcomings, but in the RFC phase I didn't want perfect to be the enemy of good.

As I've said multiple times, I am strongly in favor of Meson over CMake, and that's why I invested as much time as I did to wire it up this extensively. But it goes without saying that this of course doesn't mean that the project cannot come to a different conclusion than I did.

The patch series is built on top of e9356ba3ea (another batch after 2.47-rc0, 2024-09-30).

Thanks!

[1]: <GV1PR02MB848925A79A9DD733848182D58D662@GV1PR02MB8489.eurprd02.prod.outlook.com>

Patrick Steinhardt (21):
Documentation: add comparison of build systems t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE t/lib-gitweb: test against the build version of gitweb t/lib-gpg: fix setup of GNUPGHOME in MinGW
t3404: work around platform-specific behaviour on macOS 10.15 t/unit-tests: update clar unit test framework
t/clar: simplify how the clar derives struct stat builtin/credential-cache: fix missing parameter for stub function
http: fix build error on FreeBSD
Makefile: extract script to generate clar declarations
Makefile: extract script to massage Perl scripts
Makefile: refactor GIT-VERSION-GEN to be reusable
Makefile: refactor generators to be PWD-independent
Makefile: use common template for GIT-BUILD-OPTIONS
Makefile: consistently use @PLACEHOLDER@ to substitute
Makefile: consistently use PERL_PATH
Makefile: allow "bin-wrappers/" directory to exist
Makefile: simplify building of templates
t: better support for out-of-tree builds
t: allow overriding build dir
Introduce support for the Meson build system

 .gitignore                                    |    1 -
 Documentation/CodingGuidelines                |    2 +-
 Documentation/Makefile                        |    1 +
 Documentation/technical/build-systems.txt     |  164 ++
 GIT-BUILD-OPTIONS.in                          |   40 +
 GIT-VERSION-GEN                               |   12 +-
 Makefile                                      |  186 +-
 bin-wrappers/.gitignore                       |    9 +
 bin-wrappers/meson.build                      |   28 +
 bin-wrappers/wrap-for-bin.sh                  |   37 +
 builtin/credential-cache.c                    |    3 +-
 configure.ac                                  |    2 +-
 contrib/buildsystems/CMakeLists.txt           |  129 +-
 contrib/completion/meson.build                |    8 +
 contrib/meson.build                           |    1 +
 generate-cmdlist.sh                           |   42 +-
 generate-configlist.sh                        |   20 +-
 generate-hooklist.sh                          |   15 +-
 generate-perl.sh                              |   22 +
 git-cvsserver.perl                            |    2 +-
 git-instaweb.sh                               |    8 +-
 git-request-pull.sh                           |    2 +-
 git-send-email.perl                           |    2 +-
 git-sh-i18n.sh                                |    6 +-
 git-sh-setup.sh                               |    6 +-
 git-svn.perl                                  |    2 +-
 gitk-git/po/vi.po                             |    2 +-
 gitweb/Makefile                               |   44 +-
 gitweb/gitweb.perl                            |   44 +-
 gitweb/meson.build                            |   32 +
 gitweb/static/meson.build                     |   28 +
 http.c                                        |   10 +-
 meson.build                                   | 1567 +++++++++++++++++
 meson_options.txt                             |   67 +
 perl/FromCPAN/Mail/meson.build                |    7 +
 perl/FromCPAN/meson.build                     |    9 +
 perl/Git/I18N.pm                              |    6 +-
 perl/Git/LoadCPAN.pm                          |    6 +-
 perl/Git/LoadCPAN/Mail/meson.build            |    7 +
 perl/Git/LoadCPAN/meson.build                 |    9 +
 perl/Git/SVN/Memoize/meson.build              |    7 +
 perl/Git/SVN/meson.build                      |   20 +
 perl/Git/meson.build                          |   18 +
 .../header_templates/fixed_prefix.template.pl |    2 +-
 .../runtime_prefix.template.pl                |    8 +-
 perl/meson.build                              |   18 +
 po/meson.build                                |   28 +
 t/helper/meson.build                          |   91 +
 t/lib-gettext.sh                              |    4 +-
 t/lib-gitweb.sh                               |    2 +-
 t/lib-gpg.sh                                  |    2 +-
 t/meson.build                                 | 1107 ++++++++++++
 t/t3404-rebase-interactive.sh                 |   38 +-
 t/t7609-mergetool--lib.sh                     |    2 +-
 t/test-lib.sh                                 |   24 +-
 t/unit-tests/clar/.editorconfig               |   13 +
 t/unit-tests/clar/.github/workflows/ci.yml    |   20 +-
 t/unit-tests/clar/.gitignore                  |    1 +
 t/unit-tests/clar/CMakeLists.txt              |   28 +
 t/unit-tests/clar/clar.c                      |  111 +-
 t/unit-tests/clar/clar/print.h                |   11 +-
 t/unit-tests/clar/clar/sandbox.h              |   17 +-
 t/unit-tests/clar/clar/summary.h              |   14 +-
 t/unit-tests/clar/test/.gitignore             |    4 -
 t/unit-tests/clar/test/CMakeLists.txt         |   41 +
 t/unit-tests/clar/test/Makefile               |   39 -
 t/unit-tests/generate-clar-decls.sh           |   16 +
 templates/Makefile                            |   38 +-
 templates/branches--                          |    1 -
 templates/{this--description => description}  |    0
 .../applypatch-msg.sample}                    |    0
 .../commit-msg.sample}                        |    0
 .../fsmonitor-watchman.sample}                |    0
 templates/hooks/meson.build                   |   24 +
 .../post-update.sample}                       |    0
 .../pre-applypatch.sample}                    |    0
 .../pre-commit.sample}                        |    0
 .../pre-merge-commit.sample}                  |    0
 .../pre-push.sample}                          |    0
 .../pre-rebase.sample}                        |    0
 .../pre-receive.sample}                       |    0
 .../prepare-commit-msg.sample}                |    0
 .../push-to-checkout.sample}                  |    0
 .../sendemail-validate.sample}                |    0
 .../update.sample}                            |    0
 templates/{info--exclude => info/exclude}     |    0
 templates/info/meson.build                    |    5 +
 templates/meson.build                         |    8 +
 unimplemented.sh                              |    2 +-
 wrap-for-bin.sh                               |   36 -
 90 files changed, 3901 insertions(+), 487 deletions(-)
 create mode 100644 Documentation/technical/build-systems.txt
 create mode 100644 GIT-BUILD-OPTIONS.in
 create mode 100644 bin-wrappers/.gitignore
 create mode 100644 bin-wrappers/meson.build
 create mode 100755 bin-wrappers/wrap-for-bin.sh
 create mode 100644 contrib/completion/meson.build
 create mode 100644 contrib/meson.build
 create mode 100755 generate-perl.sh
 create mode 100644 gitweb/meson.build
 create mode 100644 gitweb/static/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 perl/FromCPAN/Mail/meson.build
 create mode 100644 perl/FromCPAN/meson.build
 create mode 100644 perl/Git/LoadCPAN/Mail/meson.build
 create mode 100644 perl/Git/LoadCPAN/meson.build
 create mode 100644 perl/Git/SVN/Memoize/meson.build
 create mode 100644 perl/Git/SVN/meson.build
 create mode 100644 perl/Git/meson.build
 create mode 100644 perl/meson.build
 create mode 100644 po/meson.build
 create mode 100644 t/helper/meson.build
 create mode 100644 t/meson.build
 create mode 100644 t/unit-tests/clar/.editorconfig
 create mode 100644 t/unit-tests/clar/.gitignore
 create mode 100644 t/unit-tests/clar/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/Makefile
 create mode 100755 t/unit-tests/generate-clar-decls.sh
 delete mode 100644 templates/branches--
 rename templates/{this--description => description} (100%)
 rename templates/{hooks--applypatch-msg.sample => hooks/applypatch-msg.sample} (100%)
 rename templates/{hooks--commit-msg.sample => hooks/commit-msg.sample} (100%)
 rename templates/{hooks--fsmonitor-watchman.sample => hooks/fsmonitor-watchman.sample} (100%)
 create mode 100644 templates/hooks/meson.build
 rename templates/{hooks--post-update.sample => hooks/post-update.sample} (100%)
 rename templates/{hooks--pre-applypatch.sample => hooks/pre-applypatch.sample} (100%)
 rename templates/{hooks--pre-commit.sample => hooks/pre-commit.sample} (100%)
 rename templates/{hooks--pre-merge-commit.sample => hooks/pre-merge-commit.sample} (100%)
 rename templates/{hooks--pre-push.sample => hooks/pre-push.sample} (100%)
 rename templates/{hooks--pre-rebase.sample => hooks/pre-rebase.sample} (100%)
 rename templates/{hooks--pre-receive.sample => hooks/pre-receive.sample} (100%)
 rename templates/{hooks--prepare-commit-msg.sample => hooks/prepare-commit-msg.sample} (100%)
 rename templates/{hooks--push-to-checkout.sample => hooks/push-to-checkout.sample} (100%)
 rename templates/{hooks--sendemail-validate.sample => hooks/sendemail-validate.sample} (100%)
 rename templates/{hooks--update.sample => hooks/update.sample} (100%)
 rename templates/{info--exclude => info/exclude} (100%)
 create mode 100644 templates/info/meson.build
 create mode 100644 templates/meson.build
 delete mode 100644 wrap-for-bin.sh
Signature · 1 line
2.47.0.rc0.dirty
#1 lore raw

RFC PATCH 1/21 Documentation: add comparison of build systems

We're contemplating whether to eventually replace our build systems with a build system that is easier to use. Add a comparison of build systems to our technical documentation as a baseline for discussion.

---
 Documentation/Makefile                    |   1 +
 Documentation/technical/build-systems.txt | 164 ++++++++++++++++++++++
 2 files changed, 165 insertions(+)
 create mode 100644 Documentation/technical/build-systems.txt
Documentation/Makefile +1 -0
index 0f55baa252..e23cffb5f9 100644
@@ -111,6 +111,7 @@ TECH_DOCS += MyFirstObjectWalk
 TECH_DOCS += SubmittingPatches
 TECH_DOCS += ToolsForGit
 TECH_DOCS += technical/bitmap-format
+TECH_DOCS += technical/build-systems
 TECH_DOCS += technical/bundle-uri
 TECH_DOCS += technical/hash-function-transition
 TECH_DOCS += technical/long-running-process-protocol
Documentation/technical/build-systems.txt new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
2.47.0.rc0.dirty
#2 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

Quoted 6 lines · Patrick Steinhardt

We're contemplating whether to eventually replace our build systems with a build system that is easier to use. Add a comparison of build systems to our technical documentation as a baseline for discussion.

---

Thanks for starting this.

Documentation/technical/build-systems.txt line 5

Quoted 11 lines
Documentation/technical/build-systems.txt new file +5 -0
new file mode 100644
index 0000000000..8fac36ce1d
@@ -0,0 +1,164 @@
+= Build Systems
+
+The build system is the primary way for both developers and system integrators
+to interact with the Git project. As such, we consider it important to pick a
+build system that fulfills our requirements while being easy to use and extend.

Maybe it is me, but this sounds as if _we_ do not need "easy to use and extend", but "easy to use and extend" are extra afterthought consideration we are making for others, which is a bit disturbing.

Let me try paraphrasing what I think you wanted to say

As such, being easy to use and extend for those who are not directly developing Git itself is just as important as other requirements we have on any potential build system.

which hopefully would sound more like we are not treating those who only build and tweak the product of our project as second-class citizens.

Documentation/technical/build-systems.txt line 12

Quoted 6 lines
Documentation/technical/build-systems.txt new file +6 -0
+This document outlines the different requirements that we have for the build
+system and then compares available build systems using these criteria.
+
+== Requirements
+
+The following subsections prevent a list of requirements that we have for any

I think you meant "present".

Documentation/technical/build-systems.txt line 19

Quoted 7 lines
Documentation/technical/build-systems.txt new file +7 -0
+potential build system. Sections are sorted by decreasing priority, even though
+these priorities will naturally differ between users.
+
+=== Platform support
+
+The most important criterium is whether the build system supports all of the
+platforms that Git supports. The most important platforms include:

Maybe it is just me, but when I hear "The most", I expect an exhaustive list (hence "include" that came later somewhat surprised me), and I consider these "the more important systems" (implying "than others").

Quoted 6 lines
Documentation/technical/build-systems.txt new file +6 -0
+  - Linux
+  - macOS
+  - Windows
+  - FreeBSD
+  - OpenBSD
+  - NetBSD

Documentation/technical/build-systems.txt line 42

Quoted 10 lines
Documentation/technical/build-systems.txt new file +9 -0
+
+The platforms which must be supported by the tool should be aligned with our
+[platform support policy](platform-support.txt).
 
+Auto-detection of the following items is considered to be important:
+
+  - Check for the existence of headers.
+  - Check for the existence of libraries.
+  - Check for the existence of exectuables.
+  - Check for the runtime behavior of specific functions.

- Check for specific link order requirements when multiple libraries are involved.

Documentation/technical/build-systems.txt line 48

Quoted 5 lines

+=== Ease of use

Documentation/technical/build-systems.txt new file +4 -0
+
+The build system SHOULD be both easy to use and easy to extend. While this is
+naturally a subjective metric it is likely not controversial to say that some
+build systems are considerably harder to use than others.

If we want to pull RFC-2119/BCP-14 with shouting "SHOULD", we probably should use something similar in the previous "Platform support" section.

Quoted 2 lines
+=== IDE support
+=== Out-of-tree builds

Cross platform builds (e.g., building for arm on x86-64 host)?

Documentation/technical/build-systems.txt line 90

Quoted 5 lines

+=== Rust support

Documentation/technical/build-systems.txt new file +4 -0
+
+Many long-time Git contributors are nowadays in favor of adopting Rust as a
+second language next to C. The build system SHOULD thus support Rust such that
+we do not have to reopen the discussion once we decide to pick up Rust.

What reasons do you have in mind that, without spelling this out, Rust will be left behind while C is fully supported? If the build system can keep track of dependencies by knowing foo.o is made from foo.c and turning foo.c into foo.o takes running cc, it can do the same for rustc. Do you mean include file dependencies and the like?

If the reason why we say "Language X needs to be supported" is because it is not enough to be able to run a compiler on source files written in the language, but it is also necessary to know when to run the compiler (i.e., by dependency tracking), it is better to spell it out.

In any case, instead of singling out Rust in the title, name the section "languate support", and give an enumeration of compilers languages, processors that we care about, just like we did for platforms. For exaple, we may not necessarily want to treat "C support, done as an afterthought of supporting C++" and "C support, done natively" as equivalents (of course, the latter is better).

Shouldn't it also "support" asciidoc/asciidoctor/makeinfo for the documentation toolchain?

Are there other things we use Makefile for in our current system that we are forgetting in this requirements section, like "running lint" or "running tests"?

Thanks.

#3 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

Quoted 11 lines · Junio C Hamano

Documentation/technical/build-systems.txt line 90

Quoted 5 lines

+=== Rust support

Documentation/technical/build-systems.txt new file +4 -0
+
+Many long-time Git contributors are nowadays in favor of adopting Rust as a
+second language next to C. The build system SHOULD thus support Rust such that
+we do not have to reopen the discussion once we decide to pick up Rust.

What reasons do you have in mind that, without spelling this out, Rust will be left behind while C is fully supported? If the build system can keep track of dependencies by knowing foo.o is made from foo.c and turning foo.c into foo.o takes running cc, it can do the same for rustc. Do you mean include file dependencies and the like?

It's actually tremendously more complicated, speaking as someone who as reviewed and dabbled with support for rustc in meson. :)

Rust can trivially compile a single source file into a single executable fairly easily, and it looks much like running a C compiler. Correctly invoking rustc in any more complicated project, such as but not limited to:

- building an internal rust static library ("rlib", typically in the form of a crate)
- linking to a C library
- exporting a C library
- cross compilation
- proc-macros=

quickly turns into a maze of options to ensure correct linkage, and you also have to pass special options to do name-mangling right down the entire dependency tree. Note also that the rust compiler driver has decided for its own reasons to *partially* not rely on the C compiler as a linker driver (it passes -nodefaultlibs for "ideological reasons"), so you have to detect the correct libraries that need to be referenced by a staticlib using rustc --print native-static-libs and then order matters and sanitizers are broken anyway.

In short, you really need a build system for Rust, you cannot just run rustc, which means you need to make the decision about a build system if you ever end up using Rust.

Quoted 5 lines

If the reason why we say "Language X needs to be supported" is because it is not enough to be able to run a compiler on source files written in the language, but it is also necessary to know when to run the compiler (i.e., by dependency tracking), it is better to spell it out.

Dependency tracking is tame stuff and just table stakes for build systems. :)

Quoted 9 lines

In any case, instead of singling out Rust in the title, name the section "languate support", and give an enumeration of compilers languages, processors that we care about, just like we did for platforms. For exaple, we may not necessarily want to treat "C support, done as an afterthought of supporting C++" and "C support, done natively" as equivalents (of course, the latter is better).

Shouldn't it also "support" asciidoc/asciidoctor/makeinfo for the documentation toolchain?

Running asciidoc is pretty simple as it doesn't involve fiddly domain-specific compiler internals. You just run a command -- the same command everywhere -- with an "infile" and "outfile" parameter and the asciidoc tool is essentially well behaved and does what you want it to do. makeinfo isn't really any different.

Quoted 5 lines

Are there other things we use Makefile for in our current system that we are forgetting in this requirements section, like "running lint" or "running tests"?

Thanks.

Signature · 1 line
Eli Schwartz
#4 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

In reply to Junio C Hamano
Quoted 19 lines · Junio C Hamano

Documentation/technical/build-systems.txt line 5

Quoted 11 lines · Patrick Steinhardt
Documentation/technical/build-systems.txt new file +5 -0
new file mode 100644
index 0000000000..8fac36ce1d
@@ -0,0 +1,164 @@
+= Build Systems
+
+The build system is the primary way for both developers and system integrators
+to interact with the Git project. As such, we consider it important to pick a
+build system that fulfills our requirements while being easy to use and extend.

Maybe it is me, but this sounds as if _we_ do not need "easy to use and extend", but "easy to use and extend" are extra afterthought consideration we are making for others, which is a bit disturbing.

Let me try paraphrasing what I think you wanted to say

Quoted 7 lines

As such, being easy to use and extend for those who are not directly developing Git itself is just as important as other requirements we have on any potential build system.

which hopefully would sound more like we are not treating those who only build and tweak the product of our project as second-class citizens.

Oh, that sounds way better, yes!

Quoted 8 lines

Documentation/technical/build-systems.txt line 12

Quoted 6 lines
Documentation/technical/build-systems.txt new file +6 -0
+This document outlines the different requirements that we have for the build
+system and then compares available build systems using these criteria.
+
+== Requirements
+
+The following subsections prevent a list of requirements that we have for any

I think you meant "present".

Yup.

Quoted 4 lines
Quoted 4 lines
Documentation/technical/build-systems.txt new file +4 -0
+potential build system. Sections are sorted by decreasing priority, even though
+these priorities will naturally differ between users.
+
+=== Platform support
Quoted 8 lines

Documentation/technical/build-systems.txt line 19

Quoted 3 lines
Documentation/technical/build-systems.txt new file +3 -0
+
+The most important criterium is whether the build system supports all of the
+platforms that Git supports. The most important platforms include:

Maybe it is just me, but when I hear "The most", I expect an exhaustive list (hence "include" that came later somewhat surprised me), and I consider these "the more important systems" (implying "than others").

Fair point. Ideally, I would be able to just point to our platform support policy, but that document stops short of defining what kind of guarantees we give for each platform.

So what are our primary platforms? Based on the criteria we have it would be Windows, Ubuntu and macOS because we have CI runners for these, all of which are included. Providing support for the BSDs is nice, but these are likely rather "secondary" platforms.

Quoted 9 lines

Documentation/technical/build-systems.txt line 48

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+=== Ease of use
+
+The build system SHOULD be both easy to use and easy to extend. While this is
+naturally a subjective metric it is likely not controversial to say that some
+build systems are considerably harder to use than others.

If we want to pull RFC-2119/BCP-14 with shouting "SHOULD", we probably should use something similar in the previous "Platform support" section.

I think I originally wanted to use RFC-2119, but then noticed that it's rather pointless. I'll stop shouting.

Quoted 4 lines

Documentation/technical/build-systems.txt line 80

Quoted 2 lines
Documentation/technical/build-systems.txt new file +2 -0
+=== IDE support
+=== Out-of-tree builds

Cross platform builds (e.g., building for arm on x86-64 host)?

Oh, yes, that one is indeed an ommission in the current doc.

Quoted 12 lines

Documentation/technical/build-systems.txt line 90

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+=== Rust support
+
+Many long-time Git contributors are nowadays in favor of adopting Rust as a
+second language next to C. The build system SHOULD thus support Rust such that
+we do not have to reopen the discussion once we decide to pick up Rust.

What reasons do you have in mind that, without spelling this out, Rust will be left behind while C is fully supported? If the build system can keep track of dependencies by knowing foo.o is made from foo.c and turning foo.c into foo.o takes running cc, it can do the same for rustc. Do you mean include file dependencies and the like?

Quoted 5 lines

If the reason why we say "Language X needs to be supported" is because it is not enough to be able to run a compiler on source files written in the language, but it is also necessary to know when to run the compiler (i.e., by dependency tracking), it is better to spell it out.

Eli already did a good job of explaining this. While it should be possible to "retrofit" Rust support to basically all build systems out there, it certainly would be nice if we could hide away most of the intricate details of how Rust code needs to be compiled. It can get complex rather fast.

Quoted 6 lines

In any case, instead of singling out Rust in the title, name the section "languate support", and give an enumeration of compilers languages, processors that we care about, just like we did for platforms. For exaple, we may not necessarily want to treat "C support, done as an afterthought of supporting C++" and "C support, done natively" as equivalents (of course, the latter is better).

That makes sense to me, will do.

Quoted 2 lines

Shouldn't it also "support" asciidoc/asciidoctor/makeinfo for the documentation toolchain?

It certainly should be flexible enough to allow for this, yes.

Quoted 3 lines

Are there other things we use Makefile for in our current system that we are forgetting in this requirements section, like "running lint" or "running tests"?

I was a bit torn on whether or not to add "running tests", mostly because it was supported by all of the proposed build systems. But that's probably not a good reason to not make this requirement explicit.

Patrick

#5 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

Quoted 7 lines · Patrick Steinhardt
Quoted 3 lines

Are there other things we use Makefile for in our current system that we are forgetting in this requirements section, like "running lint" or "running tests"?

I was a bit torn on whether or not to add "running tests", mostly because it was supported by all of the proposed build systems. But that's probably not a good reason to not make this requirement explicit.

If a magic build system can omit tests that it can prove (by looking at dependency graph) that they will not be affected with the change I made to this single source file "builtin/cat-file.c", that would certainly be welcome.

We can dream for build system that specifically cater to and know intricate details of a language. We should also be able to dream of such a thing ;-)

Thanks.

#6 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

In reply to Patrick Steinhardt

Documentation/technical/build-systems.txt line 90

Quoted 11 lines · Patrick Steinhardt

We're contemplating whether to eventually replace our build systems with a build system that is easier to use. Add a comparison of build systems to our technical documentation as a baseline for discussion.

---
+=== Rust support

Documentation/technical/build-systems.txt new file +4 -0
+
+Many long-time Git contributors are nowadays in favor of adopting Rust as a
+second language next to C. The build system SHOULD thus support Rust such that
+we do not have to reopen the discussion once we decide to pick up Rust.

I've been watching the Rust discussion mostly from the sidelines, so it's possible that I've missed something, but I was more than a little surprised to see the claim that "Many long-time Git contributors [are] in favor of adopting Rust" since my impression of the discussions does not reflect that claim, nor could I find sufficient references to support such a strong statement. My understanding of the situation is rather different; I've seen both proponents and opponents. With regards to project regulars...

* The most vocal proponent has been brian who gives the impression of being quite a fan of Rust, but hasn't provided particularly compelling reasons to adopt it, and some of his arguments are highly subjective (for instance, "Rust excels at multithreading"[1]; while it's true that Rust may make multithreading safer, it is highly subjective to say that it "excels" at it -- especially, for instance, for anyone familiar with Go's approach to the same subject).

* The Google team is interested in having a Rust wrapper for core Git library[2], but that doesn't imply or require adopting Rust into the Git project itself.

* Randall has severe misgivings[3] about Rust being introduced into the project due to its exclusionary nature with regards to the platform(s) he supports.

* At least one well-established contributor has stated[4] that "Rust scares" him. (Possibly this was said somewhat in jest, but I suspect the feeling may be shared by more than a few long-time Git contributors who see Rust as an overly complex, complicated, and convoluted language but who haven't spoken up because they understand that the programming world in general is moving toward more modern languages such as Rust and Go.)

* The only properly compelling arguments I've seen in favor of adopting Rust came from Elijah[5,6] who is always well-spoken, well-reasoned, thorough, and backs up his statements with plenty of factual evidence.

Those aside, I don't recall seeing any other long-time Git contributors speak up in favor of adopting Rust.

[1]: https://lore.kernel.org/git/[email protected]/
[2]: https://lore.kernel.org/git/[email protected]/
[3]: https://lore.kernel.org/git/[email protected]/
[4]: https://lore.kernel.org/git/Zu2D%[email protected]/
[5]: https://lore.kernel.org/git/CABPp-BFWsWCGogqQ=haMsS4OhOdSwc3frcAxa6soQR5ORTceOA@mail.gmail.com/
[6]: https://lore.kernel.org/git/CABPp-BFOmwV-xBtjvtenb6RFz9wx2VWVpTeho0k=D8wsCCVwqQ@mail.gmail.com/

#7 lore raw

Re: [RFC PATCH 01/21] Documentation: add comparison of build systems

Quoted 5 lines · Eric Sunshine
Quoted 4 lines · Patrick Steinhardt

We're contemplating whether to eventually replace our build systems with a build system that is easier to use. Add a comparison of build systems to our technical documentation as a baseline for discussion.

Quoted 16 lines

Documentation/technical/build-systems.txt line 90

Quoted 7 lines

---
+=== Rust support

Documentation/technical/build-systems.txt new file +4 -0
+
+Many long-time Git contributors are nowadays in favor of adopting Rust as a
+second language next to C. The build system SHOULD thus support Rust such that
+we do not have to reopen the discussion once we decide to pick up Rust.

I've been watching the Rust discussion mostly from the sidelines, so it's possible that I've missed something, but I was more than a little surprised to see the claim that "Many long-time Git contributors [are] in favor of adopting Rust" since my impression of the discussions does not reflect that claim, nor could I find sufficient references to support such a strong statement. My understanding of the situation is rather different; I've seen both proponents and opponents. With regards to project regulars...

I felt that during the Git Contributor's summit the room was in favor of adopting Rust in general. The discussion seemed to rather revolve around _how_ we start to adopt it, not _if_ we do so. I also cannot really remember anybody pushing back on adopting Rust.

In any case, I'm happy to tone this down a bit, as the document is not here to make the case for Rust. I think that it is very likely that we will eventually start to adopt Rust, and because of that I tend to think that we should be prepared for such a future instead of having to reevaluate our build system because it cannot handle such a potential future.

[snip]

Quoted 7 lines

* At least one well-established contributor has stated[4] that "Rust scares" him. (Possibly this was said somewhat in jest, but I suspect the feeling may be shared by more than a few long-time Git contributors who see Rust as an overly complex, complicated, and convoluted language but who haven't spoken up because they understand that the programming world in general is moving toward more modern languages such as Rust and Go.)

Well, that was me :) I _am_ scared of the learning curve of Rust, but I also think that it puts enough on the table to be a worthwhile addition. So it was said half-jokingly.

Patrick

#8 lore raw

RFC PATCH 2/21 t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE

In reply to Patrick Steinhardt

When assembling our LSAN_OPTIONS that configure the leak sanitizer we end up prepending the string with various different colon-separated options via calls to prepend_var. One of the settings we add is the path where the sanitizer should store logs, which can be an arbitrary filesystem path.

Naturally, filesystem paths may contain whitespace characters. And while it does seem as if we were quoting the value, we use escaped quotes and consequently split up the value if it does contain spaces. This leads to the following error in t0000 when having a value with whitespaces:

.../t/test-lib.sh: eval: line 64: unexpected EOF while looking for matching `"' ++ return 1
error: last command exited with $?=1
not ok 5 - subtest: 3 passing tests

The error itself is a bit puzzling at first. The basic problem is that the code sees the leading escaped quote during eval, but because we truncate everything after the space character it doesn't see the trailing escaped quote and thus fails to parse the string.

Properly quote the value to fix the issue while using single-quotes to quote the inner value passed to eval. The issue can be reproduced by t0000 with such a path that contains spaces.

---
 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/test-lib.sh +1 -1
index e718efe4c6..5de93911b9 100644
@@ -1601,7 +1601,7 @@ then
 
 	prepend_var LSAN_OPTIONS : dedup_token_length=9999
 	prepend_var LSAN_OPTIONS : log_exe_name=1
-	prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
+	prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'"
 	export LSAN_OPTIONS
 
 elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
Signature · 1 line
2.47.0.rc0.dirty
#9 lore raw

RFC PATCH 3/21 t/lib-gitweb: test against the build version of gitweb

In reply to Patrick Steinhardt

When testing gitweb we set up the CGI script as "gitweb.perl", which is the source file of the build target "gitweb.cgi". This works alright as long as we run in-tree tests. But we're about to make out-of-tree tests a reality, and there things will break because "gitweb.perl" will not be found in the build directory.

Fix this by using "gitweb.cgi" instead.

---
 t/lib-gitweb.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/lib-gitweb.sh +1 -1
index 1f32ca66ea..c64c87fb87 100644
@@ -49,7 +49,7 @@ EOF
 		error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
 		say "# Testing $SCRIPT_NAME"
 	else # normal case, use source version of gitweb
-		SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
+		SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.cgi"
 	fi
 	export SCRIPT_NAME
 }
Signature · 1 line
2.47.0.rc0.dirty
#10 lore raw

RFC PATCH 4/21 t/lib-gpg: fix setup of GNUPGHOME in MinGW

In reply to Patrick Steinhardt

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to point to a test-specific diretcory. This is done by using "$PWD/gpghome" as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style paths that contain drive letters. What we really want in this context is a Unix-style path, which we can get by using $(pwd) instead.

Adapt the code accordingly to fix tests using this library.

---
 t/lib-gpg.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/lib-gpg.sh +1 -1
index add11e88fc..3845b6ac44 100644
@@ -6,7 +6,7 @@
 #   executed in an eval'ed subshell that changes the working directory to a
 #   temporary one.
 
-GNUPGHOME="$PWD/gpghome"
+GNUPGHOME="$(pwd)/gpghome"
 export GNUPGHOME
 
 test_lazy_prereq GPG '
Signature · 1 line
2.47.0.rc0.dirty
#11 lore raw

Re: [RFC PATCH 04/21] t/lib-gpg: fix setup of GNUPGHOME in MinGW

Quoted 2 lines · Patrick Steinhardt

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to point to a test-specific diretcory. This is done by using "$PWD/gpghome"

s/diretcory/directory/

Quoted 5 lines

as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style paths that contain drive letters. What we really want in this context is a Unix-style path, which we can get by using $(pwd) instead.

It's not clear from this description why Windows- vs. Unix-style paths only now become a problem but have not been a problem up to this point. Is it because PGP testing has always been disabled on Windows until now? Or some other reason?

Quoted 3 lines

Adapt the code accordingly to fix tests using this library.

#12 lore raw

Re: [RFC PATCH 04/21] t/lib-gpg: fix setup of GNUPGHOME in MinGW

Quoted 5 lines · Eric Sunshine
Quoted 2 lines · Patrick Steinhardt

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to point to a test-specific diretcory. This is done by using "$PWD/gpghome"

s/diretcory/directory/

Thanks, fixed.

Quoted 10 lines
Quoted 5 lines

as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style paths that contain drive letters. What we really want in this context is a Unix-style path, which we can get by using $(pwd) instead.

It's not clear from this description why Windows- vs. Unix-style paths only now become a problem but have not been a problem up to this point. Is it because PGP testing has always been disabled on Windows until now? Or some other reason?

I guess that nobody ever ran these tests on Windows with GnuPG installed. It is installed in MinGW though because pacman pulls it in as a dependency.

Anyway, I've amended the commit message accordingly.

Patrick

Quoted 3 lines
Quoted 3 lines

Adapt the code accordingly to fix tests using this library.

#13 lore raw

RFC PATCH 5/21 t3404: work around platform-specific behaviour on macOS 10.15

In reply to Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

Work around this issue by retaining the tabs.

---
 t/t3404-rebase-interactive.sh | 38 +++++++++++++++++------------------
 1 file changed, 18 insertions(+), 20 deletions(-)
t/t3404-rebase-interactive.sh +18 -20
index f171af3061..da4f3e6caf 100755
@@ -1917,18 +1917,17 @@ test_expect_success '--update-refs updates refs correctly' '
 	test_cmp_rev HEAD~1 refs/heads/third &&
 	test_cmp_rev HEAD refs/heads/no-conflict-branch &&
 
-	cat >expect <<-\EOF &&
-	Successfully rebased and updated refs/heads/update-refs.
-	Updated the following refs with --update-refs:
-		refs/heads/first
-		refs/heads/no-conflict-branch
-		refs/heads/second
-		refs/heads/third
-	EOF
+	cat >expect <<\EOF &&
+Successfully rebased and updated refs/heads/update-refs.
+Updated the following refs with --update-refs:
+	refs/heads/first
+	refs/heads/no-conflict-branch
+	refs/heads/second
+	refs/heads/third
+EOF
 
 	# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
-	sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
-		<err >err.trimmed &&
+	sed "s/Rebasing.*Successfully/Successfully/g" <err >err.trimmed &&
 	test_cmp expect err.trimmed
 '
 
@@ -2178,19 +2177,18 @@ test_expect_success '--update-refs: check failed ref update' '
 	test_must_fail git rebase --continue 2>err &&
 	grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
 
-	cat >expect <<-\EOF &&
-	Updated the following refs with --update-refs:
-		refs/heads/first
-		refs/heads/no-conflict-branch
-		refs/heads/third
-	Failed to update the following refs with --update-refs:
-		refs/heads/second
-	EOF
+	cat >expect <<\EOF &&
+Updated the following refs with --update-refs:
+	refs/heads/first
+	refs/heads/no-conflict-branch
+	refs/heads/third
+Failed to update the following refs with --update-refs:
+	refs/heads/second
+EOF
 
 	# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
 	tail -n 6 err >err.last &&
-	sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
-		<err.last >err.trimmed &&
+	sed "s/Rebasing.*Successfully/Successfully/g" <err.last >err.trimmed &&
 	test_cmp expect err.trimmed
 '
 
Signature · 1 line
2.47.0.rc0.dirty
#14 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

Quoted 5 lines · Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

I presume this nebulous explanation is due to the fact that the reason why macOS 10.15 exhibits this anomalous behavior is not yet known?

Quoted 12 lines

Work around this issue by retaining the tabs.

---

t/t3404-rebase-interactive.sh +0 -6
@@ -1917,18 +1917,17 @@ test_expect_success '--update-refs updates refs correctly' '
-       cat >expect <<-\EOF &&
-       Successfully rebased and updated refs/heads/update-refs.
-       Updated the following refs with --update-refs:
-               refs/heads/first
-               refs/heads/no-conflict-branch
-               refs/heads/second

t/t3404-rebase-interactive.sh test_expect_success '--update-refs updates refs correctly' ' · line 1924

Quoted 10 lines
t/t3404-rebase-interactive.sh +8 -2
-               refs/heads/third
-       EOF
+       cat >expect <<\EOF &&
+Successfully rebased and updated refs/heads/update-refs.
+Updated the following refs with --update-refs:
+       refs/heads/first
+       refs/heads/no-conflict-branch
+       refs/heads/second
+       refs/heads/third
+EOF

Although this works, the problem with this change (and its sibling later in the patch) is that someday someone is going to come along (say, for instance, a GSoC applicant doing a microproject) who submits a patch to (re-)"modernize" this test by using <<- to (re-)indent the heredoc body. A better approach would probably be to retain <<- and use q_to_tab():

    q_to_tab >expect <<-\EOF &&
    Qrefs/heads/first
    Q...
    Qrefs/heads/third
    EOF
#15 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

Quoted 9 lines · Eric Sunshine
Quoted 5 lines · Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

I presume this nebulous explanation is due to the fact that the reason why macOS 10.15 exhibits this anomalous behavior is not yet known?

I suspect that the problem is that we use "\t" which is non-standard rather than a literal tab character in the sed expression.

Quoted 7 lines

Although this works, the problem with this change (and its sibling later in the patch) is that someday someone is going to come along (say, for instance, a GSoC applicant doing a microproject) who submits a patch to (re-)"modernize" this test by using <<- to (re-)indent the heredoc body. A better approach would probably be to retain <<- and use q_to_tab():

Quoted 5 lines
     q_to_tab >expect <<-\EOF &&
     Qrefs/heads/first
     Q...
     Qrefs/heads/third
     EOF

I agree that using q_to_tab is a better approach here.

These first few patches all look like useful fixes in their own right. I might be worth splitting them out into a separate series so they can progress independently of the build system changes.

Best Wishes

Phillip

#16 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

Quoted 8 lines · Phillip Wood
Quoted 7 lines · Eric Sunshine
Quoted 5 lines · Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

Quoted 5 lines
Quoted 2 lines

I presume this nebulous explanation is due to the fact that the reason why macOS 10.15 exhibits this anomalous behavior is not yet known?

I suspect that the problem is that we use "\t" which is non-standard rather than a literal tab character in the sed expression.

Ah yes. The sed on macOS 10.15 would have been of an older BSD-lineage than the more modern macOS versions, so that makes sense. It wouldn't be a bad idea for the commit message to mention something along those lines.

(I always use literal TAB with sed for this precise reason, which may explain why my eyes skipped right over the non-standard use of "\t" or I just wasn't paying close enough attention, which is equally likely.)

#17 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

Quoted 8 lines · Eric Sunshine
Quoted 2 lines

I suspect that the problem is that we use "\t" which is non-standard rather than a literal tab character in the sed expression.

Ah yes. The sed on macOS 10.15 would have been of an older BSD-lineage than the more modern macOS versions, so that makes sense. It wouldn't be a bad idea for the commit message to mention something along those lines.

Quoted 4 lines

(I always use literal TAB with sed for this precise reason, which may explain why my eyes skipped right over the non-standard use of "\t" or I just wasn't paying close enough attention, which is equally likely.)

I also learned sed with old BSD behaviour to be portable (I somehow thought it is not just "old BSD" but outside POSIX if you used "\t" and friends). Checking with

$ git grep 'sed.*\\t' t/\*.sh

shows that t3305 also has this problem. The ones in t3404 are from 4611884e (sequencer: notify user of --update-refs activity, 2022-07-19), while the other one is from e1c52539 (t3305: check notes fanout more carefully and robustly, 2020-02-03), both are relatively old. If people are not reporting issues, it may be an indication that sed implementations of BSD origin may have died off.

#18 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

Quoted 19 lines · Junio C Hamano
Quoted 8 lines · Eric Sunshine
Quoted 2 lines

I suspect that the problem is that we use "\t" which is non-standard rather than a literal tab character in the sed expression.

Ah yes. The sed on macOS 10.15 would have been of an older BSD-lineage than the more modern macOS versions, so that makes sense. It wouldn't be a bad idea for the commit message to mention something along those lines.

Quoted 4 lines

(I always use literal TAB with sed for this precise reason, which may explain why my eyes skipped right over the non-standard use of "\t" or I just wasn't paying close enough attention, which is equally likely.)

I also learned sed with old BSD behaviour to be portable (I somehow thought it is not just "old BSD" but outside POSIX if you used "\t" and friends). Checking with

Quoted 8 lines
$ git grep 'sed.*\\t' t/\*.sh

shows that t3305 also has this problem. The ones in t3404 are from 4611884e (sequencer: notify user of --update-refs activity, 2022-07-19), while the other one is from e1c52539 (t3305: check notes fanout more carefully and robustly, 2020-02-03), both are relatively old. If people are not reporting issues, it may be an indication that sed implementations of BSD origin may have died off.

Probably. Curious that I didn't see issues in t3305.

Patrick

#19 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

In reply to Phillip Wood
Quoted 8 lines · Phillip Wood
Quoted 7 lines · Eric Sunshine
Quoted 5 lines · Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

Quoted 5 lines
Quoted 2 lines

I presume this nebulous explanation is due to the fact that the reason why macOS 10.15 exhibits this anomalous behavior is not yet known?

I suspect that the problem is that we use "\t" which is non-standard rather than a literal tab character in the sed expression.

Ah, that makes sense.

Quoted 13 lines
Quoted 7 lines

Although this works, the problem with this change (and its sibling later in the patch) is that someday someone is going to come along (say, for instance, a GSoC applicant doing a microproject) who submits a patch to (re-)"modernize" this test by using <<- to (re-)indent the heredoc body. A better approach would probably be to retain <<- and use q_to_tab():

Quoted 5 lines
     q_to_tab >expect <<-\EOF &&
     Qrefs/heads/first
     Q...
     Qrefs/heads/third
     EOF
Quoted 5 lines

I agree that using q_to_tab is a better approach here.

These first few patches all look like useful fixes in their own right. I might be worth splitting them out into a separate series so they can progress independently of the build system changes.

Yeah, I'm certainly happy to split these out into a separate series. For now I'll keep things in one, but will do so depending on how this series progresses.

Patrick

#20 lore raw

Re: [RFC PATCH 05/21] t3404: work around platform-specific behaviour on macOS 10.15

In reply to Eric Sunshine
Quoted 9 lines · Eric Sunshine
Quoted 5 lines · Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But on macOS 10.15 this doesn't work as expected and we somehow keep the tabs around in the actual output.

I presume this nebulous explanation is due to the fact that the reason why macOS 10.15 exhibits this anomalous behavior is not yet known?

Yeah, I didn't thoroughly investigate this one but just wanted to have it fixed. I was hitting so many platform-dependent issues left and right that at some point I started to feel a bit tired.

Quoted 30 lines
Quoted 12 lines

Work around this issue by retaining the tabs.

---

t/t3404-rebase-interactive.sh +0 -6
@@ -1917,18 +1917,17 @@ test_expect_success '--update-refs updates refs correctly' '
-       cat >expect <<-\EOF &&
-       Successfully rebased and updated refs/heads/update-refs.
-       Updated the following refs with --update-refs:
-               refs/heads/first
-               refs/heads/no-conflict-branch
-               refs/heads/second

t/t3404-rebase-interactive.sh test_expect_success '--update-refs updates refs correctly' ' · line 1924

Quoted 10 lines
t/t3404-rebase-interactive.sh +8 -2
-               refs/heads/third
-       EOF
+       cat >expect <<\EOF &&
+Successfully rebased and updated refs/heads/update-refs.
+Updated the following refs with --update-refs:
+       refs/heads/first
+       refs/heads/no-conflict-branch
+       refs/heads/second
+       refs/heads/third
+EOF

Although this works, the problem with this change (and its sibling later in the patch) is that someday someone is going to come along (say, for instance, a GSoC applicant doing a microproject) who submits a patch to (re-)"modernize" this test by using <<- to (re-)indent the heredoc body. A better approach would probably be to retain <<- and use q_to_tab():

Quoted 5 lines
    q_to_tab >expect <<-\EOF &&
    Qrefs/heads/first
    Q...
    Qrefs/heads/third
    EOF

Cute! Didn't know we even had this helper.

Patrick

#21 lore raw

RFC PATCH 6/21 t/unit-tests: update clar unit test framework

In reply to Patrick Steinhardt

Update clar unit test framework to 67e689a (Merge pull request #103 from pks-t/pks-editorconfig, 2024-09-20).

---
 t/unit-tests/clar/.editorconfig            |  13 +++
 t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-
 t/unit-tests/clar/.gitignore               |   1 +
 t/unit-tests/clar/CMakeLists.txt           |  28 ++++++
 t/unit-tests/clar/clar.c                   | 102 +++++++++++----------
 t/unit-tests/clar/clar/print.h             |  11 ++-
 t/unit-tests/clar/clar/sandbox.h           |  17 ++--
 t/unit-tests/clar/clar/summary.h           |  14 +--
 t/unit-tests/clar/test/.gitignore          |   4 -
 t/unit-tests/clar/test/CMakeLists.txt      |  41 +++++++++
 t/unit-tests/clar/test/Makefile            |  39 --------
 11 files changed, 172 insertions(+), 118 deletions(-)
 create mode 100644 t/unit-tests/clar/.editorconfig
 create mode 100644 t/unit-tests/clar/.gitignore
 create mode 100644 t/unit-tests/clar/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/Makefile
t/unit-tests/clar/.editorconfig new file +13 -0
new file mode 100644
index 0000000000..aa343a4288
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+charset = utf-8
+insert_final_newline = true
+
+[*.{c,h}]
+indent_style = tab
+tab_width = 8
+
+[CMakeLists.txt]
+indent_style = tab
+tab_width = 8
t/unit-tests/clar/.github/workflows/ci.yml +16 -4
index b1ac2de460..0065843d17 100644
@@ -10,14 +10,26 @@ jobs:
   build:
     strategy:
       matrix:
-        os: [ ubuntu-latest, macos-latest ]
+        platform:
+          - os: ubuntu-latest
+            generator: Unix Makefiles
+          - os: macos-latest
+            generator: Unix Makefiles
+          - os: windows-latest
+            generator: Visual Studio 17 2022
+          - os: windows-latest
+            generator: MSYS Makefiles
+          - os: windows-latest
+            generator: MinGW Makefiles
 
-    runs-on: ${{ matrix.os }}
+    runs-on: ${{ matrix.platform.os }}
 
     steps:
     - name: Check out
       uses: actions/checkout@v2
     - name: Build
       run: |
-        cd test
-        make
+        mkdir build
+        cd build
+        cmake .. -G "${{matrix.platform.generator}}"
+        cmake --build .
t/unit-tests/clar/.gitignore new file +1 -0
new file mode 100644
index 0000000000..84c048a73c
@@ -0,0 +1 @@
+/build/
t/unit-tests/clar/CMakeLists.txt new file +28 -0
new file mode 100644
index 0000000000..12d4af114f
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.16..3.29)
+
+project(clar LANGUAGES C)
+
+option(BUILD_TESTS "Build test executable" ON)
+
+add_library(clar INTERFACE)
+target_sources(clar INTERFACE
+	clar.c
+	clar.h
+	clar/fixtures.h
+	clar/fs.h
+	clar/print.h
+	clar/sandbox.h
+	clar/summary.h
+)
+set_target_properties(clar PROPERTIES
+	C_STANDARD 90
+	C_STANDARD_REQUIRED ON
+	C_EXTENSIONS OFF
+)
+
+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
+	include(CTest)
+	if(BUILD_TESTING)
+		add_subdirectory(test)
+	endif()
+endif()
t/unit-tests/clar/clar.c +52 -50

222 lines not on this page · raw message

t/unit-tests/clar/clar/print.h +8 -3
index c17e2f693b..69d0ee967e 100644
@@ -21,7 +21,7 @@ static void clar_print_clap_error(int num, const struct clar_report *report, con
 {
 	printf("  %d) Failure:\n", num);
 
-	printf("%s::%s [%s:%"PRIuZ"]\n",
+	printf("%s::%s [%s:%"PRIuMAX"]\n",
 		report->suite,
 		report->test,
 		error->file,
@@ -136,7 +136,7 @@ static void clar_print_tap_ontest(const char *suite_name, const char *test_name,
 
 		printf("    at:\n");
 		printf("      file: '"); print_escaped(error->file); printf("'\n");
-		printf("      line: %" PRIuZ "\n", error->line_number);
+		printf("      line: %" PRIuMAX "\n", error->line_number);
 		printf("      function: '%s'\n", error->function);
 		printf("    ---\n");
 
@@ -202,10 +202,15 @@ static void clar_print_onsuite(const char *suite_name, int suite_index)
 	PRINT(onsuite, suite_name, suite_index);
 }
 
+static void clar_print_onabortv(const char *msg, va_list argp)
+{
+	PRINT(onabort, msg, argp);
+}
+
 static void clar_print_onabort(const char *msg, ...)
 {
 	va_list argp;
 	va_start(argp, msg);
-	PRINT(onabort, msg, argp);
+	clar_print_onabortv(msg, argp);
 	va_end(argp);
 }
t/unit-tests/clar/clar/sandbox.h +8 -9
index e25057b7c4..681a1f80f1 100644
@@ -122,14 +122,14 @@ static int build_sandbox_path(void)
 
 	if (mkdir(_clar_path, 0700) != 0)
 		return -1;
-#elif defined(__TANDEM)
-	if (mktemp(_clar_path) == NULL)
+#elif defined(_WIN32)
+	if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
 		return -1;
 
 	if (mkdir(_clar_path, 0700) != 0)
 		return -1;
-#elif defined(_WIN32)
-	if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
+#elif defined(__TANDEM)
+	if (mktemp(_clar_path) == NULL)
 		return -1;
 
 	if (mkdir(_clar_path, 0700) != 0)
@@ -142,15 +142,14 @@ static int build_sandbox_path(void)
 	return 0;
 }
 
-static int clar_sandbox(void)
+static void clar_sandbox(void)
 {
 	if (_clar_path[0] == '\0' && build_sandbox_path() < 0)
-		return -1;
+		clar_abort("Failed to build sandbox path.\n");
 
 	if (chdir(_clar_path) != 0)
-		return -1;
-
-	return 0;
+		clar_abort("Failed to change into sandbox directory '%s': %s.\n",
+			   _clar_path, strerror(errno));
 }
 
 const char *clar_sandbox_path(void)
t/unit-tests/clar/clar/summary.h +5 -9
index 4dd352e28b..0d0b646fe7 100644
@@ -66,16 +66,12 @@ struct clar_summary *clar_summary_init(const char *filename)
 	struct clar_summary *summary;
 	FILE *fp;
 
-	if ((fp = fopen(filename, "w")) == NULL) {
-		perror("fopen");
-		return NULL;
-	}
+	if ((fp = fopen(filename, "w")) == NULL)
+		clar_abort("Failed to open the summary file '%s': %s.\n",
+			   filename, strerror(errno));
 
-	if ((summary = malloc(sizeof(struct clar_summary))) == NULL) {
-		perror("malloc");
-		fclose(fp);
-		return NULL;
-	}
+	if ((summary = malloc(sizeof(struct clar_summary))) == NULL)
+		clar_abort("Failed to allocate summary.\n");
 
 	summary->filename = filename;
 	summary->fp = fp;
t/unit-tests/clar/test/.gitignore deleted +0 -4
deleted file mode 100644
index a477d0c40c..0000000000
@@ -1,4 +0,0 @@
-clar.suite
-.clarcache
-clar_test
-*.o
t/unit-tests/clar/test/CMakeLists.txt new file +41 -0

41 lines not on this page · raw message

t/unit-tests/clar/test/Makefile deleted +0 -39
deleted file mode 100644
index 93c6b2ad32..0000000000
@@ -1,39 +0,0 @@
-#
-# Copyright (c) Vicent Marti. All rights reserved.
-#
-# This file is part of clar, distributed under the ISC license.
-# For full terms see the included COPYING file.
-#
-
-#
-# Set up the path to the clar sources and to the fixtures directory
-#
-# The fixture path needs to be an absolute path so it can be used
-# even after we have chdir'ed into the test directory while testing.
-#
-CURRENT_MAKEFILE  := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
-TEST_DIRECTORY    := $(abspath $(dir $(CURRENT_MAKEFILE)))
-CLAR_PATH         := $(dir $(TEST_DIRECTORY))
-CLAR_FIXTURE_PATH := $(TEST_DIRECTORY)/resources/
-
-CFLAGS=-g -I.. -I. -Wall -DCLAR_FIXTURE_PATH=\"$(CLAR_FIXTURE_PATH)\"
-
-.PHONY: clean
-
-# list the objects that go into our test
-objects = main.o sample.o
-
-# build the test executable itself
-clar_test: $(objects) clar_test.h clar.suite $(CLAR_PATH)clar.c
-	$(CC) $(CFLAGS) -o $@ "$(CLAR_PATH)clar.c" $(objects)
-
-# test object files depend on clar macros
-$(objects) : $(CLAR_PATH)clar.h
-
-# build the clar.suite file of test metadata
-clar.suite:
-	python "$(CLAR_PATH)generate.py" .
-
-# remove all generated files
-clean:
-	$(RM) -rf *.o clar.suite .clarcache clar_test clar_test.dSYM
Signature · 1 line
2.47.0.rc0.dirty
#22 lore raw

RFC PATCH 7/21 t/clar: simplify how the clar derives `struct stat`

In reply to Patrick Steinhardt

Windows has different definitions of struct stat. The difference between those structs is that they either use 32 or 64 bit timestamps and/or filesizes.

In the clar we try to set that up automatically, but the logic to do so is somewhat convoluted and really fragile. Refactor the code such that we always define the stat() function and its structure together, which is both easier to understand and less fragile.

---
 t/unit-tests/clar/clar.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
t/unit-tests/clar/clar.c +3 -6
index f463ee823a..12fa66d088 100644
@@ -30,6 +30,9 @@
 
 #	ifndef stat
 #		define stat(path, st) _stat(path, st)
+		typedef struct _stat STAT_T;
+#	else
+		typedef struct stat STAT_T;
 #	endif
 #	ifndef mkdir
 #		define mkdir(path, mode) _mkdir(path)
@@ -62,12 +65,6 @@
 #	else
 #		define p_snprintf snprintf
 #	endif
-
-#	if defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
-	typedef struct stat STAT_T;
-#	else
-	typedef struct _stat STAT_T;
-#	endif
 #else
 #	include <sys/wait.h> /* waitpid(2) */
 #	include <unistd.h>
Signature · 1 line
2.47.0.rc0.dirty
#23 lore raw

RFC PATCH 8/21 builtin/credential-cache: fix missing parameter for stub function

In reply to Patrick Steinhardt

When not compiling the credential cache we may use a stub function for cmd_credential_cache(). With commit 9b1cb5070f (builtin: add a repository parameter for builtin functions, 2024-09-13), we have added a new parameter to all of those top-level cmd_*() functions, and did indeed adapt the non-stubbed-out cmd_credential_cache(). But we didn't adapt the stubbed-out variant, so the code does not compile.

Fix this by adding the missing parameter.

---
 builtin/credential-cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
builtin/credential-cache.c +2 -1
index 5de8b9123b..c51f7fc2ad 100644
@@ -189,7 +189,8 @@ int cmd_credential_cache(int argc,
 
 #else
 
-int cmd_credential_cache(int argc, const char **argv, const char *prefix)
+int cmd_credential_cache(int argc, const char **argv, const char *prefix,
+			 struct repository *repo UNUSED)
 {
 	const char * const usage[] = {
 		"git credential-cache [options] <action>",
Signature · 1 line
2.47.0.rc0.dirty
#24 lore raw

RFC PATCH 9/21 http: fix build error on FreeBSD

In reply to Patrick Steinhardt

The result parameter passed to http_request_reauth() may either point to a struct strbuf or a FILE *, where the target parameter tells us which of either it actually is. To accommodate for both types the pointer is a void *, which we then pass directly to functions without doing a cast.

This is fine on most platforms, but it breaks on FreeBSD because fileno() is implemented as a macro that tries to directly access the FILE * structure.

Fix this issue by storing the FILE * in a local variable before we pass it on to other functions.

---
 http.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
http.c +6 -4
index 376af88c5d..28f70a7a9c 100644
@@ -2289,17 +2289,19 @@ static int http_request_reauth(const char *url,
 		case HTTP_REQUEST_STRBUF:
 			strbuf_reset(result);
 			break;
-		case HTTP_REQUEST_FILE:
-			if (fflush(result)) {
+		case HTTP_REQUEST_FILE: {
+			FILE *f = result;
+			if (fflush(f)) {
 				error_errno("unable to flush a file");
 				return HTTP_START_FAILED;
 			}
-			rewind(result);
-			if (ftruncate(fileno(result), 0) < 0) {
+			rewind(f);
+			if (ftruncate(fileno(f), 0) < 0) {
 				error_errno("unable to truncate a file");
 				return HTTP_START_FAILED;
 			}
 			break;
+		}
 		default:
 			BUG("Unknown http_request target");
 		}
Signature · 1 line
2.47.0.rc0.dirty
#25 lore raw

RFC PATCH 10/21 Makefile: extract script to generate clar declarations

In reply to Patrick Steinhardt

Extract the script to generate function declarations for the clar unit testing framework into a standalone script. This is done such that we can reuse it in other build systems.

---
 Makefile                            |  4 +---
 t/unit-tests/generate-clar-decls.sh | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100755 t/unit-tests/generate-clar-decls.sh
Makefile +1 -3
index 7344a7f725..de6426a684 100644
@@ -3880,9 +3880,7 @@ GIT-TEST-SUITES: FORCE
             fi
 
 $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES
-	$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \
-		sed -ne "s/^\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\)/extern \1;/p" $(UNIT_TEST_DIR)/$$suite.c; \
-	done >$@
+	$(QUIET_GEN)$(SHELL_PATH) $(UNIT_TEST_DIR)/generate-clar-decls.sh "$@" $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES))
 $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h
 	$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite
 $(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h
t/unit-tests/generate-clar-decls.sh new file +16 -0
new file mode 100755
index 0000000000..d5ddbaa5da
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if test $# -lt 3
+then
+	echo "USAGE: $0 <OUTPUT> <SUITE>..." 2>&1
+	exit 1
+fi
+
+OUTPUT="$1"
+shift
+
+for suite in $*
+do
+	sed -ne "s/^\(void test_$suite__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$\)/extern \1;/p" "$suite" ||
+	exit 1
+done >"$OUTPUT"
Signature · 1 line
2.47.0.rc0.dirty
#26 lore raw

RFC PATCH 11/21 Makefile: extract script to massage Perl scripts

In reply to Patrick Steinhardt

Extract the script to inject various build-time parameters into our Perl scripts into a standalone script. This is done such that we can reuse it in other build systems.

---
 Makefile         | 10 +---------
 generate-perl.sh | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)
 create mode 100755 generate-perl.sh
Makefile +1 -9
index de6426a684..f582ccdc98 100644
@@ -2580,15 +2580,7 @@ endif
 PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
 
 $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
-	$(QUIET_GEN) \
-	sed -e '1{' \
-	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-	    -e '	r GIT-PERL-HEADER' \
-	    -e '	G' \
-	    -e '}' \
-	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-	    $< >$@+ && \
-	chmod +x $@+ && \
+	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh $(GIT_VERSION) GIT-PERL-HEADER "$(PERL_PATH_SQ)" "$<" "$@+" && \
 	mv $@+ $@
 
 PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
generate-perl.sh new file +22 -0
new file mode 100755
index 0000000000..b9e04d6f42
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if test $# -ne 5
+then
+	echo "USAGE: $0 <GIT_VERSION> <PERL_HEADER> <PERL_PATH> <PERL_SCRIPT> <OUT>" >&2
+	exit 1
+fi
+
+GIT_VERSION="$1"
+PERL_HEADER="$2"
+PERL_PATH="$3"
+PERL_SCRIPT="$4"
+OUT="$5"
+
+sed -e '1{' \
+    -e "	s|#!.*perl|#!$PERL_PATH|" \
+    -e "	r $PERL_HEADER" \
+    -e '	G' \
+    -e '}' \
+    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
+    "$PERL_SCRIPT" >"$OUT"
+chmod a+x "$OUT"
Signature · 1 line
2.47.0.rc0.dirty
#27 lore raw

RFC PATCH 12/21 Makefile: refactor GIT-VERSION-GEN to be reusable

In reply to Patrick Steinhardt

Our "GIT-VERSION-GEN" script always writes the "GIT-VERSION-FILE" into the current directory, where the expectation is that it should exist in the source directory. But other build systems that support out-of-tree builds may not want to do that to keep the source directory pristine, even though CMake currently doesn't care.

Refactor the script such that it doesn't write output to a file anymore but so that it instead writes the version to stdout. This makes it easier to compute the same version as our Makefile would without having to write the "GIT-VERSION-FILE".

We should ideally refactor our CMake build instructions to stop writing into the source directory. But this step is out of scope of the current patch series.

---
 GIT-VERSION-GEN                     | 12 +-----------
 Makefile                            |  3 ++-
 contrib/buildsystems/CMakeLists.txt |  5 ++++-
 3 files changed, 7 insertions(+), 13 deletions(-)
GIT-VERSION-GEN +1 -11
index 38e920725c..f626d74d6d 100755
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-GVF=GIT-VERSION-FILE
 DEF_VER=v2.47.0-rc0
 
 LF='
@@ -28,13 +27,4 @@ fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
 
-if test -r $GVF
-then
-	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
-else
-	VC=unset
-fi
-test "$VN" = "$VC" || {
-	echo >&2 "GIT_VERSION = $VN"
-	echo "GIT_VERSION = $VN" >$GVF
-}
+echo "$VN"
Makefile +2 -1
index f582ccdc98..fae931ff0b 100644
@@ -588,7 +588,8 @@ include shared.mak
 #        Disable -pedantic compilation.
 
 GIT-VERSION-FILE: FORCE
-	@$(SHELL_PATH) ./GIT-VERSION-GEN
+	@printf "GIT_VERSION = %s\n" $$($(SHELL_PATH) GIT-VERSION-GEN) >$@+
+	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else cat $@+ >&2 && mv $@+ $@; fi
 -include GIT-VERSION-FILE
 
 # Set our default configuration.
contrib/buildsystems/CMakeLists.txt +4 -1
index 62af7b33d2..01a23788e1 100644
@@ -87,7 +87,10 @@ endif()
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
 	message("Generating GIT-VERSION-FILE")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
-		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+		OUTPUT_VARIABLE GIT_VERSION
+		OUTPUT_STRIP_TRAILING_WHITESPACE)
+	file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "GIT_VERSION = '${GIT_VERSION}'\n")
 endif()
 
 #Parse GIT-VERSION-FILE to get the version
Signature · 1 line
2.47.0.rc0.dirty
#28 lore raw

RFC PATCH 13/21 Makefile: refactor generators to be PWD-independent

In reply to Patrick Steinhardt

We have multiple scripts that generate headers from other data. All of these scripts have the assumption built-in that they are executed in the current source directory, which makes them a bit unwieldy to use during out-of-tree builds. This makes them a bit unwieldy to use. Refactor them to instead take the source directory as well as the output file as arguments.

---
 Makefile                            |  6 ++---
 contrib/buildsystems/CMakeLists.txt | 12 +++------
 generate-cmdlist.sh                 | 42 ++++++++++++++++++-----------
 generate-configlist.sh              | 20 ++++++++++----
 generate-hooklist.sh                | 15 ++++++++++-
 5 files changed, 61 insertions(+), 34 deletions(-)
Makefile +3 -3
index fae931ff0b..d128b5b3e4 100644
@@ -2498,17 +2498,17 @@ $(BUILT_INS): git$X
 config-list.h: generate-configlist.sh
 
 config-list.h: Documentation/*config.txt Documentation/config/*.txt
-	$(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh >$@
+	$(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@
 
 command-list.h: generate-cmdlist.sh command-list.txt
 
 command-list.h: $(wildcard Documentation/git*.txt)
 	$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \
 		$(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \
-		command-list.txt >$@
+		. $@
 
 hook-list.h: generate-hooklist.sh Documentation/githooks.txt
-	$(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh >$@
+	$(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh . $@
 
 SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):\
 	$(localedir_SQ):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
contrib/buildsystems/CMakeLists.txt +3 -9
index 01a23788e1..27d986eaf0 100644
@@ -655,23 +655,17 @@ set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" F
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
 	list(REMOVE_ITEM EXCLUSION_PROGS empty)
 	message("Generating command-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/command-list.h)
 endif()
 
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
 	message("Generating config-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/config.list)
 endif()
 
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h)
 	message("Generating hook-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/hook-list.h)
 endif()
 
 include_directories(${CMAKE_BINARY_DIR})
generate-cmdlist.sh +26 -16

58 lines not on this page · raw message

generate-configlist.sh +15 -5
index 8692fe5cf4..512804a1ca 100755
@@ -1,13 +1,19 @@
 #!/bin/sh
 
-echo "/* Automatically generated by generate-configlist.sh */"
-echo
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT"
+then
+	echo "USAGE: $0 <SOURCE_DIR> <OUTPUT>" >&2
+	exit 1
+fi
 
 print_config_list () {
 	cat <<EOF
 static const char *config_name_list[] = {
 EOF
-	grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
+	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.txt "$SOURCE_DIR"/Documentation/config/*.txt |
 	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
 	sort |
 	sed 's/^.*$/	"&",/'
@@ -17,5 +23,9 @@ EOF
 EOF
 }
 
-echo
-print_config_list
+{
+	echo "/* Automatically generated by generate-configlist.sh */"
+	echo
+	echo
+	print_config_list
+} >"$OUTPUT"
generate-hooklist.sh +14 -1
index 2f9f54eb54..0ff2a0b6fb 100755
@@ -2,6 +2,17 @@
 #
 # Usage: ./generate-hooklist.sh >hook-list.h
 
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT"
+then
+	echo "USAGE: $0 <SOURCE_DIR> <OUTPUT>" >&2
+	exit 1
+fi
+
+{
+
 cat <<EOF
 /* Automatically generated by generate-hooklist.sh */
 
@@ -11,10 +22,12 @@ EOF
 sed -n \
 	-e '/^~~~~*$/ {x; s/^.*$/	"&",/; p;}' \
 	-e 'x' \
-	<Documentation/githooks.txt |
+	<"$SOURCE_DIR"/Documentation/githooks.txt |
 	LC_ALL=C sort
 
 cat <<EOF
 	NULL,
 };
 EOF
+
+} >"$OUTPUT"
Signature · 1 line
2.47.0.rc0.dirty
#29 lore raw

RFC PATCH 14/21 Makefile: use common template for GIT-BUILD-OPTIONS

In reply to Patrick Steinhardt

The "GIT-BUILD-OPTIONS" file is generated by our build systems to propagate built-in features and paths to our tests. The generation is done ad-hoc, where both our Makefile and the CMake build instructions simply echo a bunch of strings into the file. This makes it very hard to figure out what variables are expected to exist and what format they have, and the written variables can easily get out of sync between build systems.

Introduce a new "GIT-BUILD-OPTIONS.in" template to address this issue. This has multiple advantages:

- It demonstrates which built options exist in the first place.

- It can serve as a spot to document the build options.

- Some build systems complain when not all variables could be substituted, alerting us of mismatches. Others don't, but if we forgot to substitute such variables we now have a bogus string that will likely cause our tests to fail, if they have any meaning in the first place.

Backfill values that we didn't yet set in our CMake build instructions. While at it, remove the SUPPORTS_SIMPLE_IPC variable that we only set up in CMake as it isn't used anywhere.

Note that this change requires us to move around the setup of TEST_OUTPUT_DIRECTORY in "test-lib.sh" such that it comes after sourcing the "GIT-BUILD-OPTIONS" file. This is the only instance I could find where we rely on ordering on variables.

---
 GIT-BUILD-OPTIONS.in                |  35 +++++++++
 Makefile                            | 106 ++++++++++------------------
 contrib/buildsystems/CMakeLists.txt |  56 ++++++++++-----
 t/test-lib.sh                       |  13 ++--
 4 files changed, 117 insertions(+), 93 deletions(-)
 create mode 100644 GIT-BUILD-OPTIONS.in
GIT-BUILD-OPTIONS.in new file +35 -0
new file mode 100644
index 0000000000..e73cd5fa1a
@@ -0,0 +1,35 @@
+SHELL_PATH=@SHELL_PATH@
+TEST_SHELL_PATH=@TEST_SHELL_PATH@
+PERL_PATH=@PERL_PATH@
+DIFF=@DIFF@
+PYTHON_PATH=@PYTHON_PATH@
+TAR=@TAR@
+NO_CURL=@NO_CURL@
+NO_EXPAT=@NO_EXPAT@
+USE_LIBPCRE2=@USE_LIBPCRE2@
+NO_PERL=@NO_PERL@
+NO_PTHREADS=@NO_PTHREADS@
+NO_PYTHON=@NO_PYTHON@
+NO_REGEX=@NO_REGEX@
+NO_UNIX_SOCKETS=@NO_UNIX_SOCKETS@
+PAGER_ENV=@PAGER_ENV@
+SANITIZE_LEAK=@SANITIZE_LEAK@
+SANITIZE_ADDRESS=@SANITIZE_ADDRESS@
+X=@X@
+FSMONITOR_DAEMON_BACKEND=@FSMONITOR_DAEMON_BACKEND@
+FSMONITOR_OS_SETTINGS=@FSMONITOR_OS_SETTINGS@
+TEST_OUTPUT_DIRECTORY=@TEST_OUTPUT_DIRECTORY@
+GIT_TEST_OPTS=@GIT_TEST_OPTS@
+GIT_TEST_CMP=@GIT_TEST_CMP@
+GIT_TEST_CMP_USE_COPIED_CONTEXT=@GIT_TEST_CMP_USE_COPIED_CONTEXT@
+GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@
+NO_GETTEXT=@NO_GETTEXT@
+GIT_PERF_REPEAT_COUNT=@GIT_PERF_REPEAT_COUNT@
+GIT_PERF_REPO=@GIT_PERF_REPO@
+GIT_PERF_LARGE_REPO=@GIT_PERF_LARGE_REPO@
+GIT_PERF_MAKE_OPTS=@GIT_PERF_MAKE_OPTS@
+GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
+GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
+GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
+GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
+RUNTIME_PREFIX=@RUNTIME_PREFIX@
Makefile +37 -69

112 lines not on this page · raw message

contrib/buildsystems/CMakeLists.txt +38 -18

64 lines not on this page · raw message

t/test-lib.sh +7 -6
index 5de93911b9..3fab470f3b 100644
@@ -35,12 +35,6 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
-if test -z "$TEST_OUTPUT_DIRECTORY"
-then
-	# Similarly, override this to store the test-results subdir
-	# elsewhere
-	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
-fi
 GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
 then
@@ -100,6 +94,13 @@ fi
 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
 export PERL_PATH SHELL_PATH
 
+if test -z "$TEST_OUTPUT_DIRECTORY"
+then
+	# Similarly, override this to store the test-results subdir
+	# elsewhere
+	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
+fi
+
 # In t0000, we need to override test directories of nested testcases. In case
 # the developer has TEST_OUTPUT_DIRECTORY part of his build options, then we'd
 # reset this value to instead contain what the developer has specified. We thus
Signature · 1 line
2.47.0.rc0.dirty
#30 lore raw

RFC PATCH 15/21 Makefile: consistently use @PLACEHOLDER@ to substitute

In reply to Patrick Steinhardt

We have a bunch of placeholders in our scripts that we replace at build time, for example by using sed(1). These placeholders come in three different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Next to being inconsistent it also creates a bit of a problem with CMake, which only supports the first syntax. To work around that we instead manually replace such strings via string operations, which is both a hassle and also removes safeguards that CMake has to verify that we didn't forget to replace any placeholders. Besides that, other build systems like Meson also support the CMake syntax.

Unify our codebase to consistently use the syntax supported by such build systems.

---
 Makefile                                      | 42 +++++++++---------
 configure.ac                                  |  2 +-
 contrib/buildsystems/CMakeLists.txt           | 34 +++++++-------
 generate-perl.sh                              |  2 +-
 git-cvsserver.perl                            |  2 +-
 git-instaweb.sh                               |  8 ++--
 git-request-pull.sh                           |  2 +-
 git-send-email.perl                           |  2 +-
 git-sh-i18n.sh                                |  6 +--
 git-sh-setup.sh                               |  6 +--
 git-svn.perl                                  |  2 +-
 gitk-git/po/vi.po                             |  2 +-
 gitweb/Makefile                               | 44 +++++++++----------
 gitweb/gitweb.perl                            | 44 +++++++++----------
 perl/Git/I18N.pm                              |  6 +--
 perl/Git/LoadCPAN.pm                          |  6 +--
 .../header_templates/fixed_prefix.template.pl |  2 +-
 .../runtime_prefix.template.pl                |  8 ++--
 unimplemented.sh                              |  2 +-
 wrap-for-bin.sh                               | 18 ++++----
 20 files changed, 120 insertions(+), 120 deletions(-)
Makefile +21 -21
index e92ecd0c51..91e64c1222 100644
@@ -1552,10 +1552,10 @@ endif
 
 ifdef SANE_TOOL_PATH
 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
-BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
+BROKEN_PATH_FIX = 's|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
 PATH := $(SANE_TOOL_PATH):${PATH}
 else
-BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
+BROKEN_PATH_FIX = '/^\# @BROKEN_PATH_FIX@$$/d'
 endif
 
 ifeq (,$(HOST_CPU))
@@ -2524,13 +2524,13 @@ GIT-SCRIPT-DEFINES: FORCE
 define cmd_munge_script
 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
-    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
-    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
+    -e 's|@DIFF@|$(DIFF_SQ)|' \
+    -e 's|@LOCALEDIR@|$(localedir_SQ)|g' \
+    -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
-    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-    -e 's|@@PAGER_ENV@@|$(PAGER_ENV_SQ)|g' \
+    -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
+    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
 
@@ -2597,11 +2597,11 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
 	INSTLIBDIR='$(perllibdir_SQ)' && \
 	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
 	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
-	sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
-	    -e "s=@@INSTLIBDIR@@=$$INSTLIBDIR=g" \
-	    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
-	    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
-	    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
+	sed -e 's=@PATHSEP@=$(pathsep)=g' \
+	    -e "s=@INSTLIBDIR@=$$INSTLIBDIR=g" \
+	    -e 's=@PERLLIBDIR_REL@=$(perllibdir_relative_SQ)=g' \
+	    -e 's=@GITEXECDIR_REL@=$(gitexecdir_relative_SQ)=g' \
+	    -e 's=@LOCALEDIR_REL@=$(localedir_relative_SQ)=g' \
 	    $< >$@+ && \
 	mv $@+ $@
 
@@ -2617,7 +2617,7 @@ else # NO_PERL
 $(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
+	    -e 's|@REASON@|NO_PERL=$(NO_PERL)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -2638,13 +2638,13 @@ else # NO_PYTHON
 $(SCRIPT_PYTHON_GEN): % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
+	    -e 's|@REASON@|NO_PYTHON=$(NO_PYTHON)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 endif # NO_PYTHON
 
-CONFIGURE_RECIPE = sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+CONFIGURE_RECIPE = sed -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
 			configure.ac >configure.ac+ && \
 		   autoconf -o configure configure.ac+ && \
 		   $(RM) configure.ac+
@@ -3073,9 +3073,9 @@ endif
 perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN) \
-	sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
-	    -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \
-	    -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
+	sed -e 's|@LOCALEDIR@|$(perl_localedir_SQ)|g' \
+	    -e 's|@NO_GETTEXT@|$(NO_GETTEXT_SQ)|g' \
+	    -e 's|@NO_PERL_CPAN_FALLBACKS@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
 	< $< > $@
 
 perl/build/man/man3/Git.3pm: perl/Git.pm
@@ -3192,8 +3192,8 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
 bin-wrappers/%: wrap-for-bin.sh
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	     -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-	     -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
+	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
 	chmod +x $@
 
 # GNU make supports exporting all variables by "export" without parameters.
configure.ac +1 -1
index d1a96da14e..5923edc44a 100644
@@ -142,7 +142,7 @@ fi
 ## Configure body starts here.
 
 AC_PREREQ(2.59)
-AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
+AC_INIT([git], [@GIT_VERSION@], [[email protected]])
 
 AC_CONFIG_SRCDIR([git.c])
 
contrib/buildsystems/CMakeLists.txt +17 -17
index 2ba15155b3..bf029b9428 100644
@@ -833,14 +833,14 @@ set(git_shell_scripts
 foreach(script ${git_shell_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
 	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
-	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@DIFF@" "diff" content "${content}")
 	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
 	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
-	string(REPLACE "@@NO_CURL@@" "" content "${content}")
-	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
-	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
-	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	string(REPLACE "@NO_CURL@" "" content "${content}")
+	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
+	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
+	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -849,13 +849,13 @@ parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
-string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
-string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
+string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
 
 foreach(script ${git_perl_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
 	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
-	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -870,8 +870,8 @@ file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
 foreach(pm ${perl_modules})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
 	file(STRINGS ${pm} content NEWLINE_CONSUME)
-	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
 #test-lib.sh requires perl/build/lib to be the build directory of perl modules
 endforeach()
@@ -1079,21 +1079,21 @@ set(wrapper_test_scripts
 
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
 #options for configuring test options
generate-perl.sh +1 -1
index b9e04d6f42..41d78da029 100755
@@ -17,6 +17,6 @@ sed -e '1{' \
     -e "	r $PERL_HEADER" \
     -e '	G' \
     -e '}' \
-    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
+    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
     "$PERL_SCRIPT" >"$OUT"
 chmod a+x "$OUT"
git-cvsserver.perl +1 -1
index 124f598bdc..70ae7cb8e4 100755
@@ -26,7 +26,7 @@
 use File::Basename;
 use Getopt::Long qw(:config require_order no_ignore_case);
 
-my $VERSION = '@@GIT_VERSION@@';
+my $VERSION = '@GIT_VERSION@';
 
 my $log = GITCVS::log->new();
 my $cfg;
git-instaweb.sh +4 -4
index 8dbe21d588..c8efb1205a 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@@PERL@@'
+PERL='@PERL@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -38,8 +38,8 @@ conf="$GIT_DIR/gitweb/httpd.conf"
 # if installed, it doesn't need further configuration (module_path)
 test -z "$httpd" && httpd='lighttpd -f'
 
-# Default is @@GITWEBDIR@@
-test -z "$root" && root='@@GITWEBDIR@@'
+# Default is @GITWEBDIR@
+test -z "$root" && root='@GITWEBDIR@'
 
 # any untaken local port will do...
 test -z "$port" && port=1234
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@@PERL@@
+#!@PERL@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 01640a044b..10c88639e2 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
git-send-email.perl +1 -1
index c835d4c11a..02805c43e5 100755
@@ -1501,7 +1501,7 @@ sub gen_header {
 	@recipients = unique_email_list(@recipients,@cc,@initial_bcc);
 	@recipients = (map { extract_valid_address_or_die($_) } @recipients);
 	my $date = format_2822_time($time++);
-	my $gitversion = '@@GIT_VERSION@@';
+	my $gitversion = '@GIT_VERSION@';
 	if ($gitversion =~ m/..GIT_VERSION../) {
 	    $gitversion = Git::version();
 	}
git-sh-i18n.sh +3 -3
index a15c0620db..ae4b2d6ba9 100644
@@ -9,7 +9,7 @@ TEXTDOMAIN=git
 export TEXTDOMAIN
 if test -z "$GIT_TEXTDOMAINDIR"
 then
-	TEXTDOMAINDIR="@@LOCALEDIR@@"
+	TEXTDOMAINDIR="@LOCALEDIR@"
 else
 	TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
 fi
@@ -17,9 +17,9 @@ export TEXTDOMAINDIR
 
 # First decide what scheme to use...
 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
-if test -n "@@USE_GETTEXT_SCHEME@@"
+if test -n "@USE_GETTEXT_SCHEME@"
 then
-	GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
+	GIT_INTERNAL_GETTEXT_SH_SCHEME="@USE_GETTEXT_SCHEME@"
 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
 then
 	: no probing necessary
git-sh-setup.sh +3 -3
index ce273fe0e4..19aef72ec2 100644
@@ -41,7 +41,7 @@ git_broken_path_fix () {
 	esac
 }
 
-# @@BROKEN_PATH_FIX@@
+# @BROKEN_PATH_FIX@
 
 # Source git-sh-i18n for gettext support.
 . "$(git --exec-path)/git-sh-i18n"
@@ -154,7 +154,7 @@ git_pager() {
 	else
 		GIT_PAGER=cat
 	fi
-	for vardef in @@PAGER_ENV@@
+	for vardef in @PAGER_ENV@
 	do
 		var=${vardef%%=*}
 		eval ": \"\${$vardef}\" && export $var"
@@ -280,7 +280,7 @@ get_author_ident_from_commit () {
 # remove lines from $1 that are not in $2, leaving only common lines.
 create_virtual_base() {
 	sz0=$(wc -c <"$1")
-	@@DIFF@@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
+	@DIFF@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
 	sz1=$(wc -c <"$1")
 
 	# If we do not have enough common material, it is not
git-svn.perl +1 -1
index 01e7a70de1..dcf65cf1d1 100755
@@ -9,7 +9,7 @@
 		$_revision $_repository
 		$_q $_authors $_authors_prog %users/;
 $AUTHOR = 'Eric Wong <[email protected]>';
-$VERSION = '@@GIT_VERSION@@';
+$VERSION = '@GIT_VERSION@';
 
 use Carp qw/croak/;
 use File::Basename qw/dirname basename/;
gitk-git/po/vi.po +1 -1
index 5967498660..184430dcde 100644
@@ -5,7 +5,7 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: gitk @@GIT_VERSION@@\n"
+"Project-Id-Version: gitk @GIT_VERSION@\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2015-05-17 14:32+1000\n"
 "PO-Revision-Date: 2015-09-15 07:33+0700\n"
gitweb/Makefile +22 -22

50 lines not on this page · raw message

gitweb/gitweb.perl +22 -22

116 lines not on this page · raw message

perl/Git/I18N.pm +3 -3
index 5454c3a6d2..1da830c98a 100644
@@ -20,14 +20,14 @@ BEGIN
 # this "'@@' [...] '@@'" pattern.
 use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
 use constant NO_GETTEXT => (
-	q[@@NO_GETTEXT@@] ne ''
+	q[@NO_GETTEXT@] ne ''
 	and
-	q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
+	q[@NO_GETTEXT@] ne NO_GETTEXT_STR
 );
 
 sub __bootstrap_locale_messages {
 	our $TEXTDOMAIN = 'git';
-	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@LOCALEDIR@';
 	die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
 
 	require POSIX;
perl/Git/LoadCPAN.pm +3 -3
index 8c7fa805f9..6be99840f8 100644
@@ -31,11 +31,11 @@ =head1 DESCRIPTION
 # Makefile, and allows for detecting whether the module is loaded from
 # perl/Git as opposed to perl/build/Git, which is useful for one-off
 # testing without having Error.pm et al installed.
-use constant NO_PERL_CPAN_FALLBACKS_STR => '@@' . 'NO_PERL_CPAN_FALLBACKS' . '@@';
+use constant NO_PERL_CPAN_FALLBACKS_STR => '@' . 'NO_PERL_CPAN_FALLBACKS' . '@';
 use constant NO_PERL_CPAN_FALLBACKS => (
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne ''
+	q[@NO_PERL_CPAN_FALLBACKS@] ne ''
 	and
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne NO_PERL_CPAN_FALLBACKS_STR
+	q[@NO_PERL_CPAN_FALLBACKS@] ne NO_PERL_CPAN_FALLBACKS_STR
 );
 
 sub import {
perl/header_templates/fixed_prefix.template.pl +1 -1
index 857b4391a4..d571ca5cde 100644
@@ -1 +1 @@
-use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || '@@INSTLIBDIR@@'));
+use lib (split(/@PATHSEP@/, $ENV{GITPERLLIB} || '@INSTLIBDIR@'));
perl/header_templates/runtime_prefix.template.pl +4 -4
index 9d28b3d863..e6f8e661a1 100644
@@ -3,7 +3,7 @@
 # This finds our Git::* libraries relative to the script's runtime path.
 sub __git_system_path {
 	my ($relpath) = @_;
-	my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
+	my $gitexecdir_relative = '@GITEXECDIR_REL@';
 
 	# GIT_EXEC_PATH is supplied by `git` or the test suite.
 	my $exec_path;
@@ -24,11 +24,11 @@ sub __git_system_path {
 }
 
 BEGIN {
-	use lib split /@@PATHSEP@@/,
+	use lib split /@PATHSEP@/,
 	(
 		$ENV{GITPERLLIB} ||
 		do {
-			my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
+			my $perllibdir = __git_system_path('@PERLLIBDIR_REL@');
 			(-e $perllibdir) || die("Invalid system path ($relpath): $path");
 			$perllibdir;
 		}
@@ -36,7 +36,7 @@ BEGIN
 
 	# Export the system locale directory to the I18N module. The locale directory
 	# is only installed if NO_GETTEXT is set.
-	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
+	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@LOCALEDIR_REL@');
 }
 
 # END RUNTIME_PREFIX generated code.
unimplemented.sh +1 -1
index fee21d24e8..41776b279d 100644
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-echo >&2 "fatal: git was built without support for $(basename $0) (@@REASON@@)."
+echo >&2 "fatal: git was built without support for $(basename $0) (@REASON@)."
 exit 128
wrap-for-bin.sh +9 -9
index 95851b85b6..7898a1c238 100644
@@ -4,33 +4,33 @@
 # to run test suite against sandbox, but with only bindir-installed
 # executables in PATH.  The Makefile copies this into various
 # files in bin-wrappers, substituting
-# @@BUILD_DIR@@ and @@PROG@@.
+# @BUILD_DIR@ and @PROG@.
 
-GIT_EXEC_PATH='@@BUILD_DIR@@'
+GIT_EXEC_PATH='@BUILD_DIR@'
 if test -n "$NO_SET_GIT_TEMPLATE_DIR"
 then
 	unset GIT_TEMPLATE_DIR
 else
-	GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
+	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
 	export GIT_TEMPLATE_DIR
 fi
-GITPERLLIB='@@BUILD_DIR@@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
-PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
+GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
 export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
 case "$GIT_DEBUGGER" in
 '')
-	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 1)
 	unset GIT_DEBUGGER
-	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec gdb --args "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 *)
 	GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
 	unset GIT_DEBUGGER
-	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 esac
Signature · 1 line
2.47.0.rc0.dirty
#31 lore raw

Re: [RFC PATCH 15/21] Makefile: consistently use @PLACEHOLDER@ to substitute

Hi Patrick

Quoted 3 lines · Patrick Steinhardt

We have a bunch of placeholders in our scripts that we replace at build time, for example by using sed(1). These placeholders come in three different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

I agree that it's a good idea to stanardise on a single format here.

Quoted 2 lines

Next to being inconsistent it also creates a bit of a problem with CMake, which only supports the first syntax.

I'm a bit confused - is this referring to CMake's "configure_file" command?

Quoted 8 lines

To work around that we
instead manually replace such strings via string operations, which is both a hassle and also removes safeguards that CMake has to verify that we didn't forget to replace any placeholders. Besides that, other build systems like Meson also support the CMake syntax.

Unify our codebase to consistently use the syntax supported by such build systems.

Sounds good!

Phillip

Quoted 710 lines
---
  Makefile                                      | 42 +++++++++---------
  configure.ac                                  |  2 +-
  contrib/buildsystems/CMakeLists.txt           | 34 +++++++-------
  generate-perl.sh                              |  2 +-
  git-cvsserver.perl                            |  2 +-
  git-instaweb.sh                               |  8 ++--
  git-request-pull.sh                           |  2 +-
  git-send-email.perl                           |  2 +-
  git-sh-i18n.sh                                |  6 +--
  git-sh-setup.sh                               |  6 +--
  git-svn.perl                                  |  2 +-
  gitk-git/po/vi.po                             |  2 +-
  gitweb/Makefile                               | 44 +++++++++----------
  gitweb/gitweb.perl                            | 44 +++++++++----------
  perl/Git/I18N.pm                              |  6 +--
  perl/Git/LoadCPAN.pm                          |  6 +--
  .../header_templates/fixed_prefix.template.pl |  2 +-
  .../runtime_prefix.template.pl                |  8 ++--
  unimplemented.sh                              |  2 +-
  wrap-for-bin.sh                               | 18 ++++----
  20 files changed, 120 insertions(+), 120 deletions(-)
Makefile +21 -21
index e92ecd0c51..91e64c1222 100644
@@ -1552,10 +1552,10 @@ endif
 
  ifdef SANE_TOOL_PATH
  SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
-BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
+BROKEN_PATH_FIX = 's|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
  PATH := $(SANE_TOOL_PATH):${PATH}
  else
-BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
+BROKEN_PATH_FIX = '/^\# @BROKEN_PATH_FIX@$$/d'
  endif
 
  ifeq (,$(HOST_CPU))
@@ -2524,13 +2524,13 @@ GIT-SCRIPT-DEFINES: FORCE
  define cmd_munge_script
  sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
      -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
-    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
-    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
+    -e 's|@DIFF@|$(DIFF_SQ)|' \
+    -e 's|@LOCALEDIR@|$(localedir_SQ)|g' \
+    -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
      -e $(BROKEN_PATH_FIX) \
-    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-    -e 's|@@PAGER_ENV@@|$(PAGER_ENV_SQ)|g' \
+    -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
+    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
      [email protected] >$@+
  endef
 
@@ -2597,11 +2597,11 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
  	INSTLIBDIR='$(perllibdir_SQ)' && \
  	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
  	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
-	sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
-	    -e "s=@@INSTLIBDIR@@=$$INSTLIBDIR=g" \
-	    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
-	    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
-	    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
+	sed -e 's=@PATHSEP@=$(pathsep)=g' \
+	    -e "s=@INSTLIBDIR@=$$INSTLIBDIR=g" \
+	    -e 's=@PERLLIBDIR_REL@=$(perllibdir_relative_SQ)=g' \
+	    -e 's=@GITEXECDIR_REL@=$(gitexecdir_relative_SQ)=g' \
+	    -e 's=@LOCALEDIR_REL@=$(localedir_relative_SQ)=g' \
  	    $< >$@+ && \
  	mv $@+ $@
 
@@ -2617,7 +2617,7 @@ else # NO_PERL
  $(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh
  	$(QUIET_GEN) \
  	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
+	    -e 's|@REASON@|NO_PERL=$(NO_PERL)|g' \
  	    unimplemented.sh >$@+ && \
  	chmod +x $@+ && \
  	mv $@+ $@
@@ -2638,13 +2638,13 @@ else # NO_PYTHON
  $(SCRIPT_PYTHON_GEN): % : unimplemented.sh
  	$(QUIET_GEN) \
  	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
+	    -e 's|@REASON@|NO_PYTHON=$(NO_PYTHON)|g' \
  	    unimplemented.sh >$@+ && \
  	chmod +x $@+ && \
  	mv $@+ $@
  endif # NO_PYTHON
 
-CONFIGURE_RECIPE = sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+CONFIGURE_RECIPE = sed -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
  			configure.ac >configure.ac+ && \
  		   autoconf -o configure configure.ac+ && \
  		   $(RM) configure.ac+
@@ -3073,9 +3073,9 @@ endif
  perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
  	$(call mkdir_p_parent_template)
  	$(QUIET_GEN) \
-	sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
-	    -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \
-	    -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
+	sed -e 's|@LOCALEDIR@|$(perl_localedir_SQ)|g' \
+	    -e 's|@NO_GETTEXT@|$(NO_GETTEXT_SQ)|g' \
+	    -e 's|@NO_PERL_CPAN_FALLBACKS@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
  	< $< > $@
 
  perl/build/man/man3/Git.3pm: perl/Git.pm
@@ -3192,8 +3192,8 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
  bin-wrappers/%: wrap-for-bin.sh
  	$(call mkdir_p_parent_template)
  	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	     -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-	     -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
+	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
  	chmod +x $@
 
  # GNU make supports exporting all variables by "export" without parameters.
configure.ac +1 -1
index d1a96da14e..5923edc44a 100644
@@ -142,7 +142,7 @@ fi
  ## Configure body starts here.
 
  AC_PREREQ(2.59)
-AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
+AC_INIT([git], [@GIT_VERSION@], [[email protected]])
 
  AC_CONFIG_SRCDIR([git.c])
 
contrib/buildsystems/CMakeLists.txt +17 -17
index 2ba15155b3..bf029b9428 100644
@@ -833,14 +833,14 @@ set(git_shell_scripts
  foreach(script ${git_shell_scripts})
  	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
  	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
-	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@DIFF@" "diff" content "${content}")
  	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
  	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
-	string(REPLACE "@@NO_CURL@@" "" content "${content}")
-	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
-	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
-	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	string(REPLACE "@NO_CURL@" "" content "${content}")
+	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
+	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
+	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
  	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
  endforeach()
 
@@ -849,13 +849,13 @@ parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
  #create perl header
  file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
-string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
-string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
+string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
 
  foreach(script ${git_perl_scripts})
  	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
  	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
-	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
  	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
  endforeach()
 
@@ -870,8 +870,8 @@ file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
  foreach(pm ${perl_modules})
  	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
  	file(STRINGS ${pm} content NEWLINE_CONSUME)
-	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" content "${content}")
  	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
  #test-lib.sh requires perl/build/lib to be the build directory of perl modules
  endforeach()
@@ -1079,21 +1079,21 @@ set(wrapper_test_scripts
 
  foreach(script ${wrapper_scripts})
  	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
  	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
  endforeach()
 
  foreach(script ${wrapper_test_scripts})
  	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
  	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
  endforeach()
 
  file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
  file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
  #options for configuring test options
generate-perl.sh +1 -1
index b9e04d6f42..41d78da029 100755
@@ -17,6 +17,6 @@ sed -e '1{' \
      -e "	r $PERL_HEADER" \
      -e '	G' \
      -e '}' \
-    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
+    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
      "$PERL_SCRIPT" >"$OUT"
  chmod a+x "$OUT"
git-cvsserver.perl +1 -1
index 124f598bdc..70ae7cb8e4 100755
@@ -26,7 +26,7 @@
  use File::Basename;
  use Getopt::Long qw(:config require_order no_ignore_case);
 
-my $VERSION = '@@GIT_VERSION@@';
+my $VERSION = '@GIT_VERSION@';
 
  my $log = GITCVS::log->new();
  my $cfg;
git-instaweb.sh +4 -4
index 8dbe21d588..c8efb1205a 100755
@@ -3,7 +3,7 @@
  # Copyright (c) 2006 Eric Wong
  #
 
-PERL='@@PERL@@'
+PERL='@PERL@'
  OPTIONS_KEEPDASHDASH=
  OPTIONS_STUCKLONG=
  OPTIONS_SPEC="\
@@ -38,8 +38,8 @@ conf="$GIT_DIR/gitweb/httpd.conf"
  # if installed, it doesn't need further configuration (module_path)
  test -z "$httpd" && httpd='lighttpd -f'
 
-# Default is @@GITWEBDIR@@
-test -z "$root" && root='@@GITWEBDIR@@'
+# Default is @GITWEBDIR@
+test -z "$root" && root='@GITWEBDIR@'
 
  # any untaken local port will do...
  test -z "$port" && port=1234
@@ -716,7 +716,7 @@ EOF
 
  gitweb_conf() {
  	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@@PERL@@
+#!@PERL@
  our \$projectroot = "$(dirname "$fqgitdir")";
  our \$git_temp = "$fqgitdir/gitweb/tmp";
  our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 01640a044b..10c88639e2 100755
@@ -112,7 +112,7 @@ find_matching_ref='
  	}
  '
 
-set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
  remote_sha1=$2
  ref=$3
 
git-send-email.perl +1 -1
index c835d4c11a..02805c43e5 100755
@@ -1501,7 +1501,7 @@ sub gen_header {
  	@recipients = unique_email_list(@recipients,@cc,@initial_bcc);
  	@recipients = (map { extract_valid_address_or_die($_) } @recipients);
  	my $date = format_2822_time($time++);
-	my $gitversion = '@@GIT_VERSION@@';
+	my $gitversion = '@GIT_VERSION@';
  	if ($gitversion =~ m/..GIT_VERSION../) {
  	    $gitversion = Git::version();
  	}
git-sh-i18n.sh +3 -3
index a15c0620db..ae4b2d6ba9 100644
@@ -9,7 +9,7 @@ TEXTDOMAIN=git
  export TEXTDOMAIN
  if test -z "$GIT_TEXTDOMAINDIR"
  then
-	TEXTDOMAINDIR="@@LOCALEDIR@@"
+	TEXTDOMAINDIR="@LOCALEDIR@"
  else
  	TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
  fi
@@ -17,9 +17,9 @@ export TEXTDOMAINDIR
 
  # First decide what scheme to use...
  GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
-if test -n "@@USE_GETTEXT_SCHEME@@"
+if test -n "@USE_GETTEXT_SCHEME@"
  then
-	GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
+	GIT_INTERNAL_GETTEXT_SH_SCHEME="@USE_GETTEXT_SCHEME@"
  elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
  then
  	: no probing necessary
git-sh-setup.sh +3 -3
index ce273fe0e4..19aef72ec2 100644
@@ -41,7 +41,7 @@ git_broken_path_fix () {
  	esac
  }
 
-# @@BROKEN_PATH_FIX@@
+# @BROKEN_PATH_FIX@
 
  # Source git-sh-i18n for gettext support.
  . "$(git --exec-path)/git-sh-i18n"
@@ -154,7 +154,7 @@ git_pager() {
  	else
  		GIT_PAGER=cat
  	fi
-	for vardef in @@PAGER_ENV@@
+	for vardef in @PAGER_ENV@
  	do
  		var=${vardef%%=*}
  		eval ": \"\${$vardef}\" && export $var"
@@ -280,7 +280,7 @@ get_author_ident_from_commit () {
  # remove lines from $1 that are not in $2, leaving only common lines.
  create_virtual_base() {
  	sz0=$(wc -c <"$1")
-	@@DIFF@@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
+	@DIFF@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
  	sz1=$(wc -c <"$1")
 
  	# If we do not have enough common material, it is not
git-svn.perl +1 -1
index 01e7a70de1..dcf65cf1d1 100755
@@ -9,7 +9,7 @@
  		$_revision $_repository
  		$_q $_authors $_authors_prog %users/;
  $AUTHOR = 'Eric Wong <[email protected]>';
-$VERSION = '@@GIT_VERSION@@';
+$VERSION = '@GIT_VERSION@';
 
  use Carp qw/croak/;
  use File::Basename qw/dirname basename/;
gitk-git/po/vi.po +1 -1
index 5967498660..184430dcde 100644
@@ -5,7 +5,7 @@
  #
  msgid ""
  msgstr ""
-"Project-Id-Version: gitk @@GIT_VERSION@@\n"
+"Project-Id-Version: gitk @GIT_VERSION@\n"
  "Report-Msgid-Bugs-To: \n"
  "POT-Creation-Date: 2015-05-17 14:32+1000\n"
  "PO-Revision-Date: 2015-09-15 07:33+0700\n"
gitweb/Makefile +22 -22
index 3b68ab2d67..164c8d5375 100644
@@ -79,28 +79,28 @@ GITWEB_JSLIB_FILES += static/js/blame_incremental.js
 
 
  GITWEB_REPLACE = \
-	-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-	-e 's|++GIT_BINDIR++|$(bindir)|g' \
-	-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
-	-e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-	-e 's|++GITWEB_CONFIG_COMMON++|$(GITWEB_CONFIG_COMMON)|g' \
-	-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-	-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-	-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
-	-e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
-	-e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
-	-e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
-	-e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
-	-e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
-	-e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
-	-e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
-	-e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
-	-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
-	-e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
-	-e 's|++GITWEB_SITE_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
-	-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
-	-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
-	-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
+	-e 's|@GIT_VERSION@|$(GIT_VERSION)|g' \
+	-e 's|@GIT_BINDIR@|$(bindir)|g' \
+	-e 's|@GITWEB_CONFIG@|$(GITWEB_CONFIG)|g' \
+	-e 's|@GITWEB_CONFIG_SYSTEM@|$(GITWEB_CONFIG_SYSTEM)|g' \
+	-e 's|@GITWEB_CONFIG_COMMON@|$(GITWEB_CONFIG_COMMON)|g' \
+	-e 's|@GITWEB_HOME_LINK_STR@|$(GITWEB_HOME_LINK_STR)|g' \
+	-e 's|@GITWEB_SITENAME@|$(GITWEB_SITENAME)|g' \
+	-e 's|@GITWEB_PROJECTROOT@|$(GITWEB_PROJECTROOT)|g' \
+	-e 's|"@GITWEB_PROJECT_MAXDEPTH@"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
+	-e 's|@GITWEB_EXPORT_OK@|$(GITWEB_EXPORT_OK)|g' \
+	-e 's|@GITWEB_STRICT_EXPORT@|$(GITWEB_STRICT_EXPORT)|g' \
+	-e 's|@GITWEB_BASE_URL@|$(GITWEB_BASE_URL)|g' \
+	-e 's|@GITWEB_LIST@|$(GITWEB_LIST)|g' \
+	-e 's|@GITWEB_HOMETEXT@|$(GITWEB_HOMETEXT)|g' \
+	-e 's|@GITWEB_CSS@|$(GITWEB_CSS)|g' \
+	-e 's|@GITWEB_LOGO@|$(GITWEB_LOGO)|g' \
+	-e 's|@GITWEB_FAVICON@|$(GITWEB_FAVICON)|g' \
+	-e 's|@GITWEB_JS@|$(GITWEB_JS)|g' \
+	-e 's|@GITWEB_SITE_HTML_HEAD_STRING@|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
+	-e 's|@GITWEB_SITE_HEADER@|$(GITWEB_SITE_HEADER)|g' \
+	-e 's|@GITWEB_SITE_FOOTER@|$(GITWEB_SITE_FOOTER)|g' \
+	-e 's|@HIGHLIGHT_BIN@|$(HIGHLIGHT_BIN)|g'
 
  .PHONY: FORCE
  $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS: FORCE
gitweb/gitweb.perl +22 -22
index b09a8d0523..76e1f4e244 100755
@@ -35,7 +35,7 @@ BEGIN
  	CGI->compile() if $ENV{'MOD_PERL'};
  }
 
-our $version = "++GIT_VERSION++";
+our $version = "@GIT_VERSION@";
 
  our ($my_url, $my_uri, $base_url, $path_info, $home_link);
  sub evaluate_uri {
@@ -80,46 +80,46 @@ sub evaluate_uri {
 
  # core git executable to use
  # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+our $GIT = "@GIT_BINDIR@/git";
 
  # absolute fs-path which will be prepended to the project path
  #our $projectroot = "/pub/scm";
-our $projectroot = "++GITWEB_PROJECTROOT++";
+our $projectroot = "@GITWEB_PROJECTROOT@";
 
  # fs traversing limit for getting project list
  # the number is relative to the projectroot
-our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
+our $project_maxdepth = "@GITWEB_PROJECT_MAXDEPTH@";
 
  # string of the home link on top of all pages
-our $home_link_str = "++GITWEB_HOME_LINK_STR++";
+our $home_link_str = "@GITWEB_HOME_LINK_STR@";
 
  # extra breadcrumbs preceding the home link
  our @extra_breadcrumbs = ();
 
  # name of your site or organization to appear in page titles
  # replace this with something more descriptive for clearer bookmarks
-our $site_name = "++GITWEB_SITENAME++"
+our $site_name = "@GITWEB_SITENAME@"
                   || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
 
  # html snippet to include in the <head> section of each page
-our $site_html_head_string = "++GITWEB_SITE_HTML_HEAD_STRING++";
+our $site_html_head_string = "@GITWEB_SITE_HTML_HEAD_STRING@";
  # filename of html text to include at top of each page
-our $site_header = "++GITWEB_SITE_HEADER++";
+our $site_header = "@GITWEB_SITE_HEADER@";
  # html text to include at home page
-our $home_text = "++GITWEB_HOMETEXT++";
+our $home_text = "@GITWEB_HOMETEXT@";
  # filename of html text to include at bottom of each page
-our $site_footer = "++GITWEB_SITE_FOOTER++";
+our $site_footer = "@GITWEB_SITE_FOOTER@";
 
  # URI of stylesheets
-our @stylesheets = ("++GITWEB_CSS++");
+our @stylesheets = ("@GITWEB_CSS@");
  # URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
  our $stylesheet = undef;
  # URI of GIT logo (72x27 size)
-our $logo = "++GITWEB_LOGO++";
+our $logo = "@GITWEB_LOGO@";
  # URI of GIT favicon, assumed to be image/png type
-our $favicon = "++GITWEB_FAVICON++";
+our $favicon = "@GITWEB_FAVICON@";
  # URI of gitweb.js (JavaScript code for gitweb)
-our $javascript = "++GITWEB_JS++";
+our $javascript = "@GITWEB_JS@";
 
  # URI and label (title) of GIT logo link
  #our $logo_url = "https://www.kernel.org/pub/software/scm/git/docs/";
@@ -128,7 +128,7 @@ sub evaluate_uri {
  our $logo_label = "git homepage";
 
  # source of projects list
-our $projects_list = "++GITWEB_LIST++";
+our $projects_list = "@GITWEB_LIST@";
 
  # the width (in characters) of the projects list "Description" column
  our $projects_list_description_width = 25;
@@ -147,7 +147,7 @@ sub evaluate_uri {
 
  # show repository only if this file exists
  # (only effective if this variable evaluates to true)
-our $export_ok = "++GITWEB_EXPORT_OK++";
+our $export_ok = "@GITWEB_EXPORT_OK@";
 
  # don't generate age column on the projects list page
  our $omit_age_column = 0;
@@ -161,11 +161,11 @@ sub evaluate_uri {
  our $export_auth_hook = undef;
 
  # only allow viewing of repositories also shown on the overview page
-our $strict_export = "++GITWEB_STRICT_EXPORT++";
+our $strict_export = "@GITWEB_STRICT_EXPORT@";
 
  # list of git base URLs used for URL to where fetch project from,
  # i.e. full URL is "$git_base_url/$project"
-our @git_base_url_list = grep { $_ ne '' } ("++GITWEB_BASE_URL++");
+our @git_base_url_list = grep { $_ ne '' } ("@GITWEB_BASE_URL@");
 
  # default blob_plain mimetype and default charset for text/plain blob
  our $default_blob_plain_mimetype = 'text/plain';
@@ -200,7 +200,7 @@ sub evaluate_uri {
  # http://andre-simon.de/zip/download.php due to assumptions about parameters and output).
  # Useful if highlight is not installed on your webserver's PATH.
  # [Default: highlight]
-our $highlight_bin = "++HIGHLIGHT_BIN++";
+our $highlight_bin = "@HIGHLIGHT_BIN@";
 
  # information about snapshot formats that gitweb is capable of serving
  our %known_snapshot_formats = (
@@ -741,9 +741,9 @@ sub read_config_file {
 
  our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM, $GITWEB_CONFIG_COMMON);
  sub evaluate_gitweb_config {
-	our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-	our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
-	our $GITWEB_CONFIG_COMMON = $ENV{'GITWEB_CONFIG_COMMON'} || "++GITWEB_CONFIG_COMMON++";
+	our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "@GITWEB_CONFIG@";
+	our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "@GITWEB_CONFIG_SYSTEM@";
+	our $GITWEB_CONFIG_COMMON = $ENV{'GITWEB_CONFIG_COMMON'} || "@GITWEB_CONFIG_COMMON@";
 
  	# Protect against duplications of file names, to not read config twice.
  	# Only one of $GITWEB_CONFIG and $GITWEB_CONFIG_SYSTEM is used, so
perl/Git/I18N.pm +3 -3
index 5454c3a6d2..1da830c98a 100644
@@ -20,14 +20,14 @@ BEGIN
  # this "'@@' [...] '@@'" pattern.
  use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
  use constant NO_GETTEXT => (
-	q[@@NO_GETTEXT@@] ne ''
+	q[@NO_GETTEXT@] ne ''
  	and
-	q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
+	q[@NO_GETTEXT@] ne NO_GETTEXT_STR
  );
 
  sub __bootstrap_locale_messages {
  	our $TEXTDOMAIN = 'git';
-	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@LOCALEDIR@';
  	die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
 
  	require POSIX;
perl/Git/LoadCPAN.pm +3 -3
index 8c7fa805f9..6be99840f8 100644
@@ -31,11 +31,11 @@ =head1 DESCRIPTION
  # Makefile, and allows for detecting whether the module is loaded from
  # perl/Git as opposed to perl/build/Git, which is useful for one-off
  # testing without having Error.pm et al installed.
-use constant NO_PERL_CPAN_FALLBACKS_STR => '@@' . 'NO_PERL_CPAN_FALLBACKS' . '@@';
+use constant NO_PERL_CPAN_FALLBACKS_STR => '@' . 'NO_PERL_CPAN_FALLBACKS' . '@';
  use constant NO_PERL_CPAN_FALLBACKS => (
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne ''
+	q[@NO_PERL_CPAN_FALLBACKS@] ne ''
  	and
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne NO_PERL_CPAN_FALLBACKS_STR
+	q[@NO_PERL_CPAN_FALLBACKS@] ne NO_PERL_CPAN_FALLBACKS_STR
  );
 
  sub import {
perl/header_templates/fixed_prefix.template.pl +1 -1
index 857b4391a4..d571ca5cde 100644
@@ -1 +1 @@
-use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || '@@INSTLIBDIR@@'));
+use lib (split(/@PATHSEP@/, $ENV{GITPERLLIB} || '@INSTLIBDIR@'));
perl/header_templates/runtime_prefix.template.pl +4 -4
index 9d28b3d863..e6f8e661a1 100644
@@ -3,7 +3,7 @@
  # This finds our Git::* libraries relative to the script's runtime path.
  sub __git_system_path {
  	my ($relpath) = @_;
-	my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
+	my $gitexecdir_relative = '@GITEXECDIR_REL@';
 
  	# GIT_EXEC_PATH is supplied by `git` or the test suite.
  	my $exec_path;
@@ -24,11 +24,11 @@ sub __git_system_path {
  }
 
  BEGIN {
-	use lib split /@@PATHSEP@@/,
+	use lib split /@PATHSEP@/,
  	(
  		$ENV{GITPERLLIB} ||
  		do {
-			my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
+			my $perllibdir = __git_system_path('@PERLLIBDIR_REL@');
  			(-e $perllibdir) || die("Invalid system path ($relpath): $path");
  			$perllibdir;
  		}
@@ -36,7 +36,7 @@ BEGIN
 
  	# Export the system locale directory to the I18N module. The locale directory
  	# is only installed if NO_GETTEXT is set.
-	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
+	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@LOCALEDIR_REL@');
  }
 
  # END RUNTIME_PREFIX generated code.
unimplemented.sh +1 -1
index fee21d24e8..41776b279d 100644
@@ -1,4 +1,4 @@
  #!/bin/sh
 
-echo >&2 "fatal: git was built without support for $(basename $0) (@@REASON@@)."
+echo >&2 "fatal: git was built without support for $(basename $0) (@REASON@)."
  exit 128
wrap-for-bin.sh +9 -9
index 95851b85b6..7898a1c238 100644
@@ -4,33 +4,33 @@
  # to run test suite against sandbox, but with only bindir-installed
  # executables in PATH.  The Makefile copies this into various
  # files in bin-wrappers, substituting
-# @@BUILD_DIR@@ and @@PROG@@.
+# @BUILD_DIR@ and @PROG@.
 
-GIT_EXEC_PATH='@@BUILD_DIR@@'
+GIT_EXEC_PATH='@BUILD_DIR@'
  if test -n "$NO_SET_GIT_TEMPLATE_DIR"
  then
  	unset GIT_TEMPLATE_DIR
  else
-	GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
+	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
  	export GIT_TEMPLATE_DIR
  fi
-GITPERLLIB='@@BUILD_DIR@@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
-PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
+GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
  export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
  case "$GIT_DEBUGGER" in
  '')
-	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec "${GIT_EXEC_PATH}/@PROG@" "$@"
  	;;
  1)
  	unset GIT_DEBUGGER
-	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec gdb --args "${GIT_EXEC_PATH}/@PROG@" "$@"
  	;;
  *)
  	GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
  	unset GIT_DEBUGGER
-	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@PROG@" "$@"
  	;;
  esac
#32 lore raw

Re: [RFC PATCH 15/21] Makefile: consistently use @PLACEHOLDER@ to substitute

Quoted 7 lines · Phillip Wood

Hi Patrick

Quoted 3 lines · Patrick Steinhardt

We have a bunch of placeholders in our scripts that we replace at build time, for example by using sed(1). These placeholders come in three different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Quoted 6 lines

I agree that it's a good idea to stanardise on a single format here.

Quoted 2 lines

Next to being inconsistent it also creates a bit of a problem with CMake, which only supports the first syntax.

I'm a bit confused - is this referring to CMake's "configure_file" command?

Ah, yes. I should've made this more explicit.

Patrick

#33 lore raw

RFC PATCH 16/21 Makefile: consistently use PERL_PATH

In reply to Patrick Steinhardt

When injecting the Perl path into our scripts we sometimes use '@PERL@' while we othertimes use '@PERL_PATH@'. Refactor the code use the latter consistently, which makes it easier to reuse the same logic for multiple scripts.

---
 Makefile                            | 2 +-
 contrib/buildsystems/CMakeLists.txt | 2 +-
 git-instaweb.sh                     | 4 ++--
 git-request-pull.sh                 | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
Makefile +1 -1
index 91e64c1222..380b6a3dbc 100644
@@ -2529,7 +2529,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
     -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
-    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' \
     -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
contrib/buildsystems/CMakeLists.txt +1 -1
index bf029b9428..5884fa73b1 100644
@@ -839,7 +839,7 @@ foreach(script ${git_shell_scripts})
 	string(REPLACE "@NO_CURL@" "" content "${content}")
 	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
 	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
-	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PERL_PATH@" "${PERL_PATH}" content "${content}")
 	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
git-instaweb.sh +2 -2
index c8efb1205a..5ad50160bb 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@PERL@'
+PERL='@PERL_PATH@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@PERL@
+#!@PERL_PATH@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 10c88639e2..775ba8ea11 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL_PATH@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
Signature · 1 line
2.47.0.rc0.dirty
#34 lore raw

RFC PATCH 17/21 Makefile: allow "bin-wrappers/" directory to exist

In reply to Patrick Steinhardt

The "bin-wrappers/" directory gets created by our build system and is populated with one script for each of our binaries. There isn't anything inherently wrong with the current layout, but it is somewhat hard to adapt for out-of-tree build systems.

Adapt the layout such that our "bin-wrappers/" directory always exists and contains our "wrap-for-bin.sh" script to make things a little bit easier for subsequent steps.

---
 .gitignore                                      | 1 -
 Documentation/CodingGuidelines                  | 2 +-
 Makefile                                        | 6 +++---
 bin-wrappers/.gitignore                         | 9 +++++++++
 wrap-for-bin.sh => bin-wrappers/wrap-for-bin.sh | 0
 contrib/buildsystems/CMakeLists.txt             | 6 +++---
 6 files changed, 16 insertions(+), 8 deletions(-)
 create mode 100644 bin-wrappers/.gitignore
 rename wrap-for-bin.sh => bin-wrappers/wrap-for-bin.sh (100%)
 mode change 100644 => 100755
.gitignore +0 -1
index 6687bd6db4..349673c55c 100644
@@ -12,7 +12,6 @@
 /GIT-TEST-SUITES
 /GIT-USER-AGENT
 /GIT-VERSION-FILE
-/bin-wrappers/
 /git
 /git-add
 /git-am
Documentation/CodingGuidelines +1 -1
index 3263245b03..ad83156744 100644
@@ -583,7 +583,7 @@ For C programs:
    Run `GIT_DEBUGGER=1 ./bin-wrappers/git foo` to simply use gdb as is, or
    run `GIT_DEBUGGER="<debugger> <debugger-args>" ./bin-wrappers/git foo` to
    use your own debugger and arguments. Example: `GIT_DEBUGGER="ddd --gdb"
-   ./bin-wrappers/git log` (See `wrap-for-bin.sh`.)
+   ./bin-wrappers/git log` (See `bin-wrappers/wrap-for-bin.sh`.)
 
  - The primary data structure that a subsystem 'S' deals with is called
    `struct S`. Functions that operate on `struct S` are named
Makefile +3 -3
index 380b6a3dbc..b0c21c4c0d 100644
@@ -3189,8 +3189,7 @@ test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG)
 
-bin-wrappers/%: wrap-for-bin.sh
-	$(call mkdir_p_parent_template)
+bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
 	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
@@ -3686,7 +3685,8 @@ clean: profile-clean coverage-clean cocciclean
 	$(RM) $(FUZZ_PROGRAMS)
 	$(RM) $(SP_OBJ)
 	$(RM) $(HCC)
-	$(RM) -r bin-wrappers $(dep_dirs) $(compdb_dir) compile_commands.json
+	$(RM) -r $(dep_dirs) $(compdb_dir) compile_commands.json
+	$(RM) $(test_bindir_programs)
 	$(RM) -r po/build/
 	$(RM) *.pyc *.pyo */*.pyc */*.pyo $(GENERATED_H) $(ETAGS_TARGET) tags cscope*
 	$(RM) -r .dist-tmp-dir .doc-tmp-dir
bin-wrappers/.gitignore new file +9 -0
new file mode 100644
index 0000000000..1c6c90458b
@@ -0,0 +1,9 @@
+/git
+/git-cvsserver
+/git-receive-pack
+/git-shell
+/git-upload-archive
+/git-upload-pack
+/scalar
+/test-fake-ssh
+/test-tool
bin-wrappers/wrap-for-bin.sh renamed from wrap-for-bin.sh +0 -0
old mode 100644
new mode 100755
similarity index 100%
rename from wrap-for-bin.sh
rename to bin-wrappers/wrap-for-bin.sh
contrib/buildsystems/CMakeLists.txt +3 -3
index 5884fa73b1..700f4e5160 100644
@@ -1078,20 +1078,20 @@ set(wrapper_test_scripts
 
 
 foreach(script ${wrapper_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
-file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
Signature · 1 line
2.47.0.rc0.dirty
#35 lore raw

RFC PATCH 18/21 Makefile: simplify building of templates

In reply to Patrick Steinhardt

When we install Git we also install a set of default templates that both git-init(1) and git-clone(1) populate into our build directories. The way the pristine templates are layed out in our source directory is somewhat weird though: instead of reconstructing the actual directory hierarchy in "templates/", we represent directory separators with "--".

The only reason I could come up with for why we have this is the "branches/" directory, which is supposed to be empty when installing it. And as Git famously doesn't store empty directories at all we have to work around this limitation.

Now the thing is that the "branches/" directory is a leftover to how branches used to be stored in the dark ages. gitrepository-layout(5) lists this directory as "slightly deprecated", which I would claim is a strong understatement. I have never encountered anybody using it today and would be surprised if it even works as expected. So having the "--" hack in place for an item that is basically unused, unmaintained and deprecated doesn't only feel unreasonable, but installing that entry by default may also cause confusion for users that do not know what this is supposed to be in the first place.

Remove this directory from our templates and, now that we do not require the workaround anymore, restructure the templates to form a proper hierarchy. This makes it way easier for build systems to install these templates into place.

We should likely think about removing support for "branch/" altogether, but that is outside of the scope of this patch series.

---
 contrib/buildsystems/CMakeLists.txt           |  8 +---
 templates/Makefile                            | 38 ++++++++++++-------
 templates/branches--                          |  1 -
 templates/{this--description => description}  |  0
 .../applypatch-msg.sample}                    |  0
 .../commit-msg.sample}                        |  0
 .../fsmonitor-watchman.sample}                |  0
 .../post-update.sample}                       |  0
 .../pre-applypatch.sample}                    |  0
 .../pre-commit.sample}                        |  0
 .../pre-merge-commit.sample}                  |  0
 .../pre-push.sample}                          |  0
 .../pre-rebase.sample}                        |  0
 .../pre-receive.sample}                       |  0
 .../prepare-commit-msg.sample}                |  0
 .../push-to-checkout.sample}                  |  0
 .../sendemail-validate.sample}                |  0
 .../update.sample}                            |  0
 templates/{info--exclude => info/exclude}     |  0
 19 files changed, 25 insertions(+), 22 deletions(-)
 delete mode 100644 templates/branches--
 rename templates/{this--description => description} (100%)
 rename templates/{hooks--applypatch-msg.sample => hooks/applypatch-msg.sample} (100%)
 rename templates/{hooks--commit-msg.sample => hooks/commit-msg.sample} (100%)
 rename templates/{hooks--fsmonitor-watchman.sample => hooks/fsmonitor-watchman.sample} (100%)
 rename templates/{hooks--post-update.sample => hooks/post-update.sample} (100%)
 rename templates/{hooks--pre-applypatch.sample => hooks/pre-applypatch.sample} (100%)
 rename templates/{hooks--pre-commit.sample => hooks/pre-commit.sample} (100%)
 rename templates/{hooks--pre-merge-commit.sample => hooks/pre-merge-commit.sample} (100%)
 rename templates/{hooks--pre-push.sample => hooks/pre-push.sample} (100%)
 rename templates/{hooks--pre-rebase.sample => hooks/pre-rebase.sample} (100%)
 rename templates/{hooks--pre-receive.sample => hooks/pre-receive.sample} (100%)
 rename templates/{hooks--prepare-commit-msg.sample => hooks/prepare-commit-msg.sample} (100%)
 rename templates/{hooks--push-to-checkout.sample => hooks/push-to-checkout.sample} (100%)
 rename templates/{hooks--sendemail-validate.sample => hooks/sendemail-validate.sample} (100%)
 rename templates/{hooks--update.sample => hooks/update.sample} (100%)
 rename templates/{info--exclude => info/exclude} (100%)
contrib/buildsystems/CMakeLists.txt +1 -7
index 700f4e5160..23c2fb91ce 100644
@@ -878,23 +878,17 @@ endforeach()
 
 
 #templates
-file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
+file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/**")
 list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
 list(REMOVE_ITEM templates ".gitignore")
 list(REMOVE_ITEM templates "Makefile")
 list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
 
-list(REMOVE_ITEM templates "branches--")
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
-
 #templates have @.*@ replacement so use configure_file instead
 foreach(tm ${templates})
-	string(REPLACE "--" "/" blt_tm ${tm})
-	string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
 	configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
 endforeach()
 
-
 #translations
 if(MSGFMT_EXE)
 	file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
templates/Makefile +24 -14
index 367ad00c24..0b91d18925 100644
@@ -29,24 +29,34 @@ all: boilerplates.made custom
 # in a file direc--tory--file in the source.  They will be
 # just copied to the destination.
 
-bpsrc = $(filter-out %~,$(wildcard *--*))
-boilerplates.made : $(bpsrc)
-	$(QUIET)umask 022 && ls *--* 2>/dev/null | \
-	while read boilerplate; \
+TEMPLATES  = description
+TEMPLATES += hooks/applypatch-msg.sample
+TEMPLATES += hooks/commit-msg.sample
+TEMPLATES += hooks/fsmonitor-watchman.sample
+TEMPLATES += hooks/post-update.sample
+TEMPLATES += hooks/pre-applypatch.sample
+TEMPLATES += hooks/pre-commit.sample
+TEMPLATES += hooks/pre-merge-commit.sample
+TEMPLATES += hooks/prepare-commit-msg.sample
+TEMPLATES += hooks/pre-push.sample
+TEMPLATES += hooks/pre-rebase.sample
+TEMPLATES += hooks/pre-receive.sample
+TEMPLATES += hooks/push-to-checkout.sample
+TEMPLATES += hooks/sendemail-validate.sample
+TEMPLATES += hooks/update.sample
+TEMPLATES += info/exclude
+
+boilerplates.made: $(TEMPLATES)
+	$(QUIET)umask 022 && for template in $(TEMPLATES); \
 	do \
-		case "$$boilerplate" in *~) continue ;; esac && \
-		dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
-		dir=`expr "$$dst" : '\(.*\)/'` && \
+		dir=$$(dirname "$$template") && \
 		mkdir -p blt/$$dir && \
-		case "$$boilerplate" in \
-		*--) continue;; \
-		esac && \
 		sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 		    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-		    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
-			blt/$$dst && \
-		if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
-		chmod a+$$rx "blt/$$dst" || exit; \
+		    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$template > \
+			blt/$$template && \
+		if test -x "$$template"; then rx=rx; else rx=r; fi && \
+		chmod a+$$rx "blt/$$template" || exit; \
 	done && \
 	date >$@
 
templates/branches-- deleted +0 -1
deleted file mode 100644
index fae88709a6..0000000000
@@ -1 +0,0 @@
-: this is just to ensure the directory exists.
templates/description renamed from templates/this--description +0 -0
similarity index 100%
rename from templates/this--description
rename to templates/description
templates/hooks/applypatch-msg.sample renamed from templates/hooks--applypatch-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--applypatch-msg.sample
rename to templates/hooks/applypatch-msg.sample
templates/hooks/commit-msg.sample renamed from templates/hooks--commit-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--commit-msg.sample
rename to templates/hooks/commit-msg.sample
templates/hooks/fsmonitor-watchman.sample renamed from templates/hooks--fsmonitor-watchman.sample +0 -0
similarity index 100%
rename from templates/hooks--fsmonitor-watchman.sample
rename to templates/hooks/fsmonitor-watchman.sample
templates/hooks/post-update.sample renamed from templates/hooks--post-update.sample +0 -0
similarity index 100%
rename from templates/hooks--post-update.sample
rename to templates/hooks/post-update.sample
templates/hooks/pre-applypatch.sample renamed from templates/hooks--pre-applypatch.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-applypatch.sample
rename to templates/hooks/pre-applypatch.sample
templates/hooks/pre-commit.sample renamed from templates/hooks--pre-commit.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-commit.sample
rename to templates/hooks/pre-commit.sample
templates/hooks/pre-merge-commit.sample renamed from templates/hooks--pre-merge-commit.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-merge-commit.sample
rename to templates/hooks/pre-merge-commit.sample
templates/hooks/pre-push.sample renamed from templates/hooks--pre-push.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-push.sample
rename to templates/hooks/pre-push.sample
templates/hooks/pre-rebase.sample renamed from templates/hooks--pre-rebase.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-rebase.sample
rename to templates/hooks/pre-rebase.sample
templates/hooks/pre-receive.sample renamed from templates/hooks--pre-receive.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-receive.sample
rename to templates/hooks/pre-receive.sample
templates/hooks/prepare-commit-msg.sample renamed from templates/hooks--prepare-commit-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--prepare-commit-msg.sample
rename to templates/hooks/prepare-commit-msg.sample
templates/hooks/push-to-checkout.sample renamed from templates/hooks--push-to-checkout.sample +0 -0
similarity index 100%
rename from templates/hooks--push-to-checkout.sample
rename to templates/hooks/push-to-checkout.sample
templates/hooks/sendemail-validate.sample renamed from templates/hooks--sendemail-validate.sample +0 -0
similarity index 100%
rename from templates/hooks--sendemail-validate.sample
rename to templates/hooks/sendemail-validate.sample
templates/hooks/update.sample renamed from templates/hooks--update.sample +0 -0
similarity index 100%
rename from templates/hooks--update.sample
rename to templates/hooks/update.sample
templates/info/exclude renamed from templates/info--exclude +0 -0
similarity index 100%
rename from templates/info--exclude
rename to templates/info/exclude
Signature · 1 line
2.47.0.rc0.dirty
#36 lore raw

RFC PATCH 19/21 t: better support for out-of-tree builds

In reply to Patrick Steinhardt

Our in-tree builds used by the Makefile use various different build directories scattered around different locations. The paths to those build directories have to be propagated to our tests such that they can find the contained files. This is done via a mixture of hardcoded paths in our test library and injected variables in our bin-wrappers or "GIT-BUILD-OPTIONS".

The latter two mechanisms are preferable over using hardcoded paths. For one, we have all paths which are subject to change stored in a small set of central files instead of having the knowledge of build paths in many files. And second, it allows build systems which build files elsewhere to adapt those paths based on their own needs. This is especially nice in the context of build systems that use out-of-tree builds like CMake or Meson.

Remove hardcoded knowledge of build paths from our test library and move it into our bin-wrappers and "GIT-BUILD-OPTIONS".

---
 GIT-BUILD-OPTIONS.in                |  5 +++++
 Makefile                            |  9 +++++++++
 bin-wrappers/wrap-for-bin.sh        | 11 ++++++-----
 contrib/buildsystems/CMakeLists.txt |  8 ++++++++
 t/lib-gettext.sh                    |  4 ++--
 t/t7609-mergetool--lib.sh           |  2 +-
 t/test-lib.sh                       |  6 +++---
 7 files changed, 34 insertions(+), 11 deletions(-)
GIT-BUILD-OPTIONS.in +5 -0
index e73cd5fa1a..2b3f5ef2d6 100644
@@ -32,4 +32,9 @@ GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
 GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
 GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
 GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
+GIT_TEST_TEXTDOMAINDIR=@GIT_TEST_TEXTDOMAINDIR@
+GIT_TEST_POPATH=@GIT_TEST_POPATH@
+GIT_TEST_TEMPLATE_DIR=@GIT_TEST_TEMPLATE_DIR@
+GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
+GIT_TEST_MERGE_TOOLS_DIR=@GIT_TEST_MERGE_TOOLS_DIR@
 RUNTIME_PREFIX=@RUNTIME_PREFIX@
Makefile +9 -0
index b0c21c4c0d..e6b75b6e3e 100644
@@ -3168,6 +3168,11 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@GIT_INTEROP_MAKE_OPTS@|\'$(GIT_INTEROP_MAKE_OPTS)\'|" \
 		-e "s|@GIT_TEST_INDEX_VERSION@|\'$(GIT_TEST_INDEX_VERSION)\'|" \
 		-e "s|@GIT_TEST_PERL_FATAL_WARNINGS@|\'$(GIT_TEST_PERL_FATAL_WARNINGS)\'|" \
+		-e "s|@GIT_TEST_TEXTDOMAINDIR@|\'$(shell pwd)/po/build/locale\'|" \
+		-e "s|@GIT_TEST_POPATH@|\'$(shell pwd)/po\'|" \
+		-e "s|@GIT_TEST_TEMPLATE_DIR@|\'$(shell pwd)/templates/blt\'|" \
+		-e "s|@GIT_TEST_GITPERLLIB@|\'$(shell pwd)/perl/build/lib\'|" \
+		-e "s|@GIT_TEST_MERGE_TOOLS_DIR@|\'$(shell pwd)/mergetools\'|" \
 		-e "s|@RUNTIME_PREFIX@|\'$(RUNTIME_PREFIX)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
@@ -3192,6 +3197,10 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
 bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@GIT_TEXTDOMAINDIR@|$(shell pwd)/po/build/locale|' \
+	     -e 's|@GITPERLLIB@|$(shell pwd)/perl/build/lib|' \
+	     -e 's|@MERGE_TOOLS_DIR@|$(shell pwd)/mergetools|' \
+	     -e 's|@TEMPLATE_DIR@|$(shell pwd)/templates/blt|' \
 	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
 	chmod +x $@
 
bin-wrappers/wrap-for-bin.sh +6 -5
index 7898a1c238..1d3a59a008 100755
@@ -4,21 +4,22 @@
 # to run test suite against sandbox, but with only bindir-installed
 # executables in PATH.  The Makefile copies this into various
 # files in bin-wrappers, substituting
-# @BUILD_DIR@ and @PROG@.
+# @BUILD_DIR@, @TEMPLATE_DIR@ and @PROG@.
 
 GIT_EXEC_PATH='@BUILD_DIR@'
 if test -n "$NO_SET_GIT_TEMPLATE_DIR"
 then
 	unset GIT_TEMPLATE_DIR
 else
-	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
+	GIT_TEMPLATE_DIR='@TEMPLATE_DIR@'
 	export GIT_TEMPLATE_DIR
 fi
-GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+MERGE_TOOLS_DIR='@MERGE_TOOLS_DIR@'
+GITPERLLIB='@GITPERLLIB@'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@GIT_TEXTDOMAINDIR@'
 PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
-export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
+export MERGE_TOOLS_DIR GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
 case "$GIT_DEBUGGER" in
 '')
contrib/buildsystems/CMakeLists.txt +8 -0
index 23c2fb91ce..4048d3c367 100644
@@ -1087,6 +1087,9 @@ endforeach()
 
 file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@GIT_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" content "${content}")
+string(REPLACE "@GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" content "${content}")
+string(REPLACE "@MERGE_TOOLS_DIR@" "${CMAKE_SOURCE_DIR}/mergetools" content "${content}")
 string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
@@ -1165,6 +1168,11 @@ string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_optio
 string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
 string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
 string(REPLACE "@RUNTIME_PREFIX@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_POPATH@" "${CMAKE_BINARY_DIR}/po" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "${CMAKE_BINARY_DIR}/templates/blt" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_MERGE_TOOLS_DIR@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
t/lib-gettext.sh +2 -2
index cc6bb2cdea..7a734c6973 100644
@@ -6,8 +6,8 @@
 
 . ./test-lib.sh
 
-GIT_TEXTDOMAINDIR="$GIT_BUILD_DIR/po/build/locale"
-GIT_PO_PATH="$GIT_BUILD_DIR/po"
+GIT_TEXTDOMAINDIR="$GIT_TEST_TEXTDOMAINDIR"
+GIT_PO_PATH="$GIT_TEST_POPATH"
 export GIT_TEXTDOMAINDIR GIT_PO_PATH
 
 if test -n "$GIT_TEST_INSTALLED"
t/t7609-mergetool--lib.sh +1 -1
index 8b1c3bd39f..a9273ba58d 100755
@@ -8,7 +8,7 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'mergetool --tool=vimdiff creates the expected layout' '
-	. "$GIT_BUILD_DIR"/mergetools/vimdiff &&
+	. "$GIT_TEST_MERGE_TOOLS_DIR"/vimdiff &&
 	run_unit_tests
 '
 
t/test-lib.sh +3 -3
index 3fab470f3b..e36a21ddf7 100644
@@ -1504,7 +1504,7 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
 		PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"
 	fi
 fi
-GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
+GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR"
 GIT_CONFIG_NOSYSTEM=1
 GIT_ATTR_NOSYSTEM=1
 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/.."
@@ -1520,9 +1520,9 @@ then
 	fi
 fi
 
-GITPERLLIB="$GIT_BUILD_DIR"/perl/build/lib
+GITPERLLIB="$GIT_TEST_GITPERLLIB"
 export GITPERLLIB
-test -d "$GIT_BUILD_DIR"/templates/blt || {
+test -d "$GIT_TEMPLATE_DIR" || {
 	BAIL_OUT "You haven't built things yet, have you?"
 }
 
Signature · 1 line
2.47.0.rc0.dirty
#37 lore raw

RFC PATCH 20/21 t: allow overriding build dir

In reply to Patrick Steinhardt

Our "test-lib.sh" assumes that our build directory is the parent directory of "t/". While true when using our Makefile, it's not when using build systems that support out-of-tree builds.

Allow such build systems to override the location of the build directory with an environment variable.

---
 t/test-lib.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/test-lib.sh +2 -1
index e36a21ddf7..6f862621af 100644
@@ -35,7 +35,7 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
-GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
+GIT_BUILD_DIR="${GIT_BUILD_DIR:-${TEST_DIRECTORY%/t}}"
 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
 then
 	echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2
@@ -514,6 +514,7 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 		PERF_
 		CURL_VERBOSE
 		TRACE_CURL
+		BUILD_DIR
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
 	print join("\n", @vars);
Signature · 1 line
2.47.0.rc0.dirty
#38 lore raw

Re: [RFC PATCH 20/21] t: allow overriding build dir

Hi Patrick

Quoted 6 lines · Patrick Steinhardt

Our "test-lib.sh" assumes that our build directory is the parent directory of "t/". While true when using our Makefile, it's not when using build systems that support out-of-tree builds.

Allow such build systems to override the location of the build directory with an environment variable.

ee9e66e4e76 (cmake: avoid editing t/test-lib.sh, 2022-10-18) added support for reading the "real" build directory from "$GIT_BUILD_DIR/GIT-BUILD-DIR". Using an environment variable is fine when running the tests from the build system but it is a pain to have to set it when running them manually.

Best Wishes

Phillip

Quoted 26 lines
---
  t/test-lib.sh | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
t/test-lib.sh +2 -1
index e36a21ddf7..6f862621af 100644
@@ -35,7 +35,7 @@ else
  	# needing to exist.
  	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
  fi
-GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
+GIT_BUILD_DIR="${GIT_BUILD_DIR:-${TEST_DIRECTORY%/t}}"
  if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
  then
  	echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2
@@ -514,6 +514,7 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
  		PERF_
  		CURL_VERBOSE
  		TRACE_CURL
+		BUILD_DIR
  	));
  	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
  	print join("\n", @vars);
#39 lore raw

Re: [RFC PATCH 20/21] t: allow overriding build dir

Quoted 7 lines · Phillip Wood

Hi Patrick

Quoted 4 lines · Patrick Steinhardt

Our "test-lib.sh" assumes that our build directory is the parent directory of "t/". While true when using our Makefile, it's not when using build systems that support out-of-tree builds.

Quoted 7 lines
Quoted 2 lines

Allow such build systems to override the location of the build directory with an environment variable.

ee9e66e4e76 (cmake: avoid editing t/test-lib.sh, 2022-10-18) added support for reading the "real" build directory from "$GIT_BUILD_DIR/GIT-BUILD-DIR". Using an environment variable is fine when running the tests from the build system but it is a pain to have to set it when running them manually.

That doesn't quite solve the problem though, because "$GIT_BUILD_DIR" points to the _source_ directory as noted in the mentioned commit. So the resulting build is still not fully self-contained. So I don't currently see another way than to introduce a separate environment variable.

Patrick

#40 lore raw

RFC PATCH 21/21 Introduce support for the Meson build system

In reply to Patrick Steinhardt

Introduce support for the Meson build system, a "modern" meta build system that supports many different plaforms, including Linux, macOS, Windows and BSDs. Meson supports different backends, including Ninja, Xcode and Microsoft Visual Studio. Several common IDEs provide an integration with it.

The biggest contender compared to Meson is probably CMake as outlined in our "Documentation/technical/build-systems.txt" file. Based on my own personal experience from working with both build systems extensively I strongly favor Meson over CMake. In my opinion, it feels significantly easier to use with a syntax that feels more like a "real" programming language. The second big reason is that Meson supports Rust natively, which may prove to be important given that the project is likely to pick up Rust as another language eventually.

Using Meson is rather straight-forward. An example:

    ```
    # Meson uses out-of-tree builds. You can set up multiple build
    # directories, how you name them is completely up to you.
    $ mkdir build
    $ cd build
    $ meson setup .. -Dprefix=/tmp/git-installation

    # Build the project. This also provides several other targets like
    e.g. `install` or `test`.
    $ ninja

    # Meson has been wired up to support execution of our test suites.
    # Both our unit tests and our integration tests are supported.
    # Running `meson test` without any arguments will execute all tests,
    # but the syntax supports globbing to select only some tests.
    $ meson test 't-*'
    # Execute single test interactively to allow fordebugging.
    $ meson test 't0000-*' --interactive --test-args=-ix
    ```

The build instructions have been successfully tested on the following systems. Tests are mostly passing:

- Apple macOS 10.15.
- FreeBSD 14.1, except gitweb-based tests.
- NixOS 24.11.
- Ubuntu 24.04.
- Windows 10 with Cygwin, using -Dperl=disabled -Dpython=disabled,

    except for t0052, t0301, t5500, t5572, t5601.
  - Windows 10 with MinGW64, using `-Dperl=disabled -Dpython=disabled`,
    except for t7300.

It is expected that there will still be rough edges in the current version. If this patch lands the expectation is that it will coexist with our other build systems for a while. Like this, distributions can slowly migrate over to Meson and report any findings they have to us such that we can continue to iterate. A potential cutoff date for other build systems may be Git 3.0.

Some notes:

- The installed distribution is structured somewhat differently than how it used to be the case. All of our binaries are installed into $libexec/git-core, while all binaries part of $bindir are now symbolic links pointing to the former. This rule is consistent in itself and thus easier to reason about.

- We do not install dashed binaries into $libexec/git-core anymore. So there won't e.g. be a symlink for git-add(1). These are not required by modern Git and there isn't really much of a usecase for those anymore. By not installing those symlinks we thus start the deprecation of this layout.

- Support for installing documentation has not been wired up yet. This will follow if the project can agree on Meson as build system.

- Support for Microsoft Visual Studio has not yet been tested, mostly because I have been fighting with the Windows-based systems for a long while already. This will follow if the project can agree on Meson as build system

- Documentation does not yet exist. Same here, it will follow if the project can agree on Meson.

- We're targeting a relatively-recent Meson 1.3.0, which has been released November 2023. The only feature we use from that version is fs.relative_to(), which we could replace if necessary. If so, we could start to target Meson 1.0.0 and newer, released in December 2022.

- The whole build instructions count around 3000 lines, half of which is listing all of our code and test files. Our Makefiles are around 5000 lines of, autoconf adds another 1300 lines. CMake in comparison has only 1200 lines of code, but it avoids listing individual files and does not wire up auto-configuration as extensively as the Meson files do.

- I didn't yet port the workaround for the gettext package in Homebrew being key-only over. Users have to manually add CFLAGS and LDFLAGS for that library to work around this issue with Homebrew.

---
 bin-wrappers/meson.build           |   28 +
 contrib/completion/meson.build     |    8 +
 contrib/meson.build                |    1 +
 gitweb/meson.build                 |   32 +
 gitweb/static/meson.build          |   28 +
 meson.build                        | 1567 ++++++++++++++++++++++++++++
 meson_options.txt                  |   67 ++
 perl/FromCPAN/Mail/meson.build     |    7 +
 perl/FromCPAN/meson.build          |    9 +
 perl/Git/LoadCPAN/Mail/meson.build |    7 +
 perl/Git/LoadCPAN/meson.build      |    9 +
 perl/Git/SVN/Memoize/meson.build   |    7 +
 perl/Git/SVN/meson.build           |   20 +
 perl/Git/meson.build               |   18 +
 perl/meson.build                   |   18 +
 po/meson.build                     |   28 +
 t/helper/meson.build               |   91 ++
 t/meson.build                      | 1107 ++++++++++++++++++++
 templates/hooks/meson.build        |   24 +
 templates/info/meson.build         |    5 +
 templates/meson.build              |    8 +
 21 files changed, 3089 insertions(+)
 create mode 100644 bin-wrappers/meson.build
 create mode 100644 contrib/completion/meson.build
 create mode 100644 contrib/meson.build
 create mode 100644 gitweb/meson.build
 create mode 100644 gitweb/static/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 perl/FromCPAN/Mail/meson.build
 create mode 100644 perl/FromCPAN/meson.build
 create mode 100644 perl/Git/LoadCPAN/Mail/meson.build
 create mode 100644 perl/Git/LoadCPAN/meson.build
 create mode 100644 perl/Git/SVN/Memoize/meson.build
 create mode 100644 perl/Git/SVN/meson.build
 create mode 100644 perl/Git/meson.build
 create mode 100644 perl/meson.build
 create mode 100644 po/meson.build
 create mode 100644 t/helper/meson.build
 create mode 100644 t/meson.build
 create mode 100644 templates/hooks/meson.build
 create mode 100644 templates/info/meson.build
 create mode 100644 templates/meson.build
bin-wrappers/meson.build new file +28 -0
new file mode 100644
index 0000000000..6d03a19d7b
@@ -0,0 +1,28 @@
+bin_wrappers_config = configuration_data()
+foreach key, value : {
+      'BUILD_DIR': meson.project_build_root(),
+      'MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
+      'TEMPLATE_DIR': meson.project_build_root() / 'templates',
+      'GIT_TEXTDOMAINDIR': meson.project_build_root() / 'po',
+      'GITPERLLIB': meson.project_build_root() / 'perl/lib',
+}
+  # Paths need to be Unix-style without drive prefixes as they get added to the
+  # PATH variable. And given that drive prefixes contain a colon we'd otherwise
+  # end up with a broken PATH if we didn't convert them.
+  if cygpath.found()
+    value = run_command(cygpath, value, check: true).stdout().strip()
+  endif
+  bin_wrappers_config.set(key, value)
+endforeach
+
+foreach executable : bin_wrappers
+  executable_config = configuration_data()
+  executable_config.merge_from(bin_wrappers_config)
+  executable_config.set('PROG', fs.relative_to(executable.full_path(), meson.project_build_root()))
+
+  configure_file(
+    input: 'wrap-for-bin.sh',
+    output: fs.stem(executable.full_path()),
+    configuration: executable_config,
+  )
+endforeach
contrib/completion/meson.build new file +8 -0
new file mode 100644
index 0000000000..a9bfe2da31
@@ -0,0 +1,8 @@
+foreach script : [
+  'git-completion.bash',
+  'git-completion.tcsh',
+  'git-completion.zsh',
+  'git-prompt.sh'
+]
+  test_dependencies += fs.copyfile(script)
+endforeach
contrib/meson.build new file +1 -0
new file mode 100644
index 0000000000..a7b77b87c2
@@ -0,0 +1 @@
+subdir('completion')
gitweb/meson.build new file +32 -0
new file mode 100644
index 0000000000..f9c3a76647
@@ -0,0 +1,32 @@
+configure_file(
+  input: 'gitweb.perl',
+  output: 'gitweb.cgi',
+  configuration: {
+    'GIT_VERSION': meson.project_version(),
+    'GIT_BINDIR': get_option('prefix') / get_option('bindir'),
+    'GITWEB_CONFIG': get_option('gitweb_config'),
+    'GITWEB_CONFIG_SYSTEM': get_option('gitweb_config_system'),
+    'GITWEB_CONFIG_COMMON': get_option('gitweb_config_common'),
+    'GITWEB_HOME_LINK_STR': get_option('gitweb_home_link_str'),
+    'GITWEB_SITENAME': get_option('gitweb_sitename'),
+    'GITWEB_PROJECTROOT': get_option('gitweb_projectroot'),
+    'GITWEB_PROJECT_MAXDEPTH': get_option('gitweb_project_maxdepth'),
+    'GITWEB_EXPORT_OK': get_option('gitweb_export_ok'),
+    'GITWEB_STRICT_EXPORT': get_option('gitweb_strict_export'),
+    'GITWEB_BASE_URL': get_option('gitweb_base_url'),
+    'GITWEB_LIST': get_option('gitweb_list'),
+    'GITWEB_HOMETEXT': get_option('gitweb_hometext'),
+    'GITWEB_CSS': get_option('gitweb_css'),
+    'GITWEB_LOGO': get_option('gitweb_logo'),
+    'GITWEB_FAVICON': get_option('gitweb_favicon'),
+    'GITWEB_JS': get_option('gitweb_js'),
+    'GITWEB_SITE_HTML_HEAD_STRING': get_option('gitweb_site_html_head_string'),
+    'GITWEB_SITE_HEADER': get_option('gitweb_site_header'),
+    'GITWEB_SITE_FOOTER': get_option('gitweb_site_footer'),
+    'HIGHLIGHT_BIN': get_option('highlight_bin'),
+  },
+  install: true,
+  install_dir: get_option('datadir') / 'gitweb',
+)
+
+subdir('static')
gitweb/static/meson.build new file +28 -0
new file mode 100644
index 0000000000..1bdbe70d2d
@@ -0,0 +1,28 @@
+foreach asset : [
+  'git-favicon.png',
+  'git-logo.png',
+  'gitweb.css',
+]
+  fs.copyfile(asset,
+    install: true,
+    install_dir: get_option('datadir') / 'gitweb/static',
+  )
+endforeach
+
+javascript_sources = [
+  meson.current_source_dir() / 'js/adjust-timezone.js',
+  meson.current_source_dir() / 'js/blame_incremental.js',
+  meson.current_source_dir() / 'js/javascript-detection.js',
+  meson.current_source_dir() / 'js/lib/common-lib.js',
+  meson.current_source_dir() / 'js/lib/cookies.js',
+  meson.current_source_dir() / 'js/lib/datetime.js',
+]
+
+custom_target(
+  input: javascript_sources,
+  output: 'gitweb.js',
+  capture: true,
+  command: ['cat'] + javascript_sources,
+  install: true,
+  install_dir: get_option('datadir') / 'gitweb/static',
+)
meson.build new file +1567 -0

1,567 lines not on this page · raw message

meson_options.txt new file +67 -0

67 lines not on this page · raw message

perl/FromCPAN/Mail/meson.build new file +7 -0
new file mode 100644
index 0000000000..8cbd90ce18
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'Address.pm',
+  output: 'Address.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail',
+)
perl/FromCPAN/meson.build new file +9 -0
new file mode 100644
index 0000000000..ff88b35c2c
@@ -0,0 +1,9 @@
+configure_file(
+  input: 'Error.pm',
+  output: 'Error.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/FromCPAN',
+)
+
+subdir('Mail')
perl/Git/LoadCPAN/Mail/meson.build new file +7 -0
new file mode 100644
index 0000000000..fbf324307b
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'Address.pm',
+  output: 'Address.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail',
+)
perl/Git/LoadCPAN/meson.build new file +9 -0
new file mode 100644
index 0000000000..542e108225
@@ -0,0 +1,9 @@
+configure_file(
+  input: 'Error.pm',
+  output: 'Error.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN',
+)
+
+subdir('Mail')
perl/Git/SVN/Memoize/meson.build new file +7 -0
new file mode 100644
index 0000000000..727375c833
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'YAML.pm',
+  output: 'YAML.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/SVN',
+)
perl/Git/SVN/meson.build new file +20 -0
new file mode 100644
index 0000000000..eccc3f2263
@@ -0,0 +1,20 @@
+foreach source : [
+  'Editor.pm',
+  'Fetcher.pm',
+  'GlobSpec.pm',
+  'Log.pm',
+  'Migration.pm',
+  'Prompt.pm',
+  'Ra.pm',
+  'Utils.pm',
+]
+  configure_file(
+    input: source,
+    output: source,
+    configuration: perl_config,
+    install: true,
+    install_dir: get_option('datadir') / 'perl5/Git/SVN',
+  )
+endforeach
+
+subdir('Memoize')
perl/Git/meson.build new file +18 -0
new file mode 100644
index 0000000000..97bd62290d
@@ -0,0 +1,18 @@
+foreach source : [
+  'I18N.pm',
+  'IndexInfo.pm',
+  'LoadCPAN.pm',
+  'Packet.pm',
+  'SVN.pm',
+]
+  configure_file(
+    input: source,
+    output: source,
+    configuration: perl_config,
+    install: true,
+    install_dir: get_option('datadir') / 'perl5/Git',
+  )
+endforeach
+
+subdir('LoadCPAN')
+subdir('SVN')
perl/meson.build new file +18 -0
new file mode 100644
index 0000000000..0a7bf41d5b
@@ -0,0 +1,18 @@
+perl_config = {
+  'LOCALEDIR': get_option('prefix') / get_option('datadir') / 'locale',
+  'NO_GETTEXT': iconv.found() ? '' : '1',
+  'NO_PERL_CPAN_FALLBACKS': get_option('perl_cpan_fallback') ? '' : '1',
+}
+
+configure_file(
+  input: 'Git.pm',
+  output: 'Git.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5',
+)
+
+subdir('Git')
+if get_option('perl_cpan_fallback')
+  subdir('FromCPAN')
+endif
po/meson.build new file +28 -0
new file mode 100644
index 0000000000..fb1b92eb0a
@@ -0,0 +1,28 @@
+i18n = import('i18n')
+
+translations = i18n.gettext('git',
+  languages: [
+    'bg',
+    'ca',
+    'de',
+    'el',
+    'es',
+    'fr',
+    'id',
+    'is',
+    'it',
+    'ko',
+    'pl',
+    'pt_PT',
+    'ru',
+    'sv',
+    'tr',
+    'uk',
+    'vi',
+    'zh_CN',
+    'zh_TW',
+  ],
+  install: true,
+  install_dir: get_option('datadir'),
+)
+test_dependencies += translations[0]
t/helper/meson.build new file +91 -0

91 lines not on this page · raw message

t/meson.build new file +1107 -0

1,055 lines not on this page · raw message

templates/hooks/meson.build new file +24 -0
new file mode 100644
index 0000000000..9bef5d7cfa

Lines of this file are not shown. View the raw message.

templates/info/meson.build new file +5 -0
new file mode 100644
index 0000000000..4ee1cfdf89

Lines of this file are not shown. View the raw message.

templates/meson.build new file +8 -0
new file mode 100644
index 0000000000..7428aaf1e6

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.0.rc0.dirty

Part of the diff is not shown here. View the raw message.

#41 lore raw
In reply to Patrick Steinhardt

Hi Patrick

Quoted 5 lines · Patrick Steinhardt

- Patches 2 to 9 fix various different bugs I have found while working on many different platforms. They can likely go into the tree separately, and I'm happy to split these out into a separate patch series if we want to.

These all look like useful improvements in their own right, splitting them out would make sense to me.

Quoted 8 lines

- Patches 10 to 20 refactor parts of our preexisting build systems and testing infrastructure to provide better support for out-of-tree builds. While we already have CMake build instructions in our tree, they do not currently have "proper" out-of-tree builds as they still end up writing data into the source directory. So while these patches are written with Meson in mind, they should also help CMake. As a result of these patches, Meson builds and test runs are fully self-contained.

Patches 14-16 and 18 look useful in their own right even if we don't adopt Meson. The others all look sensible in the context of supporting multiple build systems and might be worth doing anyway especially if they simplify the existing CMakeLists.txt.

I've skipped patches 1 and 21 for now, I'll have a look at those later in the week.

Best Wishes

Phillip

#42 lore raw
Quoted 11 lines · Phillip Wood

Hi Patrick

Quoted 5 lines · Patrick Steinhardt

- Patches 2 to 9 fix various different bugs I have found while working on many different platforms. They can likely go into the tree separately, and I'm happy to split these out into a separate patch series if we want to.

These all look like useful improvements in their own right, splitting them out would make sense to me.

For now I'll reorder them such that they are all up front. Like that it should be easy enough to just merge the first X commits while keeping the overall series together. The reviewers don't have to go through all commits.

If that's creating problems though I'll split this out into a standalone series.

Quoted 9 lines
Quoted 8 lines

- Patches 10 to 20 refactor parts of our preexisting build systems and testing infrastructure to provide better support for out-of-tree builds. While we already have CMake build instructions in our tree, they do not currently have "proper" out-of-tree builds as they still end up writing data into the source directory. So while these patches are written with Meson in mind, they should also help CMake. As a result of these patches, Meson builds and test runs are fully self-contained.

Quoted 7 lines

Patches 14-16 and 18 look useful in their own right even if we don't adopt Meson. The others all look sensible in the context of supporting multiple build systems and might be worth doing anyway especially if they simplify the existing CMakeLists.txt.

I've skipped patches 1 and 21 for now, I'll have a look at those later in the week.

I'll also send an updated version soonish that includes support for MSVC, likely tomorrow. So you may want to hold off reviewing them for now.

Thanks for your review!

Patrick

#43 lore raw

v2 cover Modernize our build system

In reply to Patrick Steinhardt

Hi,

this is the second version of the patch series that modernizes our build system by introducing Meson. This series is still in an RFC state.

Changes compared to v1:

- I've reordered patches such that the platform-specific patches all come up front. This allows us to merge them independently of the rest of this series.

- I've included a couple more fixes to platform-specific issues.

- I've introduced an ICONV prerequisite. Executing tests is currently broken when compiling with NO_ICONV=Yes, and this prerequisite fixes that.

- I've upstreamed the standalone patch to the clar framework I had in v1 for how we typedef struct stat, and adapted the commit that updates clar to update to the newer version that includes the patch.

- I've fixed an issue in "generate-clar-decls.h" when the build path contains spaces. I found this by accident when I had a spaces in my source directory on Windows.

- I've rebased on top of Git v2.47.

- I've clarified some commit messages.

- I've updated "build-systems.txt" based on the feedback I got.

- I've made Meson work with the Microsoft Visual Studio compiler.

- I've included subproject wrappers. These are small files that tell Meson for how to build a dependency as a fallback in case the host system does not have the dependency. This allows a developer to build Git without any system-provided dependencies and is quite helpful especially on Windows.

- Various other small fixes and improvements to Meson.

Overall I've got this to a state where things are mostly working. I've successfully built and tested stuff on Linux, macOS 10.15, Windows 10 with MSVC, MinGW and Cygwin as well as FreeBSD.

The series is structured as following:

- Patches 1 to 11 provide various fixes to preexisting issues on several platforms. These fixes can be merged independently of the rest of this series -- so even if you don't care for the remainder of it, I'd be happy if those were reviewed.

@Junio: Let me know whether this is good enough for you, or whether I should split those patches out into a separate series.

- Patches 12 to 22 refactor parts of our build system to make proper out-of-tree builds a reality.

- Patch 23 introdudces the "build-systems.txt" file.

- Patch 24 introduces the Meson build system.

Thanks!

Patrick

Patrick Steinhardt (24):
t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE t/test-lib: wire up NO_ICONV prerequisite
t/lib-gitweb: test against the build version of gitweb t/lib-gpg: fix setup of GNUPGHOME in MinGW
t1401: make invocation of tar(1) work with Win32-provided one
t3404: work around platform-specific behaviour on macOS 10.15 t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
t7300: work around platform-specific behaviour with long paths on
MinGW
t/unit-tests: update clar unit test framework builtin/credential-cache: fix missing parameter for stub function
http: fix build error on FreeBSD
Makefile: extract script to generate clar declarations
Makefile: extract script to massage Perl scripts
Makefile: refactor GIT-VERSION-GEN to be reusable
Makefile: refactor generators to be PWD-independent
Makefile: use common template for GIT-BUILD-OPTIONS
Makefile: consistently use @PLACEHOLDER@ to substitute
Makefile: consistently use PERL_PATH
Makefile: allow "bin-wrappers/" directory to exist
Makefile: simplify building of templates
t: better support for out-of-tree builds
t: allow overriding build dir
Documentation: add comparison of build systems
Introduce support for the Meson build system

 .gitignore                                    |    1 -
 Documentation/CodingGuidelines                |    2 +-
 Documentation/Makefile                        |    1 +
 Documentation/technical/build-systems.txt     |  224 +++
 GIT-BUILD-OPTIONS.in                          |   41 +
 GIT-VERSION-GEN                               |   12 +-
 Makefile                                      |  187 +-
 bin-wrappers/.gitignore                       |    9 +
 bin-wrappers/meson.build                      |   28 +
 bin-wrappers/wrap-for-bin.sh                  |   37 +
 builtin/credential-cache.c                    |    3 +-
 configure.ac                                  |    2 +-
 contrib/buildsystems/CMakeLists.txt           |  135 +-
 contrib/completion/meson.build                |    8 +
 contrib/meson.build                           |    1 +
 generate-cmdlist.sh                           |   42 +-
 generate-configlist.sh                        |   20 +-
 generate-hooklist.sh                          |   15 +-
 generate-perl.sh                              |   22 +
 git-cvsserver.perl                            |    2 +-
 git-instaweb.sh                               |    8 +-
 git-request-pull.sh                           |    2 +-
 git-send-email.perl                           |    2 +-
 git-sh-i18n.sh                                |    6 +-
 git-sh-setup.sh                               |    6 +-
 git-svn.perl                                  |    2 +-
 gitk-git/po/vi.po                             |    2 +-
 gitweb/Makefile                               |   44 +-
 gitweb/gitweb.perl                            |   44 +-
 gitweb/meson.build                            |   32 +
 gitweb/static/meson.build                     |   28 +
 http.c                                        |   10 +-
 meson.build                                   | 1607 +++++++++++++++++
 meson_options.txt                             |   70 +
 perl/FromCPAN/Mail/meson.build                |    7 +
 perl/FromCPAN/meson.build                     |    9 +
 perl/Git/I18N.pm                              |    6 +-
 perl/Git/LoadCPAN.pm                          |    6 +-
 perl/Git/LoadCPAN/Mail/meson.build            |    7 +
 perl/Git/LoadCPAN/meson.build                 |    9 +
 perl/Git/SVN/Memoize/meson.build              |    7 +
 perl/Git/SVN/meson.build                      |   20 +
 perl/Git/meson.build                          |   18 +
 .../header_templates/fixed_prefix.template.pl |    2 +-
 .../runtime_prefix.template.pl                |    8 +-
 perl/meson.build                              |   18 +
 po/meson.build                                |   28 +
 subprojects/curl.wrap                         |   13 +
 subprojects/expat.wrap                        |   13 +
 subprojects/openssl.wrap                      |   15 +
 subprojects/pcre2.wrap                        |   16 +
 subprojects/zlib.wrap                         |   13 +
 t/helper/meson.build                          |   91 +
 t/lib-gettext.sh                              |    4 +-
 t/lib-gitweb.sh                               |    2 +-
 t/lib-gpg.sh                                  |    2 +-
 t/meson.build                                 | 1105 ++++++++++++
 t/t0028-working-tree-encoding.sh              |    6 +
 t/t1401-symbolic-ref.sh                       |    2 +-
 t/t2082-parallel-checkout-attributes.sh       |    2 +-
 t/t3404-rebase-interactive.sh                 |   26 +-
 t/t3434-rebase-i18n.sh                        |    6 +
 t/t3900-i18n-commit.sh                        |    6 +
 t/t3901-i18n-patch.sh                         |    6 +
 t/t4041-diff-submodule-option.sh              |   16 +-
 t/t4059-diff-submodule-not-initialized.sh     |   16 +-
 t/t4060-diff-submodule-option-diff-format.sh  |   17 +-
 t/t4201-shortlog.sh                           |    8 +-
 t/t4205-log-pretty-formats.sh                 |  102 +-
 t/t4210-log-i18n.sh                           |    6 +
 t/t4254-am-corrupt.sh                         |    6 +
 t/t5100-mailinfo.sh                           |   14 +-
 t/t5500-fetch-pack.sh                         |   14 +-
 t/t5550-http-fetch-dumb.sh                    |    4 +-
 t/t5601-clone.sh                              |   11 +-
 t/t6006-rev-list-format.sh                    |   54 +-
 t/t7102-reset.sh                              |   40 +-
 t/t7300-clean.sh                              |    2 +-
 t/t7609-mergetool--lib.sh                     |    2 +-
 t/t8005-blame-i18n.sh                         |    6 +
 t/t9300-fast-import.sh                        |    2 +-
 t/t9350-fast-export.sh                        |   10 +-
 t/test-lib.sh                                 |   25 +-
 t/unit-tests/clar/.editorconfig               |   13 +
 t/unit-tests/clar/.github/workflows/ci.yml    |   20 +-
 t/unit-tests/clar/.gitignore                  |    1 +
 t/unit-tests/clar/CMakeLists.txt              |   28 +
 t/unit-tests/clar/clar.c                      |  111 +-
 t/unit-tests/clar/clar/print.h                |   11 +-
 t/unit-tests/clar/clar/sandbox.h              |   17 +-
 t/unit-tests/clar/clar/summary.h              |   14 +-
 t/unit-tests/clar/test/.gitignore             |    4 -
 t/unit-tests/clar/test/CMakeLists.txt         |   41 +
 t/unit-tests/clar/test/Makefile               |   39 -
 t/unit-tests/generate-clar-decls.sh           |   18 +
 templates/Makefile                            |   38 +-
 templates/branches--                          |    1 -
 templates/{this--description => description}  |    0
 .../applypatch-msg.sample}                    |    0
 .../commit-msg.sample}                        |    0
 .../fsmonitor-watchman.sample}                |    0
 templates/hooks/meson.build                   |   24 +
 .../post-update.sample}                       |    0
 .../pre-applypatch.sample}                    |    0
 .../pre-commit.sample}                        |    0
 .../pre-merge-commit.sample}                  |    0
 .../pre-push.sample}                          |    0
 .../pre-rebase.sample}                        |    0
 .../pre-receive.sample}                       |    0
 .../prepare-commit-msg.sample}                |    0
 .../push-to-checkout.sample}                  |    0
 .../sendemail-validate.sample}                |    0
 .../update.sample}                            |    0
 templates/{info--exclude => info/exclude}     |    0
 templates/info/meson.build                    |    5 +
 templates/meson.build                         |    8 +
 unimplemented.sh                              |    2 +-
 wrap-for-bin.sh                               |   36 -
 118 files changed, 4319 insertions(+), 595 deletions(-)
 create mode 100644 Documentation/technical/build-systems.txt
 create mode 100644 GIT-BUILD-OPTIONS.in
 create mode 100644 bin-wrappers/.gitignore
 create mode 100644 bin-wrappers/meson.build
 create mode 100755 bin-wrappers/wrap-for-bin.sh
 create mode 100644 contrib/completion/meson.build
 create mode 100644 contrib/meson.build
 create mode 100755 generate-perl.sh
 create mode 100644 gitweb/meson.build
 create mode 100644 gitweb/static/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 perl/FromCPAN/Mail/meson.build
 create mode 100644 perl/FromCPAN/meson.build
 create mode 100644 perl/Git/LoadCPAN/Mail/meson.build
 create mode 100644 perl/Git/LoadCPAN/meson.build
 create mode 100644 perl/Git/SVN/Memoize/meson.build
 create mode 100644 perl/Git/SVN/meson.build
 create mode 100644 perl/Git/meson.build
 create mode 100644 perl/meson.build
 create mode 100644 po/meson.build
 create mode 100644 subprojects/curl.wrap
 create mode 100644 subprojects/expat.wrap
 create mode 100644 subprojects/openssl.wrap
 create mode 100644 subprojects/pcre2.wrap
 create mode 100644 subprojects/zlib.wrap
 create mode 100644 t/helper/meson.build
 create mode 100644 t/meson.build
 create mode 100644 t/unit-tests/clar/.editorconfig
 create mode 100644 t/unit-tests/clar/.gitignore
 create mode 100644 t/unit-tests/clar/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/Makefile
 create mode 100755 t/unit-tests/generate-clar-decls.sh
 delete mode 100644 templates/branches--
 rename templates/{this--description => description} (100%)
 rename templates/{hooks--applypatch-msg.sample => hooks/applypatch-msg.sample} (100%)
 rename templates/{hooks--commit-msg.sample => hooks/commit-msg.sample} (100%)
 rename templates/{hooks--fsmonitor-watchman.sample => hooks/fsmonitor-watchman.sample} (100%)
 create mode 100644 templates/hooks/meson.build
 rename templates/{hooks--post-update.sample => hooks/post-update.sample} (100%)
 rename templates/{hooks--pre-applypatch.sample => hooks/pre-applypatch.sample} (100%)
 rename templates/{hooks--pre-commit.sample => hooks/pre-commit.sample} (100%)
 rename templates/{hooks--pre-merge-commit.sample => hooks/pre-merge-commit.sample} (100%)
 rename templates/{hooks--pre-push.sample => hooks/pre-push.sample} (100%)
 rename templates/{hooks--pre-rebase.sample => hooks/pre-rebase.sample} (100%)
 rename templates/{hooks--pre-receive.sample => hooks/pre-receive.sample} (100%)
 rename templates/{hooks--prepare-commit-msg.sample => hooks/prepare-commit-msg.sample} (100%)
 rename templates/{hooks--push-to-checkout.sample => hooks/push-to-checkout.sample} (100%)
 rename templates/{hooks--sendemail-validate.sample => hooks/sendemail-validate.sample} (100%)
 rename templates/{hooks--update.sample => hooks/update.sample} (100%)
 rename templates/{info--exclude => info/exclude} (100%)
 create mode 100644 templates/info/meson.build
 create mode 100644 templates/meson.build
 delete mode 100644 wrap-for-bin.sh

Range-diff against v1:

 2:  559b593b598 =  1:  6dd59db9b2b t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE
 -:  ----------- >  2:  5ec91ac12da t/test-lib: wire up NO_ICONV prerequisite
 3:  be8ba4b9679 =  3:  94664e2cc06 t/lib-gitweb: test against the build version of gitweb
 4:  b5c116396da !  4:  ffb661dad71 t/lib-gpg: fix setup of GNUPGHOME in MinGW

@@ Commit message
t/lib-gpg: fix setup of GNUPGHOME in MinGW

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to
- point to a test-specific diretcory. This is done by using "$PWD/gpghome"
+ point to a test-specific directory. This is done by using "$PWD/gpghome"
as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style paths that contain drive letters. What we really want in this context is
- a Unix-style path, which we can get by using $(pwd) instead.
+ a Unix-style path, which we can get by using $(pwd) instead. It is
+ somewhat puzzling that nobody ever hit this issue, but it may easily be
+ that nobody ever tests on Windows with GnuPG installed, which would make
+ us skip those tests.

Adapt the code accordingly to fix tests using this library.

 -:  ----------- >  5:  958cf3a6b57 t1401: make invocation of tar(1) work with Win32-provided one
 -:  ----------- >  6:  bada3a82fdd t3404: work around platform-specific behaviour on macOS 10.15
 -:  ----------- >  7:  b4bdefe9e34 t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
 -:  ----------- >  8:  48ce19d876f t7300: work around platform-specific behaviour with long paths on MinGW
 6:  a0eff395839 !  9:  73b4362164a t/unit-tests: update clar unit test framework

@@ Metadata
## Commit message ##
t/unit-tests: update clar unit test framework

- Update clar unit test framework to 67e689a (Merge pull request #103 from
- pks-t/pks-editorconfig, 2024-09-20).
+ Update clar unit test framework to f065214 (Merge pull request #105 from
+ pks-t/pks-win32-stat-compat, 2024-10-03), which fixes some platform
+ compatibility issues with Windows.

@@ t/unit-tests/clar/clar.c
/* required for sandboxing */
#include <sys/types.h>
@@
+
+ # ifndef stat
+ # define stat(path, st) _stat(path, st)
++ typedef struct _stat STAT_T;
++# else
++ typedef struct stat STAT_T;
+ # endif
+ # ifndef mkdir
+ # define mkdir(path, mode) _mkdir(path)
+@@
+ # else
# define p_snprintf snprintf
# endif
-
+-
-# ifndef PRIuZ
-# define PRIuZ "Iu"
-# endif
@@ t/unit-tests/clar/clar.c
-# define PRIxZ "Ix"
-# endif
-
- # if defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
- typedef struct stat STAT_T;
- # else
-@@
+-# if defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
+- typedef struct stat STAT_T;
+-# else
+- typedef struct _stat STAT_T;
+-# endif
+ #else
+ # include <sys/wait.h> /* waitpid(2) */
# include <unistd.h>
# define _MAIN_CC
# define p_snprintf snprintf

 8:  7a36ad58384 = 10:  161f6b063af builtin/credential-cache: fix missing parameter for stub function
 9:  1c1cd4d8ef9 = 11:  e4ef4bdf1c5 http: fix build error on FreeBSD
10:  b05a551b1c2 ! 12:  6ea97bc92f2 Makefile: extract script to generate clar declarations
    @@ t/unit-tests/generate-clar-decls.sh (new)
     @@
     +#!/bin/sh
     +
    -+if test $# -lt 3
    ++if test $# -lt 2
     +then
     +	echo "USAGE: $0 <OUTPUT> <SUITE>..." 2>&1
     +	exit 1
    @@ t/unit-tests/generate-clar-decls.sh (new)
     +OUTPUT="$1"
     +shift
     +
    -+for suite in $*
    ++while test "$#" -ne 0
     +do
    ++	suite="$1"
    ++	shift
     +	sed -ne "s/^\(void test_$suite__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$\)/extern \1;/p" "$suite" ||
     +	exit 1
     +done >"$OUTPUT"
11:  ccfa97bd3db = 13:  7f567d7ce23 Makefile: extract script to massage Perl scripts
12:  ada39ec21dd ! 14:  dfc941cd18d Makefile: refactor GIT-VERSION-GEN to be reusable

@@ GIT-VERSION-GEN
#!/bin/sh

-GVF=GIT-VERSION-FILE
- DEF_VER=v2.47.0-rc0
+ DEF_VER=v2.47.0

LF='
@@ GIT-VERSION-GEN: fi

13:  7136aeaa138 = 15:  e468d3751f0 Makefile: refactor generators to be PWD-independent
14:  a5a43ed685e ! 16:  dbf9e39e3df Makefile: use common template for GIT-BUILD-OPTIONS
    @@ GIT-BUILD-OPTIONS.in (new)
     +PYTHON_PATH=@PYTHON_PATH@
     +TAR=@TAR@
     +NO_CURL=@NO_CURL@
    ++NO_ICONV=@NO_ICONV@
     +NO_EXPAT=@NO_EXPAT@
     +USE_LIBPCRE2=@USE_LIBPCRE2@
     +NO_PERL=@NO_PERL@
    @@ Makefile: GIT-LDFLAGS: FORCE
     -	@echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@+
     -	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
     -	@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
    +-	@echo NO_ICONV=\''$(subst ','\'',$(subst ','\'',$(NO_ICONV)))'\' >>$@+
     -	@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
     -	@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
     -	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
    @@ Makefile: GIT-LDFLAGS: FORCE
     +		-e "s|@PYTHON_PATH@|\'$(PYTHON_PATH_SQ)\'|" \
     +		-e "s|@TAR@|\'$(TAR)\'|" \
     +		-e "s|@NO_CURL@|\'$(NO_CURL)\'|" \
    ++		-e "s|@NO_ICONV@|\'$(NO_ICONV)\'|" \
     +		-e "s|@NO_EXPAT@|\'$(NO_EXPAT)\'|" \
     +		-e "s|@USE_LIBPCRE2@|\'$(USE_LIBPCRE2)\'|" \
     +		-e "s|@NO_PERL@|\'$(NO_PERL)\'|" \
    @@ contrib/buildsystems/CMakeLists.txt: if(NOT PYTHON_TESTS)
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
    +-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_ICONV='${NO_ICONV}'\n")
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
     -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
    @@ contrib/buildsystems/CMakeLists.txt: if(NOT PYTHON_TESTS)
     +string(REPLACE "@PYTHON_PATH@" "${PYTHON_PATH}" git_build_options "${git_build_options}")
     +string(REPLACE "@TAR@" "${TAR}" git_build_options "${git_build_options}")
     +string(REPLACE "@NO_CURL@" "${NO_CURL}" git_build_options "${git_build_options}")
    ++string(REPLACE "@NO_ICONV@" "${NO_ICONV}" git_build_options "${git_build_options}")
     +string(REPLACE "@NO_EXPAT@" "${NO_EXPAT}" git_build_options "${git_build_options}")
     +string(REPLACE "@USE_LIBPCRE2@" "" git_build_options "${git_build_options}")
     +string(REPLACE "@NO_PERL@" "${NO_PERL}" git_build_options "${git_build_options}")

15: 6aaf3263228 ! 17: 97b9789dd68 Makefile: consistently use @PLACEHOLDER@ to substitute
@@ Commit message
different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Next to being inconsistent it also creates a bit of a problem with
- CMake, which only supports the first syntax. To work around that we
- instead manually replace such strings via string operations, which is
- both a hassle and also removes safeguards that CMake has to verify that
- we didn't forget to replace any placeholders. Besides that, other build
- systems like Meson also support the CMake syntax.
+ CMake, which only supports the first syntax in its configure_file()
+ function. To work around that we instead manually replace placeholders
+ via string operations, which is a hassle and removes safeguards that
+ CMake has to verify that we didn't forget to replace any placeholders.
+ Besides that, other build systems like Meson also support the CMake
+ syntax.

Unify our codebase to consistently use the syntax supported by such build systems.

16:  73417f39a5e = 18:  1ee9c61fc33 Makefile: consistently use PERL_PATH
17:  4b356c0b634 = 19:  9fd1aeb1e96 Makefile: allow "bin-wrappers/" directory to exist
18:  bf55d0c226d = 20:  4eda54cf0f5 Makefile: simplify building of templates
19:  7a0a6b996c3 = 21:  1172c440600 t: better support for out-of-tree builds
20:  c5ae59ce905 ! 22:  b5cd5250b77 t: allow overriding build dir

@@ Commit message
directory of "t/". While true when using our Makefile, it's not when using build systems that support out-of-tree builds.

- Allow such build systems to override the location of the build directory
- with an environment variable.
+ In commit ee9e66e4e7 (cmake: avoid editing t/test-lib.sh, 2022-10-18),
+ we have introduce support for overriding the GIT_BIULD_DIR by creating
+ the file "$GIT_BUILD_DIR/GIT-BUILD-DIR" with its contents pointing to
+ the location of the build directory. The intent was to stop modifying
+ "t/test-lib.sh" with the CMake build systems while allowing out-of-tree
+ builds. But "$GIT_BUILD_DIR" is somewhat misleadingly named, as it in
+ fact points to the _source_ directory. So while that commit solved part
+ of the problem for out-of-tree builds, CMake still has to write files
+ into the source tree.
+
+ Solve the second part of the problem, namely not having to write any
+ data into the source directory at all, by also supporting an environment
+ variable that allows us to point to a different build directory. This
+ allows us to perform properly self-contained out-of-tree builds.

1: 508e3783d28 ! 23: afa2f79d46c Documentation: add comparison of build systems
@@ Documentation/technical/build-systems.txt (new)
+= Build Systems
+
+The build system is the primary way for both developers and system integrators
-+to interact with the Git project. As such, we consider it important to pick a -+build system that fulfills our requirements while being easy to use and extend. ++to interact with the Git project. As such, being easy to use and extend for ++those who are not directly developing Git itself is just as important as other ++requirements we have on any potential build system.
+
+This document outlines the different requirements that we have for the build +system and then compares available build systems using these criteria. +
+== Requirements
+
-+The following subsections prevent a list of requirements that we have for any ++The following subsections present a list of requirements that we have for any
+potential build system. Sections are sorted by decreasing priority, even though +these priorities will naturally differ between users.
+
+=== Platform support
+
-+The most important criterium is whether the build system supports all of the -+platforms that Git supports. The most important platforms include:
++The build system must have support for all of our primary platforms as outlined ++by. These platforms are:
+
+ - Linux
-+ - macOS
+ - Windows
++ - macOS
++
++Furthermore, the build system should have support for the following secondary ++platforms:
++
++ - AIX
+ - FreeBSD
-+ - OpenBSD
+ - NetBSD
++ - OpenBSD
+
+The platforms which must be supported by the tool should be aligned with our +[platform support policy](platform-support.txt).
+
+=== Auto-detection of supported features
+
-+The build system MUST support auto-detection of features which are or aren't ++The build system must support auto-detection of features which are or aren't
+available on the current platform. Platform maintainers should not be required +to manually configure the complete build.
+
@@ Documentation/technical/build-systems.txt (new)
+ - Check for the existence of libraries.
+ - Check for the existence of exectuables.
+ - Check for the runtime behavior of specific functions.
++ - Check for specific link order requirements when multiple libraries are
++ involved.
+
+=== Ease of use
+
-+The build system SHOULD be both easy to use and easy to extend. While this is ++The build system should be both easy to use and easy to extend. While this is
+naturally a subjective metric it is likely not controversial to say that some +build systems are considerably harder to use than others.
+
+=== IDE support
+
-+The build system SHOULD integrate with well-known IDEs. Well-known IDEs include:
++The build system should integrate with well-known IDEs. Well-known IDEs include:
+
+ - Microsoft Visual Studio
+ - Visual Studio Code
@@ Documentation/technical/build-systems.txt (new)
+
+=== Out-of-tree builds
+
-+The build system SHOULD support out-of-tree builds. Out-of-tree builds allow a ++The build system should support out-of-tree builds. Out-of-tree builds allow a
+developer to configure multiple different build directories with different +configuration, e.g. one "debug" build and one "release" build.
+
-+=== Rust support
++=== Cross-platform builds
++
++The build system should support cross-platform builds, e.g. building for arm on ++an x86-64 host.
++
++=== Language support
++
++The following languages and toolchains are of relevance and should be supported ++by the build system:
++
++ - C: the primary compiled language used by Git, must be supported. Relevant
++ toolchains are GCC, Clang and MSVC.
++ - Rust: candidate as a second compiled lanugage, should be supported. Relevant
++ toolchains is the LLVM-based rustc.
++
++Built-in support for the respective languages is preferred over support that ++needs to be wired up manually to avoid unnecessary complexity. Native support ++includes the following features:
++
++ - Compiling objects.
++ - Dependency tracking.
++ - Detection of available features.
++ - Discovery of relevant toolchains.
++ - Linking libraries and executables.
++
++=== Test integration
++
++It should be possible to integrate tests into the build system such that it is ++possible to build and test Git within the build system. Features which are nice ++to have:
+
-+Many long-time Git contributors are nowadays in favor of adopting Rust as a -+second language next to C. The build system SHOULD thus support Rust such that -+we do not have to reopen the discussion once we decide to pick up Rust. ++ - Track build-time dependencies for respective tests. Unit tests have
++ different requirements than integration tests.
++ - Allow filtering of which tests to run.
++ - Allow interactive tests that drop the user into a shell with test_pause or
++ debug.
+
+== Comparison
+
@@ Documentation/technical/build-systems.txt (new)
+ rules can quickly get out of hand once reaching a certain scope. +- IDE support: execution of Makefile targets is supported by many IDEs +- Out-of-tree builds: supported in theory, not wired up in practice.
-+- Rust: can be added.
++- Cross-platform builds: supported in theory, not wired up in practice. ++- Language support:
++ - C: Limited built-in support, many parts need to be wired up manually. ++ - Rust: No built-in support, needs to be wired up manually.
++- Test integration: partially supported, many parts need to be wired up ++ manually.
+
+=== autoconf
+
@@ Documentation/technical/build-systems.txt (new)
+- IDE support: no integration into IDEs at generation time. The generated
+ Makefiles have the same level of support as GNU Make.
+- Out-of-tree builds: supported in theory, not wired up in practice.
-+- Rust: not supported.
++- Cross-platform builds: supported.
++- Language support:
++ - C: Limited built-in support, many parts need to be wired up manually. ++ - Rust: No built-in support, needs to be wired up manually.
++- Test integration: partially supported, many parts need to be wired up ++ manually.
+
+=== CMake
+
@@ Documentation/technical/build-systems.txt (new)
+ project descriptions for Xcode. An extension is available for Visual Studio
+ Code. Many other IDEs have plugins for CMake.
+- Out-of-tree builds: supported.
-+- Rust: not supported.
++- Cross-platform builds: supported.
++- Language support:
++ - C: Supported for GCC, Clang, MSVC and other toolchains.
++ - Rust: No built-in support, needs to be wired up manually.
++- Test integration: supported, even though test dependencies are a bit ++ cumbersome to use via "test fixtures". Interactive test runs are not ++ supported.
+
+=== Meson
+
@@ Documentation/technical/build-systems.txt (new)
+- IDE support: Supports generating build instructions for Xcode and Microsoft
+ Visual Studio, a plugin exists for Visual Studio Code.
+- Out-of-tree builds: supported.
-+- Rust: supported.
++- Cross-platform builds: supported.
++- Language support:
++ - C: Supported for GCC, Clang, MSVC and other toolchains.
++ - Rust: Supported for rustc.
++- Test integration: supported. Interactive tests are supported starting with ++ Meson 1.5.0 via the --interactive flag.

 5:  00fd829833c <  -:  ----------- t3404: work around platform-specific behaviour on macOS 10.15
 7:  f006545eef1 <  -:  ----------- t/clar: simplify how the clar derives `struct stat`
21:  a19af6507c0 ! 24:  724232b0fad Introduce support for the Meson build system

@@ Commit message
```

The build instructions have been successfully tested on the following
- systems. Tests are mostly passing:
+ systems, tests are passing:

- Apple macOS 10.15.
+
- FreeBSD 14.1, except gitweb-based tests.
+
- NixOS 24.11.
+
- Ubuntu 24.04.
- - Windows 10 with Cygwin, using -Dperl=disabled -Dpython=disabled,
- except for t0052, t0301, t5500, t5572, t5601.
- - Windows 10 with MinGW64, using -Dperl=disabled -Dpython=disabled,
- except for t7300.
+
+ - Windows 10 with Cygwin, using -Dperl=disabled -Dpython=disabled.
+
+ - Windows 10 with MinGW64, using -Dperl=disabled -Dpython=disabled.
+
+ - Windows 10 with MSVC 2022, using `-Dperl=disabled -Dpython=disabled
+ -Dgettext=disabled -Diconv=disabled --wrap-mode=forcefallback`.

It is expected that there will still be rough edges in the current version. If this patch lands the expectation is that it will coexist
@@ Commit message
- Support for installing documentation has not been wired up yet. This will follow if the project can agree on Meson as build system.

- - Support for Microsoft Visual Studio has not yet been tested, mostly
- because I have been fighting with the Windows-based systems for a
- long while already. This will follow if the project can agree on
- Meson as build system
-
- Documentation does not yet exist. Same here, it will follow if the project can agree on Meson.

- - We're targeting a relatively-recent Meson 1.3.0, which has been
- released November 2023. The only feature we use from that version is
+ - We're targeting a Meson 1.3.0, which has been released relatively
+ recently November 2023. The only feature we use from that version is
fs.relative_to(), which we could replace if necessary. If so, we could start to target Meson 1.0.0 and newer, released in December 2022.

- The whole build instructions count around 3000 lines, half of which is listing all of our code and test files. Our Makefiles are around
- 5000 lines of, autoconf adds another 1300 lines. CMake in comparison
- has only 1200 lines of code, but it avoids listing individual files
- and does not wire up auto-configuration as extensively as the Meson
- files do.
+ 5000 lines, autoconf adds another 1300 lines. CMake in comparison
+ has only 1200 linescode, but it avoids listing individual files and
+ does not wire up auto-configuration as extensively as the Meson
+ instructions do.

- - I didn't yet port the workaround for the gettext package in
- Homebrew being key-only over. Users have to manually add CFLAGS and
- LDFLAGS for that library to work around this issue with Homebrew.
+ - We bundle a set of subproject wrappers for curl, expat, openssl,
+ pcre2 and zlib. This allows developers to build Git without these
+ dependencies preinstalled, and Meson will fetch and build them
+ automatically. This is especially helpful on Windows.

@@ gitweb/static/meson.build (new)
## meson.build (new) ##
@@
+project('git', 'c',
-+ version: run_command('GIT-VERSION-GEN', check: true).stdout().strip(),
+ meson_version: '>=1.3.0',
++ # MSVC does not support GNU99, and C99 does not define __STDC_VERSION__
++ # on MSVC. So we instead fall back to C11 there.
++ default_options: ['c_std=gnu99,c11'],
++ version: run_command('GIT-VERSION-GEN', check: true).stdout().strip(),
+)
+
+fs = import('fs')
@@ meson.build (new)
+ 'builtin/write-tree.c',
+]
+
++script_environment = environment()
++foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
++ program = find_program(tool)
++ script_environment.prepend('PATH', fs.parent(program.full_path()))
++endforeach
++
+libgit_sources += custom_target(
+ 'command-list.h',
+ input: 'command-list.txt',
+ output: 'command-list.h',
+ command: [shell, meson.current_source_dir() + '/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'],
++ env: script_environment,
+)
+
+libgit_sources += custom_target(
@@ meson.build (new)
+ meson.current_source_dir(),
+ '@OUTPUT@',
+ ],
++ env: script_environment,
+)
+
+libgit_sources += custom_target(
@@ meson.build (new)
+ meson.current_source_dir(),
+ '@OUTPUT@',
+ ],
++ env: script_environment,
+)
+
+# This contains the variables for GIT-BUILD-OPTIONS, which we use to propagate
@@ meson.build (new)
+ build_options_config.set('NO_PERL', '1')
+endif
+
-+zlib = dependency('zlib')
-+libgit_dependencies += zlib
-+if not compiler.has_function('deflateBound',
++zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
++if zlib.type_name() != 'internal' and not compiler.has_function('deflateBound',
+ prefix: '#include <zlib.h>',
+ dependencies: zlib,
+)
+ libgit_c_args += '-DNO_DEFLATE_BOUND'
+endif
++libgit_dependencies += zlib
+
+threads = dependency('threads', required: false)
+if threads.found()
@@ meson.build (new)
+ build_options_config.set('NO_PTHREADS', '1')
+endif
+
-+intl = dependency('intl', required: get_option('gettext'))
++if get_option('gettext').allowed() and host_machine.system() == 'darwin' and get_option('macos_use_homebrew_gettext') ++ if host_machine.cpu_family() == 'x86_64'
++ libintl_prefix = '/usr/local'
++ elif host_machine.cpu_family() == 'aarch64'
++ libintl_prefix = '/opt/homebrew'
++ else
++ error('Homebrew workaround not supported on current architecture')
++ endif
++
++ intl = compiler.find_library('intl', dirs: libintl_prefix / 'lib', required: get_option('gettext'))
++ if intl.found()
++ intl = declare_dependency(
++ dependencies: intl,
++ include_directories: libintl_prefix / 'include',
++ )
++ endif
++else
++ intl = dependency('intl', required: get_option('gettext'))
++endif
+if intl.found()
+ libgit_dependencies += intl
+ build_options_config.set('NO_GETTEXT', '')
@@ meson.build (new)
+iconv = dependency('iconv', required: get_option('iconv'))
+if iconv.found()
+ libgit_dependencies += iconv
++ build_options_config.set('NO_ICONV', '')
+
+ have_old_iconv = false
+ if not compiler.compiles('''
@@ meson.build (new)
+ endif
+else
+ libgit_c_args += '-DNO_ICONV'
++ build_options_config.set('NO_ICONV', '1')
+endif
+
-+pcre2 = dependency('libpcre2-8', required: get_option('pcre2'))
++pcre2 = dependency('libpcre2-8', required: get_option('pcre2'), default_options: ['default_library=static', 'test=false'])
+if pcre2.found()
+ libgit_dependencies += pcre2
+ libgit_c_args += '-DUSE_LIBPCRE2'
@@ meson.build (new)
+ build_options_config.set('USE_LIBPCRE2', '')
+endif
+
-+curl = dependency('libcurl', version: '>=7.21.3', required: get_option('curl'))
++curl = dependency('libcurl', version: '>=7.21.3', required: get_option('curl'), default_options: ['default_library=static', 'tests=disabled'])
+use_curl_for_imap_send = false
+if curl.found()
+ if curl.version().version_compare('>=7.34.0')
@@ meson.build (new)
+ build_options_config.set('NO_CURL', '1')
+endif
+
-+expat = dependency('expat', required: get_option('expat'))
++expat = dependency('expat', required: get_option('expat'), default_options: ['default_library=static', 'build_tests=false'])
+if expat.found()
+ libgit_dependencies += expat
+
@@ meson.build (new)
+endif
+
+networking_dependencies = [ ]
-+winsock = compiler.find_library('ws2_32', required: false)
-+if winsock.found()
-+ networking_dependencies += winsock
-+endif
-+libresolv = compiler.find_library('resolv', required: false)
-+if libresolv.found()
-+ networking_dependencies += libresolv
++if host_machine.system() == 'windows'
++ winsock = compiler.find_library('ws2_32', required: false)
++ if winsock.found()
++ networking_dependencies += winsock
++ endif
++else
++ libresolv = compiler.find_library('resolv', required: false)
++ if libresolv.found()
++ networking_dependencies += libresolv
++ endif
+endif
+libgit_dependencies += networking_dependencies
+
@@ meson.build (new)
+ 'compat/win32/path-utils.c',
+ 'compat/win32/pthread.c',
+ 'compat/win32/syslog.c',
-+ 'compat/win32/trace2_win32_process_info.c',
+ 'compat/win32/dirent.c',
+ 'compat/win32mmap.c',
+ 'compat/nedmalloc/nedmalloc.c',
@@ meson.build (new)
+
+ libgit_dependencies += compiler.find_library('ntdll')
+ libgit_include_directories += 'compat/win32'
++ if compiler.get_id() == 'msvc'
++ libgit_include_directories += 'compat/vcbuild/include'
++ endif
+endif
+
+if host_machine.system() == 'linux'
+ libgit_sources += 'compat/linux/procinfo.c'
++elif host_machine.system() == 'windows'
++ libgit_sources += 'compat/win32/trace2_win32_process_info.c'
+else
+ libgit_sources += 'compat/stub/procinfo.c'
+endif
@@ meson.build (new)
+build_options_config.set_quoted('FSMONITOR_DAEMON_BACKEND', fsmonitor_backend) +build_options_config.set_quoted('FSMONITOR_OS_SETTINGS', fsmonitor_backend)
+
-+if compiler.get_define('REG_STARTEND', prefix: '#include <regex.h>') != ''
++if compiler.has_header('regex.h') and compiler.get_define('REG_STARTEND', prefix: '#include <regex.h>') != ''
+ build_options_config.set('NO_REGEX', '')
++
++ if compiler.get_define('REG_ENHANCED', prefix: '#include <regex.h>') != ''
++ libgit_c_args += '-DUSE_ENHANCED_BASIC_REGULAR_EXPRESSIONS'
++ libgit_sources += 'compat/regcomp_enhanced.c'
++ endif
+else
+ libgit_c_args += [
+ '-DNO_REGEX',
@@ meson.build (new)
+ libgit_sources += 'compat/regex/regex.c'
+ libgit_include_directories += 'compat/regex'
+endif
-+if compiler.get_define('REG_ENHANCED', prefix: '#include <regex.h>') != ''
-+ libgit_c_args += '-DUSE_ENHANCED_BASIC_REGULAR_EXPRESSIONS'
-+ libgit_sources += 'compat/regcomp_enhanced.c'
-+endif
+
+# setitimer and friends are provided by compat/mingw.c.
+if host_machine.system() != 'windows'
@@ meson.build (new)
+ openssl_required = true
+endif
+
-+openssl = dependency('openssl', required: openssl_required)
++openssl = dependency('openssl', required: openssl_required, default_options: ['default_library=static'])
+if openssl.found()
+ libgit_dependencies += openssl
+endif
@@ meson.build (new)
+ '-DGIT_USER_AGENT="' + 'git/' + meson.project_version() + '"',
+ '-DGIT_BUILT_FROM_COMMIT="' + run_command('git', 'rev-parse', '-q', '--verify', 'HEAD', check: false).stdout().strip() + '"',
+ ],
++ dependencies: libgit_dependencies,
+ include_directories: libgit_include_directories,
+)
+
@@ meson.build (new)
+ sources: libgit_sources,
+ c_args: libgit_c_args,
+ link_with: libgit_version_library,
++ dependencies: libgit_dependencies,
+ include_directories: libgit_include_directories,
+)
+
@@ meson.build (new)
+ '-Wl,-nxcompat',
+ '-Wl,-dynamicbase',
+ '-Wl,-pic-executable,-e,mainCRTStartup',
-+ '-Wl,-subsystem,console',
+ ]
+ elif compiler.get_argument_syntax() == 'msvc'
+ common_main_link_args += [
-+ '/NOLOGO',
+ '/ENTRY:wmainCRTStartup',
-+ '/SUBSYSTEM:CONSOLE',
+ 'invalidcontinue.obj',
+ ]
+ else
@@ meson.build (new)
+common_main_library = static_library('common-main',
+ sources: common_main_sources,
+ c_args: libgit_c_args,
++ dependencies: libgit_dependencies,
+ include_directories: libgit_include_directories,
+)
+common_main = declare_dependency(
@@ meson.build (new)
+
+ foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
+ test_dependencies += executable(alias,
-+ objects: git.extract_all_objects(recursive: false),
++ objects: git_remote_http.extract_all_objects(recursive: false),
+ dependencies: [libgit, common_main],
+ )
+
@@ meson_options.txt (new)
+option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt', 'block'], value: 'block',
+ description: 'The backend used for hashing objects with the SHA256 object format')
+
++option('macos_use_homebrew_gettext', type: 'boolean', value: true,
++ description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
++
+option('gitweb_config', type: 'string', value: 'gitweb_config.perl')
+option('gitweb_config_system', type: 'string', value: '/etc/gitweb.conf')
+option('gitweb_config_common', type: 'string', value: '/etc/gitweb-common.conf')
@@ po/meson.build (new)
+)
+test_dependencies += translations[0]

+ ## subprojects/curl.wrap (new) ##
+@@
++[wrap-file]
++directory = curl-8.10.1
++source_url = https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
++source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/curl_8.10.1-1/curl-8.10.1.tar.xz
++source_filename = curl-8.10.1.tar.xz
++source_hash = 73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee ++patch_filename = curl_8.10.1-1_patch.zip
++patch_url = https://wrapdb.mesonbuild.com/v2/curl_8.10.1-1/get_patch
++patch_hash = 707c28f35fc9b0e8d68c0c2800712007612f922a31da9637ce706a2159f3ddd8
++wrapdb_version = 8.10.1-1
++
++[provide]
++dependency_names = libcurl
+
+ ## subprojects/expat.wrap (new) ##
+@@
++[wrap-file]
++directory = expat-2.6.3
++source_url = https://github.com/libexpat/libexpat/releases/download/R_2_6_3/expat-2.6.3.tar.xz
++source_filename = expat-2.6.3.tar.bz2
++source_hash = 274db254a6979bde5aad404763a704956940e465843f2a9bd9ed7af22e2c0efc ++patch_filename = expat_2.6.3-1_patch.zip
++patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.6.3-1/get_patch
++patch_hash = cf017fbe105e31428b2768360bd9be39094df4e948a1e8d1c54b6f7c76460cb1 ++source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/expat_2.6.3-1/expat-2.6.3.tar.bz2
++wrapdb_version = 2.6.3-1
++
++[provide]
++expat = expat_dep
+
+ ## subprojects/openssl.wrap (new) ##
+@@
++[wrap-file]
++directory = openssl-3.0.8
++source_url = https://www.openssl.org/source/openssl-3.0.8.tar.gz
++source_filename = openssl-3.0.8.tar.gz
++source_hash = 6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e ++patch_filename = openssl_3.0.8-3_patch.zip
++patch_url = https://wrapdb.mesonbuild.com/v2/openssl_3.0.8-3/get_patch
++patch_hash = 300da189e106942347d61a4a4295aa2edbcf06184f8d13b4cee0bed9fb936963 ++source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/openssl_3.0.8-3/openssl-3.0.8.tar.gz
++wrapdb_version = 3.0.8-3
++
++[provide]
++libcrypto = libcrypto_dep
++libssl = libssl_dep
++openssl = openssl_dep
+
+ ## subprojects/pcre2.wrap (new) ##
+@@
++[wrap-file]
++directory = pcre2-10.44
++source_url = https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.bz2
++source_filename = pcre2-10.44.tar.bz2
++source_hash = d34f02e113cf7193a1ebf2770d3ac527088d485d4e047ed10e5d217c6ef5de96 ++patch_filename = pcre2_10.44-2_patch.zip
++patch_url = https://wrapdb.mesonbuild.com/v2/pcre2_10.44-2/get_patch
++patch_hash = 4336d422ee9043847e5e10dbbbd01940d4c9e5027f31ccdc33a7898a1ca94009 ++source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/pcre2_10.44-2/pcre2-10.44.tar.bz2
++wrapdb_version = 10.44-2
++
++[provide]
++libpcre2-8 = libpcre2_8
++libpcre2-16 = libpcre2_16
++libpcre2-32 = libpcre2_32
++libpcre2-posix = libpcre2_posix
+
+ ## subprojects/zlib.wrap (new) ##
+@@
++[wrap-file]
++directory = zlib-1.3.1
++source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz
++source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz
++source_filename = zlib-1.3.1.tar.gz
++source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 ++patch_filename = zlib_1.3.1-1_patch.zip
++patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch
++patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095
++wrapdb_version = 1.3.1-1
++
++[provide]
++zlib = zlib_dep
+
## t/helper/meson.build (new) ##
@@
+test_tool_sources = [
@@ t/meson.build (new)
+]
+
+clar_decls_h = custom_target('clar_decls_h',
-+ input: clar_test_suites,
-+ output: 'clar-decls.h',
-+ command : [shell, meson.current_source_dir() + '/unit-tests/generate-clar-decls.sh', '@OUTPUT@', '@INPUT@'],
++ input: clar_test_suites,
++ output: 'clar-decls.h',
++ command : [shell, meson.current_source_dir() + '/unit-tests/generate-clar-decls.sh', '@OUTPUT@', '@INPUT@'], ++ env: script_environment,
+)
++clar_sources += clar_decls_h
+
-+clar_suite = custom_target('clar_suite',
-+ input: clar_decls_h,
-+ output: 'clar.suite',
-+ feed: true,
-+ capture: true,
-+ command : [awk, '-f', meson.current_source_dir() + '/unit-tests/clar-generate.awk'],
++clar_sources += custom_target('clar_suite',
++ input: clar_decls_h,
++ output: 'clar.suite',
++ feed: true,
++ capture: true,
++ command : [awk, '-f', meson.current_source_dir() + '/unit-tests/clar-generate.awk'],
+)
+
-+clar_generated_sources = [
-+ clar_decls_h,
-+ clar_suite,
-+]
-+
+clar_unit_tests = executable('unit-tests',
-+ sources: clar_sources + clar_generated_sources + clar_test_suites,
++ sources: clar_sources + clar_test_suites,
+ dependencies: [libgit, common_main],
+)
+test('unit-tests', clar_unit_tests)
@@ t/meson.build (new)
+ git_build_dir = run_command(cygpath, git_build_dir, check: true).stdout().strip()
+endif
+
++test_environment = script_environment
++test_environment.set('GIT_BUILD_DIR', git_build_dir)
++
+foreach integration_test : integration_tests
+ test(fs.stem(integration_test), shell,
+ args: [ integration_test ],
+ workdir: meson.current_source_dir(),
-+ env: {
-+ 'GIT_BUILD_DIR': git_build_dir,
-+ },
++ env: test_environment,
+ depends: test_dependencies + bin_wrappers,
+ timeout: 0,
+ )

Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#44 lore raw

RFC PATCH v2 1/24 t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE

When assembling our LSAN_OPTIONS that configure the leak sanitizer we end up prepending the string with various different colon-separated options via calls to prepend_var. One of the settings we add is the path where the sanitizer should store logs, which can be an arbitrary filesystem path.

Naturally, filesystem paths may contain whitespace characters. And while it does seem as if we were quoting the value, we use escaped quotes and consequently split up the value if it does contain spaces. This leads to the following error in t0000 when having a value with whitespaces:

.../t/test-lib.sh: eval: line 64: unexpected EOF while looking for matching `"' ++ return 1
error: last command exited with $?=1
not ok 5 - subtest: 3 passing tests

The error itself is a bit puzzling at first. The basic problem is that the code sees the leading escaped quote during eval, but because we truncate everything after the space character it doesn't see the trailing escaped quote and thus fails to parse the string.

Properly quote the value to fix the issue while using single-quotes to quote the inner value passed to eval. The issue can be reproduced by t0000 with such a path that contains spaces.

---
 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/test-lib.sh +1 -1
index b1a8ee5c002..241198ba95f 100644
@@ -1572,7 +1572,7 @@ then
 
 	prepend_var LSAN_OPTIONS : dedup_token_length=9999
 	prepend_var LSAN_OPTIONS : log_exe_name=1
-	prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
+	prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'"
 	export LSAN_OPTIONS
 
 elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#45 lore raw

RFC PATCH v2 2/24 t/test-lib: wire up NO_ICONV prerequisite

In reply to Patrick Steinhardt

The iconv library is used by Git to reencode files, commit messages and other things. As such it is a rather integral part, but given that many platforms nowadays use UTF-8 everywhere you can live without support for reencoding in many situations. It is thus optional to build Git with iconv, and some of our platforms wired up in "config.mak.uname" disable it. But while we support building without it, running our test suite with "NO_ICONV=Yes" causes many test failures.

Wire up a new test prerequisite ICONV that gets populated via our GIT-BUILD-OPTIONS. Annotate failing tests accordingly.

Note that this commit does not do a deep dive into every single test to assess whether the failure is expected or not. Most of the tests do smell like the expected kind of failure though.

Further note that there are several "!MINGW" conditions in t4201, and all of these fail due to iconv-related errors. This is quite likely a leftover from times before dce7d29551 (msvc: support building Git using MS Visual C++, 2019-06-25), which switched Windows-based builds over from "NO_ICONV=YesPlease" to "NEEDS_LIBICONV=YesPlease". Consequently, adapt those tests to also use the new ICONV prerequisite.

---
 Makefile                                     |   1 +
 contrib/buildsystems/CMakeLists.txt          |   6 ++
 t/t0028-working-tree-encoding.sh             |   6 ++
 t/t2082-parallel-checkout-attributes.sh      |   2 +-
 t/t3434-rebase-i18n.sh                       |   6 ++
 t/t3900-i18n-commit.sh                       |   6 ++
 t/t3901-i18n-patch.sh                        |   6 ++
 t/t4041-diff-submodule-option.sh             |  16 ++-
 t/t4059-diff-submodule-not-initialized.sh    |  16 ++-
 t/t4060-diff-submodule-option-diff-format.sh |  17 ++--
 t/t4201-shortlog.sh                          |   8 +-
 t/t4205-log-pretty-formats.sh                | 102 +++++++++++--------
 t/t4210-log-i18n.sh                          |   6 ++
 t/t4254-am-corrupt.sh                        |   6 ++
 t/t5100-mailinfo.sh                          |  14 ++-
 t/t5550-http-fetch-dumb.sh                   |   4 +-
 t/t6006-rev-list-format.sh                   |  54 ++++++----
 t/t7102-reset.sh                             |  40 +++++---
 t/t8005-blame-i18n.sh                        |   6 ++
 t/t9300-fast-import.sh                       |   2 +-
 t/t9350-fast-export.sh                       |  10 +-
 t/test-lib.sh                                |   1 +
 22 files changed, 229 insertions(+), 106 deletions(-)
Makefile +1 -0
index 2dde1fd2b8b..c094840426c 100644
@@ -3172,6 +3172,7 @@ GIT-BUILD-OPTIONS: FORCE
 	@echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@+
 	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@+
 	@echo NO_CURL=\''$(subst ','\'',$(subst ','\'',$(NO_CURL)))'\' >>$@+
+	@echo NO_ICONV=\''$(subst ','\'',$(subst ','\'',$(NO_ICONV)))'\' >>$@+
 	@echo NO_EXPAT=\''$(subst ','\'',$(subst ','\'',$(NO_EXPAT)))'\' >>$@+
 	@echo USE_LIBPCRE2=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE2)))'\' >>$@+
 	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@+
contrib/buildsystems/CMakeLists.txt +6 -0
index 62af7b33d2f..1384c0eb6d3 100644
@@ -1109,6 +1109,7 @@ set(DIFF diff)
 set(PYTHON_PATH /usr/bin/python)
 set(TAR tar)
 set(NO_CURL )
+set(NO_ICONV )
 set(NO_EXPAT )
 set(USE_LIBPCRE2 )
 set(NO_PERL )
@@ -1122,6 +1123,10 @@ if(NOT CURL_FOUND)
 	set(NO_CURL 1)
 endif()
 
+if(NOT Iconv_FOUND)
+	SET(NO_ICONV 1)
+endif()
+
 if(NOT EXPAT_FOUND)
 	set(NO_EXPAT 1)
 endif()
@@ -1145,6 +1150,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_ICONV='${NO_ICONV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
t/t0028-working-tree-encoding.sh +6 -0
index ad151a34670..510da4ca12d 100755
@@ -12,6 +12,12 @@ TEST_CREATE_REPO_NO_TEMPLATE=1
 
 GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping working tree encoding tests; iconv not available'
+	test_done
+fi
+
 test_expect_success 'setup test files' '
 	git config core.eol lf &&
 
t/t2082-parallel-checkout-attributes.sh +1 -1
index aec55496eb1..a040aa54cee 100755
@@ -34,7 +34,7 @@ test_expect_success 'parallel-checkout with ident' '
 	)
 '
 
-test_expect_success 'parallel-checkout with re-encoding' '
+test_expect_success ICONV 'parallel-checkout with re-encoding' '
 	set_checkout_config 2 0 &&
 	git init encoding &&
 	(
t/t3434-rebase-i18n.sh +6 -0
index 26a48d6b103..97fc9a23f21 100755
@@ -20,6 +20,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping rebase i18n tests; iconv not available'
+	test_done
+fi
+
 compare_msg () {
 	iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
 	git cat-file commit HEAD >raw &&
t/t3900-i18n-commit.sh +6 -0
index db7b403bc15..9d4b5ab1f95 100755
@@ -8,6 +8,12 @@ test_description='commit and log output encodings'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping commit i18n tests; iconv not available'
+	test_done
+fi
+
 compare_with () {
 	git show -s $1 | sed -e '1,/^$/d' -e 's/^    //' >current &&
 	case "$3" in
t/t3901-i18n-patch.sh +6 -0
index 5f0b9afc3fa..e0659c92935 100755
@@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping patch i18n tests; iconv not available'
+	test_done
+fi
+
 check_encoding () {
 	# Make sure characters are not corrupted
 	cnt="$1" header="$2" i=1 j=0
t/t4041-diff-submodule-option.sh +11 -5
index 8fc40e75eb3..aa149e0085e 100755
@@ -15,12 +15,18 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+	test_encoding="ISO8859-1"
+	# String "added" in German (translated with Google Translate), encoded in UTF-8,
+	# used in sample commit log messages in add_file() function below.
+	added=$(printf "hinzugef\303\274gt")
+else
+	test_encoding="UTF-8"
+	added="added"
+fi
 
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
 add_file () {
 	(
 		cd "$1" &&
t/t4059-diff-submodule-not-initialized.sh +11 -5
index 668f5263038..28fd3cdb154 100755
@@ -12,12 +12,18 @@ initialized previously but the checkout has since been removed.
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
 
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+	test_encoding="ISO8859-1"
+	# String "added" in German (translated with Google Translate), encoded in UTF-8,
+	# used in sample commit log messages in add_file() function below.
+	added=$(printf "hinzugef\303\274gt")
+else
+	test_encoding="UTF-8"
+	added="added"
+fi
 
 add_file () {
 	(
t/t4060-diff-submodule-option-diff-format.sh +11 -6
index 8ce67442d96..918334fa4c8 100755
@@ -13,12 +13,17 @@ This test tries to verify the sanity of --submodule=diff option of git diff.
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
-
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+	test_encoding="ISO8859-1"
+	# String "added" in German (translated with Google Translate), encoded in UTF-8,
+	# used in sample commit log messages in add_file() function below.
+	added=$(printf "hinzugef\303\274gt")
+else
+	test_encoding="UTF-8"
+	added="added"
+fi
 
 add_file () {
 	(
t/t4201-shortlog.sh +4 -4
index c20c8857244..680e707ba1e 100755
@@ -105,7 +105,7 @@ test_expect_success 'output from user-defined format is re-wrapped' '
 	test_cmp expect log.predictable
 '
 
-test_expect_success !MINGW 'shortlog wrapping' '
+test_expect_success ICONV 'shortlog wrapping' '
 	cat >expect <<\EOF &&
 A U Thor (5):
       Test
@@ -126,13 +126,13 @@ EOF
 	test_cmp expect out
 '
 
-test_expect_success !MINGW 'shortlog from non-git directory' '
+test_expect_success ICONV 'shortlog from non-git directory' '
 	git log --no-expand-tabs HEAD >log &&
 	GIT_DIR=non-existing git shortlog -w <log >out &&
 	test_cmp expect out
 '
 
-test_expect_success !MINGW 'shortlog can read --format=raw output' '
+test_expect_success ICONV 'shortlog can read --format=raw output' '
 	git log --format=raw HEAD >log &&
 	GIT_DIR=non-existing git shortlog -w <log >out &&
 	test_cmp expect out
@@ -182,7 +182,7 @@ $DSCHO (2):
 
 EOF
 
-test_expect_success !MINGW 'shortlog encoding' '
+test_expect_success ICONV 'shortlog encoding' '
 	git reset --hard "$commit" &&
 	git config --unset i18n.commitencoding &&
 	echo 2 > a1 &&
t/t4205-log-pretty-formats.sh +59 -43

310 lines not on this page · raw message

t/t4210-log-i18n.sh +6 -0
index 7120030b5c6..4a12b2b4979 100755
@@ -5,6 +5,12 @@ test_description='test log with i18n features'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./lib-gettext.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping log i18n tests; iconv not available'
+	test_done
+fi
+
 # two forms of é
 utf8_e=$(printf '\303\251')
 latin1_e=$(printf '\351')
t/t4254-am-corrupt.sh +6 -0
index 661feb60709..cb03522d021 100755
@@ -5,6 +5,12 @@ test_description='git am with corrupt input'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping am encoding corruption tests; iconv not available'
+	test_done
+fi
+
 make_mbox_with_nul () {
 	space=' '
 	q_nul_in_subject=
t/t5100-mailinfo.sh +12 -2
index 065156c1f39..23b2f218725 100755
@@ -28,7 +28,12 @@ check_mailinfo () {
 
 for mail in 00*
 do
-	test_expect_success "mailinfo $mail" '
+	case "$mail" in
+	0004)
+		prereq=ICONV;;
+	esac
+
+	test_expect_success $prereq "mailinfo $mail" '
 		check_mailinfo "$mail" "" &&
 		if test -f "$DATA/msg$mail--scissors"
 		then
@@ -56,7 +61,12 @@ test_expect_success 'split box with rfc2047 samples' \
 
 for mail in rfc2047/00*
 do
-	test_expect_success "mailinfo $mail" '
+	case "$mail" in
+	rfc2047/0001)
+		prereq=ICONV;;
+	esac
+
+	test_expect_success $prereq "mailinfo $mail" '
 		git mailinfo -u "$mail-msg" "$mail-patch" <"$mail" >"$mail-info" &&
 		echo msg &&
 		test_cmp "$DATA/empty" "$mail-msg" &&
t/t5550-http-fetch-dumb.sh +2 -2
index 58189c9f7dc..3c873de17ec 100755
@@ -344,12 +344,12 @@ test_expect_success 'git client shows text/plain with a charset' '
 	grep "this is the error message" stderr
 '
 
-test_expect_success 'http error messages are reencoded' '
+test_expect_success ICONV 'http error messages are reencoded' '
 	test_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr &&
 	grep "this is the error message" stderr
 '
 
-test_expect_success 'reencoding is robust to whitespace oddities' '
+test_expect_success ICONV 'reencoding is robust to whitespace oddities' '
 	test_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr &&
 	grep "this is the error message" stderr
 '
t/t6006-rev-list-format.sh +37 -17

72 lines not on this page · raw message

t/t7102-reset.sh +25 -15
index 2add26d7684..e9a6cc72658 100755
@@ -13,21 +13,31 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
-commit_msg () {
-	# String "modify 2nd file (changed)" partly in German
-	# (translated with Google Translate),
-	# encoded in UTF-8, used as a commit log message below.
-	msg="modify 2nd file (ge\303\244ndert)\n"
-	if test -n "$1"
-	then
-		printf "$msg" | iconv -f utf-8 -t "$1"
-	else
-		printf "$msg"
-	fi
-}
-
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
+if test_have_prereq ICONV
+then
+	commit_msg () {
+		# String "modify 2nd file (changed)" partly in German
+		# (translated with Google Translate),
+		# encoded in UTF-8, used as a commit log message below.
+		msg="modify 2nd file (ge\303\244ndert)\n"
+		if test -n "$1"
+		then
+			printf "$msg" | iconv -f utf-8 -t "$1"
+		else
+			printf "$msg"
+		fi
+	}
+
+	# Tested non-UTF-8 encoding
+	test_encoding="ISO8859-1"
+else
+	commit_msg () {
+		echo "modify 2nd file (geandert)"
+	}
+
+	# Tested non-UTF-8 encoding
+	test_encoding="UTF-8"
+fi
 
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
t/t8005-blame-i18n.sh +6 -0
index 75da219ed1b..7a1f581c240 100755
@@ -3,6 +3,12 @@
 test_description='git blame encoding conversion'
 . ./test-lib.sh
 
+if ! test_have_prereq ICONV
+then
+	skip_all='skipping blame i18n tests; iconv not available'
+	test_done
+fi
+
 . "$TEST_DIRECTORY"/t8005/utf8.txt
 . "$TEST_DIRECTORY"/t8005/euc-japan.txt
 . "$TEST_DIRECTORY"/t8005/sjis.txt
t/t9300-fast-import.sh +1 -1
index 3b3c371740a..6224f54d4d2 100755
@@ -3676,7 +3676,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi
 ### series X (other new features)
 ###
 
-test_expect_success 'X: handling encoding' '
+test_expect_success ICONV 'X: handling encoding' '
 	test_tick &&
 	cat >input <<-INPUT_END &&
 	commit refs/heads/encoding
t/t9350-fast-export.sh +5 -5
index 1eb035ee4ce..aa33791b77b 100755
@@ -124,7 +124,7 @@ test_expect_success 'fast-export --show-original-ids | git fast-import' '
 	test $MUSS = $(git rev-parse --verify refs/tags/muss)
 '
 
-test_expect_success 'reencoding iso-8859-7' '
+test_expect_success ICONV 'reencoding iso-8859-7' '
 
 	test_when_finished "git reset --hard HEAD~1" &&
 	test_config i18n.commitencoding iso-8859-7 &&
@@ -420,7 +420,7 @@ M 100644 :1 there
 
 EOF
 
-test_expect_success 'dropping tag of filtered out object' '
+test_expect_success ICONV 'dropping tag of filtered out object' '
 (
 	cd limit-by-paths &&
 	git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
@@ -437,7 +437,7 @@ msg
 
 EOF
 
-test_expect_success 'rewriting tag of filtered out object' '
+test_expect_success ICONV 'rewriting tag of filtered out object' '
 (
 	cd limit-by-paths &&
 	git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
@@ -666,7 +666,7 @@ M 100644 :13 file
 
 EOF
 
-test_expect_success 'avoid uninteresting refs' '
+test_expect_success ICONV 'avoid uninteresting refs' '
 	> tmp-marks &&
 	git fast-export --import-marks=tmp-marks \
 		--export-marks=tmp-marks main > /dev/null &&
@@ -685,7 +685,7 @@ from :14
 
 EOF
 
-test_expect_success 'refs are updated even if no commits need to be exported' '
+test_expect_success ICONV 'refs are updated even if no commits need to be exported' '
 	> tmp-marks &&
 	git fast-export --import-marks=tmp-marks \
 		--export-marks=tmp-marks main > /dev/null &&
t/test-lib.sh +1 -0
index 241198ba95f..a278181a056 100644
@@ -1743,6 +1743,7 @@ esac
 
 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
 test -z "$NO_CURL" && test_set_prereq LIBCURL
+test -z "$NO_ICONV" && test_set_prereq ICONV
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#46 lore raw

RFC PATCH v2 3/24 t/lib-gitweb: test against the build version of gitweb

In reply to Patrick Steinhardt

When testing gitweb we set up the CGI script as "gitweb.perl", which is the source file of the build target "gitweb.cgi". This works alright as long as we run in-tree tests. But we're about to make out-of-tree tests a reality, and there things will break because "gitweb.perl" will not be found in the build directory.

Fix this by using "gitweb.cgi" instead.

---
 t/lib-gitweb.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/lib-gitweb.sh +1 -1
index 1f32ca66ea5..c64c87fb87d 100644
@@ -49,7 +49,7 @@ EOF
 		error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
 		say "# Testing $SCRIPT_NAME"
 	else # normal case, use source version of gitweb
-		SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
+		SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.cgi"
 	fi
 	export SCRIPT_NAME
 }
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#47 lore raw

RFC PATCH v2 4/24 t/lib-gpg: fix setup of GNUPGHOME in MinGW

In reply to Patrick Steinhardt

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to point to a test-specific directory. This is done by using "$PWD/gpghome" as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style paths that contain drive letters. What we really want in this context is a Unix-style path, which we can get by using $(pwd) instead. It is somewhat puzzling that nobody ever hit this issue, but it may easily be that nobody ever tests on Windows with GnuPG installed, which would make us skip those tests.

Adapt the code accordingly to fix tests using this library.

---
 t/lib-gpg.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/lib-gpg.sh +1 -1
index add11e88fc0..3845b6ac449 100644
@@ -6,7 +6,7 @@
 #   executed in an eval'ed subshell that changes the working directory to a
 #   temporary one.
 
-GNUPGHOME="$PWD/gpghome"
+GNUPGHOME="$(pwd)/gpghome"
 export GNUPGHOME
 
 test_lazy_prereq GPG '
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#48 lore raw

RFC PATCH v2 5/24 t1401: make invocation of tar(1) work with Win32-provided one

In reply to Patrick Steinhardt

Windows nowadays provides a tar(1) binary in "C:\Windows\system32". This version of tar(1) doesn't seem to handle the case where directory paths end with a trailing forward slash. And as we do that in t1401 the result is that the test fails.

Drop the trailing slash. Other tests that use tar(1) work alright, this is the only instance where it has been failing.

---
 t/t1401-symbolic-ref.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t1401-symbolic-ref.sh +1 -1
index 5c60d6f812d..90af3f955c0 100755
@@ -16,7 +16,7 @@ reset_to_sane() {
 test_expect_success 'setup' '
 	git symbolic-ref HEAD refs/heads/foo &&
 	test_commit file &&
-	"$TAR" cf .git.tar .git/
+	"$TAR" cf .git.tar .git
 '
 
 test_expect_success 'symbolic-ref read/write roundtrip' '
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#49 lore raw

RFC PATCH v2 6/24 t3404: work around platform-specific behaviour on macOS 10.15

In reply to Patrick Steinhardt

Two of our tests in t3404 use indented HERE docs where leading tabs on some of the lines are actually relevant. The tabs do get removed though, and we try to fix this up by using sed(1) to replace leading tabs in the actual output, as well. But macOS 10.15 uses an oldish version of sed(1) that has BSD lineage, which does not understand "\t", and thus we fail to strip those leading tabs and fail the test.

Address this issue by using q_to_tab such that we do not have to strip leading tabs from the actual output.

---
 t/t3404-rebase-interactive.sh | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
t/t3404-rebase-interactive.sh +12 -14
index f171af3061d..7ce75237803 100755
@@ -1917,18 +1917,17 @@ test_expect_success '--update-refs updates refs correctly' '
 	test_cmp_rev HEAD~1 refs/heads/third &&
 	test_cmp_rev HEAD refs/heads/no-conflict-branch &&
 
-	cat >expect <<-\EOF &&
+	q_to_tab >expect <<-\EOF &&
 	Successfully rebased and updated refs/heads/update-refs.
 	Updated the following refs with --update-refs:
-		refs/heads/first
-		refs/heads/no-conflict-branch
-		refs/heads/second
-		refs/heads/third
+	Qrefs/heads/first
+	Qrefs/heads/no-conflict-branch
+	Qrefs/heads/second
+	Qrefs/heads/third
 	EOF
 
 	# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
-	sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
-		<err >err.trimmed &&
+	sed "s/Rebasing.*Successfully/Successfully/g" <err >err.trimmed &&
 	test_cmp expect err.trimmed
 '
 
@@ -2178,19 +2177,18 @@ test_expect_success '--update-refs: check failed ref update' '
 	test_must_fail git rebase --continue 2>err &&
 	grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
 
-	cat >expect <<-\EOF &&
+	q_to_tab >expect <<-\EOF &&
 	Updated the following refs with --update-refs:
-		refs/heads/first
-		refs/heads/no-conflict-branch
-		refs/heads/third
+	Qrefs/heads/first
+	Qrefs/heads/no-conflict-branch
+	Qrefs/heads/third
 	Failed to update the following refs with --update-refs:
-		refs/heads/second
+	Qrefs/heads/second
 	EOF
 
 	# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
 	tail -n 6 err >err.last &&
-	sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
-		<err.last >err.trimmed &&
+	sed "s/Rebasing.*Successfully/Successfully/g" <err.last >err.trimmed &&
 	test_cmp expect err.trimmed
 '
 
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#50 lore raw

RFC PATCH v2 7/24 t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin

In reply to Patrick Steinhardt

Parsing repositories which contain '[::1]' is broken on Cygwin. It seems as if Cygwin is confusing those as drive letter prefixes or something like this, but I couldn't deduce the actual root cause.

Mark those tests as broken for now.

---
 t/t5500-fetch-pack.sh | 14 ++++++++++----
 t/t5601-clone.sh      | 11 +++++++++--
 2 files changed, 19 insertions(+), 6 deletions(-)
t/t5500-fetch-pack.sh +10 -4
index 605f17240c1..416522c86ad 100755
@@ -774,7 +774,7 @@ do
 	# file with scheme
 	for p in file
 	do
-		test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
+		test_expect_success !WINDOWS "fetch-pack --diag-url $p://$h/$r" '
 			check_prot_path $p://$h/$r $p "/$r"
 		'
 		test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" '
@@ -784,7 +784,7 @@ do
 			check_prot_path $p:///$r $p "/$r"
 		'
 		# No "/~" -> "~" conversion for file
-		test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" '
+		test_expect_success !WINDOWS "fetch-pack --diag-url $p://$h/~$r" '
 			check_prot_path $p://$h/~$r $p "/~$r"
 		'
 		test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
@@ -806,11 +806,17 @@ do
 	p=ssh
 	for h in host [::1]
 	do
-		test_expect_success "fetch-pack --diag-url $h:$r" '
+		expectation="success"
+		if test_have_prereq CYGWIN && test "$h" = "[::1]"
+		then
+			expectation="failure"
+		fi
+
+		test_expect_$expectation "fetch-pack --diag-url $h:$r" '
 			check_prot_host_port_path $h:$r $p "$h" NONE "$r"
 		'
 		# Do "/~" -> "~" conversion
-		test_expect_success "fetch-pack --diag-url $h:/~$r" '
+		test_expect_$expectation "fetch-pack --diag-url $h:/~$r" '
 			check_prot_host_port_path $h:/~$r $p "$h" NONE "~$r"
 		'
 	done
t/t5601-clone.sh +9 -2
index 5d7ea147f1a..9fe665eadfb 100755
@@ -530,10 +530,17 @@ do
 	'
 done
 
+# Parsing of paths that look like IPv6 addresses is broken on Cygwin.
+expectation_for_ipv6_tests=success
+if test_have_prereq CYGWIN
+then
+	expectation_for_ipv6_tests=failure
+fi
+
 #ipv6
 for repo in rep rep/home/project 123
 do
-	test_expect_success "clone [::1]:$repo" '
+	test_expect_$expectation_for_ipv6_tests "clone [::1]:$repo" '
 		test_clone_url [::1]:$repo ::1 "$repo"
 	'
 done
@@ -542,7 +549,7 @@ test_expect_success "clone host:/~repo" '
 	test_clone_url host:/~repo host "~repo"
 '
 
-test_expect_success "clone [::1]:/~repo" '
+test_expect_$expectation_for_ipv6_tests "clone [::1]:/~repo" '
 	test_clone_url [::1]:/~repo ::1 "~repo"
 '
 
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#51 lore raw

RFC PATCH v2 8/24 t7300: work around platform-specific behaviour with long paths on MinGW

In reply to Patrick Steinhardt

Windows by default has a restriction in place to only allow paths up to 260 characters. This restriction can nowadays be lifted by setting a registry key, but is still active by default.

In t7300 we have one test that exercises the behaviour of git-clean(1) with such long paths. Interestingly enough, this test fails on my system that uses Windows 10 with mingw-w64 installed via MSYS2: instead of observing ENAMETOOLONG, we observe ENOENT. This behaviour is consistent across multiple different environments I have tried.

I cannot say why exactly we observe a different error here, but I would not be surprised if this was either dependent on the Windows version, the version of MinGW, the current working directory of Git or any kind of combination of these.

Work around the issue by handling both errors.

---
 t/t7300-clean.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t7300-clean.sh +1 -1
index 0aae0dee670..12ab25296b0 100755
@@ -747,7 +747,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
 	test_must_fail git clean -xdf 2>.git/err &&
 	# grepping for a strerror string is unportable but it is OK here with
 	# MINGW prereq
-	test_grep "too long" .git/err
+	test_grep -e "too long" -e "No such file or directory" .git/err
 '
 
 test_expect_success 'clean untracked paths by pathspec' '
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#52 lore raw

RFC PATCH v2 9/24 t/unit-tests: update clar unit test framework

In reply to Patrick Steinhardt

Update clar unit test framework to f065214 (Merge pull request #105 from pks-t/pks-win32-stat-compat, 2024-10-03), which fixes some platform compatibility issues with Windows.

---
 t/unit-tests/clar/.editorconfig            |  13 +++
 t/unit-tests/clar/.github/workflows/ci.yml |  20 +++-
 t/unit-tests/clar/.gitignore               |   1 +
 t/unit-tests/clar/CMakeLists.txt           |  28 ++++++
 t/unit-tests/clar/clar.c                   | 111 ++++++++++-----------
 t/unit-tests/clar/clar/print.h             |  11 +-
 t/unit-tests/clar/clar/sandbox.h           |  17 ++--
 t/unit-tests/clar/clar/summary.h           |  14 +--
 t/unit-tests/clar/test/.gitignore          |   4 -
 t/unit-tests/clar/test/CMakeLists.txt      |  41 ++++++++
 t/unit-tests/clar/test/Makefile            |  39 --------
 11 files changed, 175 insertions(+), 124 deletions(-)
 create mode 100644 t/unit-tests/clar/.editorconfig
 create mode 100644 t/unit-tests/clar/.gitignore
 create mode 100644 t/unit-tests/clar/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/CMakeLists.txt
 delete mode 100644 t/unit-tests/clar/test/Makefile
t/unit-tests/clar/.editorconfig new file +13 -0
new file mode 100644
index 00000000000..aa343a42885
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+charset = utf-8
+insert_final_newline = true
+
+[*.{c,h}]
+indent_style = tab
+tab_width = 8
+
+[CMakeLists.txt]
+indent_style = tab
+tab_width = 8
t/unit-tests/clar/.github/workflows/ci.yml +16 -4
index b1ac2de460a..0065843d17a 100644
@@ -10,14 +10,26 @@ jobs:
   build:
     strategy:
       matrix:
-        os: [ ubuntu-latest, macos-latest ]
+        platform:
+          - os: ubuntu-latest
+            generator: Unix Makefiles
+          - os: macos-latest
+            generator: Unix Makefiles
+          - os: windows-latest
+            generator: Visual Studio 17 2022
+          - os: windows-latest
+            generator: MSYS Makefiles
+          - os: windows-latest
+            generator: MinGW Makefiles
 
-    runs-on: ${{ matrix.os }}
+    runs-on: ${{ matrix.platform.os }}
 
     steps:
     - name: Check out
       uses: actions/checkout@v2
     - name: Build
       run: |
-        cd test
-        make
+        mkdir build
+        cd build
+        cmake .. -G "${{matrix.platform.generator}}"
+        cmake --build .
t/unit-tests/clar/.gitignore new file +1 -0
new file mode 100644
index 00000000000..84c048a73cc
@@ -0,0 +1 @@
+/build/
t/unit-tests/clar/CMakeLists.txt new file +28 -0
new file mode 100644
index 00000000000..12d4af114fe
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.16..3.29)
+
+project(clar LANGUAGES C)
+
+option(BUILD_TESTS "Build test executable" ON)
+
+add_library(clar INTERFACE)
+target_sources(clar INTERFACE
+	clar.c
+	clar.h
+	clar/fixtures.h
+	clar/fs.h
+	clar/print.h
+	clar/sandbox.h
+	clar/summary.h
+)
+set_target_properties(clar PROPERTIES
+	C_STANDARD 90
+	C_STANDARD_REQUIRED ON
+	C_EXTENSIONS OFF
+)
+
+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
+	include(CTest)
+	if(BUILD_TESTING)
+		add_subdirectory(test)
+	endif()
+endif()
t/unit-tests/clar/clar.c +55 -56

236 lines not on this page · raw message

t/unit-tests/clar/clar/print.h +8 -3
index c17e2f693bd..69d0ee967e7 100644
@@ -21,7 +21,7 @@ static void clar_print_clap_error(int num, const struct clar_report *report, con
 {
 	printf("  %d) Failure:\n", num);
 
-	printf("%s::%s [%s:%"PRIuZ"]\n",
+	printf("%s::%s [%s:%"PRIuMAX"]\n",
 		report->suite,
 		report->test,
 		error->file,
@@ -136,7 +136,7 @@ static void clar_print_tap_ontest(const char *suite_name, const char *test_name,
 
 		printf("    at:\n");
 		printf("      file: '"); print_escaped(error->file); printf("'\n");
-		printf("      line: %" PRIuZ "\n", error->line_number);
+		printf("      line: %" PRIuMAX "\n", error->line_number);
 		printf("      function: '%s'\n", error->function);
 		printf("    ---\n");
 
@@ -202,10 +202,15 @@ static void clar_print_onsuite(const char *suite_name, int suite_index)
 	PRINT(onsuite, suite_name, suite_index);
 }
 
+static void clar_print_onabortv(const char *msg, va_list argp)
+{
+	PRINT(onabort, msg, argp);
+}
+
 static void clar_print_onabort(const char *msg, ...)
 {
 	va_list argp;
 	va_start(argp, msg);
-	PRINT(onabort, msg, argp);
+	clar_print_onabortv(msg, argp);
 	va_end(argp);
 }
t/unit-tests/clar/clar/sandbox.h +8 -9
index e25057b7c49..681a1f80f17 100644
@@ -122,14 +122,14 @@ static int build_sandbox_path(void)
 
 	if (mkdir(_clar_path, 0700) != 0)
 		return -1;
-#elif defined(__TANDEM)
-	if (mktemp(_clar_path) == NULL)
+#elif defined(_WIN32)
+	if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
 		return -1;
 
 	if (mkdir(_clar_path, 0700) != 0)
 		return -1;
-#elif defined(_WIN32)
-	if (_mktemp_s(_clar_path, sizeof(_clar_path)) != 0)
+#elif defined(__TANDEM)
+	if (mktemp(_clar_path) == NULL)
 		return -1;
 
 	if (mkdir(_clar_path, 0700) != 0)
@@ -142,15 +142,14 @@ static int build_sandbox_path(void)
 	return 0;
 }
 
-static int clar_sandbox(void)
+static void clar_sandbox(void)
 {
 	if (_clar_path[0] == '\0' && build_sandbox_path() < 0)
-		return -1;
+		clar_abort("Failed to build sandbox path.\n");
 
 	if (chdir(_clar_path) != 0)
-		return -1;
-
-	return 0;
+		clar_abort("Failed to change into sandbox directory '%s': %s.\n",
+			   _clar_path, strerror(errno));
 }
 
 const char *clar_sandbox_path(void)
t/unit-tests/clar/clar/summary.h +5 -9
index 4dd352e28b8..0d0b646fe75 100644
@@ -66,16 +66,12 @@ struct clar_summary *clar_summary_init(const char *filename)
 	struct clar_summary *summary;
 	FILE *fp;
 
-	if ((fp = fopen(filename, "w")) == NULL) {
-		perror("fopen");
-		return NULL;
-	}
+	if ((fp = fopen(filename, "w")) == NULL)
+		clar_abort("Failed to open the summary file '%s': %s.\n",
+			   filename, strerror(errno));
 
-	if ((summary = malloc(sizeof(struct clar_summary))) == NULL) {
-		perror("malloc");
-		fclose(fp);
-		return NULL;
-	}
+	if ((summary = malloc(sizeof(struct clar_summary))) == NULL)
+		clar_abort("Failed to allocate summary.\n");
 
 	summary->filename = filename;
 	summary->fp = fp;
t/unit-tests/clar/test/.gitignore deleted +0 -4
deleted file mode 100644
index a477d0c40ca..00000000000
@@ -1,4 +0,0 @@
-clar.suite
-.clarcache
-clar_test
-*.o
t/unit-tests/clar/test/CMakeLists.txt new file +41 -0

41 lines not on this page · raw message

t/unit-tests/clar/test/Makefile deleted +0 -39
deleted file mode 100644
index 93c6b2ad32c..00000000000
@@ -1,39 +0,0 @@
-#
-# Copyright (c) Vicent Marti. All rights reserved.
-#
-# This file is part of clar, distributed under the ISC license.
-# For full terms see the included COPYING file.
-#
-
-#
-# Set up the path to the clar sources and to the fixtures directory
-#
-# The fixture path needs to be an absolute path so it can be used
-# even after we have chdir'ed into the test directory while testing.
-#
-CURRENT_MAKEFILE  := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
-TEST_DIRECTORY    := $(abspath $(dir $(CURRENT_MAKEFILE)))
-CLAR_PATH         := $(dir $(TEST_DIRECTORY))
-CLAR_FIXTURE_PATH := $(TEST_DIRECTORY)/resources/
-
-CFLAGS=-g -I.. -I. -Wall -DCLAR_FIXTURE_PATH=\"$(CLAR_FIXTURE_PATH)\"
-
-.PHONY: clean
-
-# list the objects that go into our test
-objects = main.o sample.o
-
-# build the test executable itself
-clar_test: $(objects) clar_test.h clar.suite $(CLAR_PATH)clar.c
-	$(CC) $(CFLAGS) -o $@ "$(CLAR_PATH)clar.c" $(objects)
-
-# test object files depend on clar macros
-$(objects) : $(CLAR_PATH)clar.h
-
-# build the clar.suite file of test metadata
-clar.suite:
-	python "$(CLAR_PATH)generate.py" .
-
-# remove all generated files
-clean:
-	$(RM) -rf *.o clar.suite .clarcache clar_test clar_test.dSYM
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#53 lore raw

RFC PATCH v2 10/24 builtin/credential-cache: fix missing parameter for stub function

In reply to Patrick Steinhardt

When not compiling the credential cache we may use a stub function for cmd_credential_cache(). With commit 9b1cb5070f (builtin: add a repository parameter for builtin functions, 2024-09-13), we have added a new parameter to all of those top-level cmd_*() functions, and did indeed adapt the non-stubbed-out cmd_credential_cache(). But we didn't adapt the stubbed-out variant, so the code does not compile.

Fix this by adding the missing parameter.

---
 builtin/credential-cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
builtin/credential-cache.c +2 -1
index 5de8b9123bf..c51f7fc2ade 100644
@@ -189,7 +189,8 @@ int cmd_credential_cache(int argc,
 
 #else
 
-int cmd_credential_cache(int argc, const char **argv, const char *prefix)
+int cmd_credential_cache(int argc, const char **argv, const char *prefix,
+			 struct repository *repo UNUSED)
 {
 	const char * const usage[] = {
 		"git credential-cache [options] <action>",
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#54 lore raw

RFC PATCH v2 11/24 http: fix build error on FreeBSD

In reply to Patrick Steinhardt

The result parameter passed to http_request_reauth() may either point to a struct strbuf or a FILE *, where the target parameter tells us which of either it actually is. To accommodate for both types the pointer is a void *, which we then pass directly to functions without doing a cast.

This is fine on most platforms, but it breaks on FreeBSD because fileno() is implemented as a macro that tries to directly access the FILE * structure.

Fix this issue by storing the FILE * in a local variable before we pass it on to other functions.

---
 http.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
http.c +6 -4
index d59e59f66b1..72973175a85 100644
@@ -2290,17 +2290,19 @@ static int http_request_reauth(const char *url,
 		case HTTP_REQUEST_STRBUF:
 			strbuf_reset(result);
 			break;
-		case HTTP_REQUEST_FILE:
-			if (fflush(result)) {
+		case HTTP_REQUEST_FILE: {
+			FILE *f = result;
+			if (fflush(f)) {
 				error_errno("unable to flush a file");
 				return HTTP_START_FAILED;
 			}
-			rewind(result);
-			if (ftruncate(fileno(result), 0) < 0) {
+			rewind(f);
+			if (ftruncate(fileno(f), 0) < 0) {
 				error_errno("unable to truncate a file");
 				return HTTP_START_FAILED;
 			}
 			break;
+		}
 		default:
 			BUG("Unknown http_request target");
 		}
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#55 lore raw

RFC PATCH v2 12/24 Makefile: extract script to generate clar declarations

In reply to Patrick Steinhardt

Extract the script to generate function declarations for the clar unit testing framework into a standalone script. This is done such that we can reuse it in other build systems.

---
 Makefile                            |  4 +---
 t/unit-tests/generate-clar-decls.sh | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100755 t/unit-tests/generate-clar-decls.sh
Makefile +1 -3
index c094840426c..0d542c58f3a 100644
@@ -3906,9 +3906,7 @@ GIT-TEST-SUITES: FORCE
             fi
 
 $(UNIT_TEST_DIR)/clar-decls.h: $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES)) GIT-TEST-SUITES
-	$(QUIET_GEN)for suite in $(CLAR_TEST_SUITES); do \
-		sed -ne "s/^\(void test_$${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$$\)/extern \1;/p" $(UNIT_TEST_DIR)/$$suite.c; \
-	done >$@
+	$(QUIET_GEN)$(SHELL_PATH) $(UNIT_TEST_DIR)/generate-clar-decls.sh "$@" $(patsubst %,$(UNIT_TEST_DIR)/%.c,$(CLAR_TEST_SUITES))
 $(UNIT_TEST_DIR)/clar.suite: $(UNIT_TEST_DIR)/clar-decls.h
 	$(QUIET_GEN)awk -f $(UNIT_TEST_DIR)/clar-generate.awk $< >$(UNIT_TEST_DIR)/clar.suite
 $(CLAR_TEST_OBJS): $(UNIT_TEST_DIR)/clar-decls.h
t/unit-tests/generate-clar-decls.sh new file +18 -0
new file mode 100755
index 00000000000..6646a90f711
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if test $# -lt 2
+then
+	echo "USAGE: $0 <OUTPUT> <SUITE>..." 2>&1
+	exit 1
+fi
+
+OUTPUT="$1"
+shift
+
+while test "$#" -ne 0
+do
+	suite="$1"
+	shift
+	sed -ne "s/^\(void test_$suite__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)$\)/extern \1;/p" "$suite" ||
+	exit 1
+done >"$OUTPUT"
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#56 lore raw

RFC PATCH v2 13/24 Makefile: extract script to massage Perl scripts

In reply to Patrick Steinhardt

Extract the script to inject various build-time parameters into our Perl scripts into a standalone script. This is done such that we can reuse it in other build systems.

---
 Makefile         | 10 +---------
 generate-perl.sh | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)
 create mode 100755 generate-perl.sh
Makefile +1 -9
index 0d542c58f3a..50fbc4f29d0 100644
@@ -2605,15 +2605,7 @@ endif
 PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
 
 $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
-	$(QUIET_GEN) \
-	sed -e '1{' \
-	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-	    -e '	r GIT-PERL-HEADER' \
-	    -e '	G' \
-	    -e '}' \
-	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-	    $< >$@+ && \
-	chmod +x $@+ && \
+	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh $(GIT_VERSION) GIT-PERL-HEADER "$(PERL_PATH_SQ)" "$<" "$@+" && \
 	mv $@+ $@
 
 PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
generate-perl.sh new file +22 -0
new file mode 100755
index 00000000000..b9e04d6f42a
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if test $# -ne 5
+then
+	echo "USAGE: $0 <GIT_VERSION> <PERL_HEADER> <PERL_PATH> <PERL_SCRIPT> <OUT>" >&2
+	exit 1
+fi
+
+GIT_VERSION="$1"
+PERL_HEADER="$2"
+PERL_PATH="$3"
+PERL_SCRIPT="$4"
+OUT="$5"
+
+sed -e '1{' \
+    -e "	s|#!.*perl|#!$PERL_PATH|" \
+    -e "	r $PERL_HEADER" \
+    -e '	G' \
+    -e '}' \
+    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
+    "$PERL_SCRIPT" >"$OUT"
+chmod a+x "$OUT"
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#57 lore raw

RFC PATCH v2 14/24 Makefile: refactor GIT-VERSION-GEN to be reusable

In reply to Patrick Steinhardt

Our "GIT-VERSION-GEN" script always writes the "GIT-VERSION-FILE" into the current directory, where the expectation is that it should exist in the source directory. But other build systems that support out-of-tree builds may not want to do that to keep the source directory pristine, even though CMake currently doesn't care.

Refactor the script such that it doesn't write output to a file anymore but so that it instead writes the version to stdout. This makes it easier to compute the same version as our Makefile would without having to write the "GIT-VERSION-FILE".

We should ideally refactor our CMake build instructions to stop writing into the source directory. But this step is out of scope of the current patch series.

---
 GIT-VERSION-GEN                     | 12 +-----------
 Makefile                            |  3 ++-
 contrib/buildsystems/CMakeLists.txt |  5 ++++-
 3 files changed, 7 insertions(+), 13 deletions(-)
GIT-VERSION-GEN +1 -11
index b3265f7becb..f2c0f47786b 100755
@@ -1,6 +1,5 @@
 #!/bin/sh
 
-GVF=GIT-VERSION-FILE
 DEF_VER=v2.47.0
 
 LF='
@@ -28,13 +27,4 @@ fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
 
-if test -r $GVF
-then
-	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
-else
-	VC=unset
-fi
-test "$VN" = "$VC" || {
-	echo >&2 "GIT_VERSION = $VN"
-	echo "GIT_VERSION = $VN" >$GVF
-}
+echo "$VN"
Makefile +2 -1
index 50fbc4f29d0..cd28f88e1b3 100644
@@ -592,7 +592,8 @@ include shared.mak
 #        Disable -pedantic compilation.
 
 GIT-VERSION-FILE: FORCE
-	@$(SHELL_PATH) ./GIT-VERSION-GEN
+	@printf "GIT_VERSION = %s\n" $$($(SHELL_PATH) GIT-VERSION-GEN) >$@+
+	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else cat $@+ >&2 && mv $@+ $@; fi
 -include GIT-VERSION-FILE
 
 # Set our default configuration.
contrib/buildsystems/CMakeLists.txt +4 -1
index 1384c0eb6d3..21d6bce26c7 100644
@@ -87,7 +87,10 @@ endif()
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
 	message("Generating GIT-VERSION-FILE")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
-		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+		OUTPUT_VARIABLE GIT_VERSION
+		OUTPUT_STRIP_TRAILING_WHITESPACE)
+	file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "GIT_VERSION = '${GIT_VERSION}'\n")
 endif()
 
 #Parse GIT-VERSION-FILE to get the version
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#58 lore raw

RFC PATCH v2 15/24 Makefile: refactor generators to be PWD-independent

In reply to Patrick Steinhardt

We have multiple scripts that generate headers from other data. All of these scripts have the assumption built-in that they are executed in the current source directory, which makes them a bit unwieldy to use during out-of-tree builds. This makes them a bit unwieldy to use. Refactor them to instead take the source directory as well as the output file as arguments.

---
 Makefile                            |  6 ++---
 contrib/buildsystems/CMakeLists.txt | 12 +++------
 generate-cmdlist.sh                 | 42 ++++++++++++++++++-----------
 generate-configlist.sh              | 20 ++++++++++----
 generate-hooklist.sh                | 15 ++++++++++-
 5 files changed, 61 insertions(+), 34 deletions(-)
Makefile +3 -3
index cd28f88e1b3..0a7d07c9dfb 100644
@@ -2523,17 +2523,17 @@ $(BUILT_INS): git$X
 config-list.h: generate-configlist.sh
 
 config-list.h: Documentation/*config.txt Documentation/config/*.txt
-	$(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh >$@
+	$(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@
 
 command-list.h: generate-cmdlist.sh command-list.txt
 
 command-list.h: $(wildcard Documentation/git*.txt)
 	$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \
 		$(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \
-		command-list.txt >$@
+		. $@
 
 hook-list.h: generate-hooklist.sh Documentation/githooks.txt
-	$(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh >$@
+	$(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh . $@
 
 SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):\
 	$(localedir_SQ):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
contrib/buildsystems/CMakeLists.txt +3 -9
index 21d6bce26c7..330a3f3504a 100644
@@ -655,23 +655,17 @@ set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" F
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
 	list(REMOVE_ITEM EXCLUSION_PROGS empty)
 	message("Generating command-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/command-list.h)
 endif()
 
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
 	message("Generating config-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/config.list)
 endif()
 
 if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h)
 	message("Generating hook-list.h")
-	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h)
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/hook-list.h)
 endif()
 
 include_directories(${CMAKE_BINARY_DIR})
generate-cmdlist.sh +26 -16

58 lines not on this page · raw message

generate-configlist.sh +15 -5
index 8692fe5cf4d..512804a1ca1 100755
@@ -1,13 +1,19 @@
 #!/bin/sh
 
-echo "/* Automatically generated by generate-configlist.sh */"
-echo
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT"
+then
+	echo "USAGE: $0 <SOURCE_DIR> <OUTPUT>" >&2
+	exit 1
+fi
 
 print_config_list () {
 	cat <<EOF
 static const char *config_name_list[] = {
 EOF
-	grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
+	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.txt "$SOURCE_DIR"/Documentation/config/*.txt |
 	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
 	sort |
 	sed 's/^.*$/	"&",/'
@@ -17,5 +23,9 @@ EOF
 EOF
 }
 
-echo
-print_config_list
+{
+	echo "/* Automatically generated by generate-configlist.sh */"
+	echo
+	echo
+	print_config_list
+} >"$OUTPUT"
generate-hooklist.sh +14 -1
index 2f9f54eb545..0ff2a0b6fbd 100755
@@ -2,6 +2,17 @@
 #
 # Usage: ./generate-hooklist.sh >hook-list.h
 
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT"
+then
+	echo "USAGE: $0 <SOURCE_DIR> <OUTPUT>" >&2
+	exit 1
+fi
+
+{
+
 cat <<EOF
 /* Automatically generated by generate-hooklist.sh */
 
@@ -11,10 +22,12 @@ EOF
 sed -n \
 	-e '/^~~~~*$/ {x; s/^.*$/	"&",/; p;}' \
 	-e 'x' \
-	<Documentation/githooks.txt |
+	<"$SOURCE_DIR"/Documentation/githooks.txt |
 	LC_ALL=C sort
 
 cat <<EOF
 	NULL,
 };
 EOF
+
+} >"$OUTPUT"
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#59 lore raw

RFC PATCH v2 16/24 Makefile: use common template for GIT-BUILD-OPTIONS

In reply to Patrick Steinhardt

The "GIT-BUILD-OPTIONS" file is generated by our build systems to propagate built-in features and paths to our tests. The generation is done ad-hoc, where both our Makefile and the CMake build instructions simply echo a bunch of strings into the file. This makes it very hard to figure out what variables are expected to exist and what format they have, and the written variables can easily get out of sync between build systems.

Introduce a new "GIT-BUILD-OPTIONS.in" template to address this issue. This has multiple advantages:

- It demonstrates which built options exist in the first place.

- It can serve as a spot to document the build options.

- Some build systems complain when not all variables could be substituted, alerting us of mismatches. Others don't, but if we forgot to substitute such variables we now have a bogus string that will likely cause our tests to fail, if they have any meaning in the first place.

Backfill values that we didn't yet set in our CMake build instructions. While at it, remove the SUPPORTS_SIMPLE_IPC variable that we only set up in CMake as it isn't used anywhere.

Note that this change requires us to move around the setup of TEST_OUTPUT_DIRECTORY in "test-lib.sh" such that it comes after sourcing the "GIT-BUILD-OPTIONS" file. This is the only instance I could find where we rely on ordering on variables.

---
 GIT-BUILD-OPTIONS.in                |  36 ++++++++++
 Makefile                            | 108 ++++++++++------------------
 contrib/buildsystems/CMakeLists.txt |  58 ++++++++++-----
 t/test-lib.sh                       |  13 ++--
 4 files changed, 120 insertions(+), 95 deletions(-)
 create mode 100644 GIT-BUILD-OPTIONS.in
GIT-BUILD-OPTIONS.in new file +36 -0
new file mode 100644
index 00000000000..f0ca240493c
@@ -0,0 +1,36 @@
+SHELL_PATH=@SHELL_PATH@
+TEST_SHELL_PATH=@TEST_SHELL_PATH@
+PERL_PATH=@PERL_PATH@
+DIFF=@DIFF@
+PYTHON_PATH=@PYTHON_PATH@
+TAR=@TAR@
+NO_CURL=@NO_CURL@
+NO_ICONV=@NO_ICONV@
+NO_EXPAT=@NO_EXPAT@
+USE_LIBPCRE2=@USE_LIBPCRE2@
+NO_PERL=@NO_PERL@
+NO_PTHREADS=@NO_PTHREADS@
+NO_PYTHON=@NO_PYTHON@
+NO_REGEX=@NO_REGEX@
+NO_UNIX_SOCKETS=@NO_UNIX_SOCKETS@
+PAGER_ENV=@PAGER_ENV@
+SANITIZE_LEAK=@SANITIZE_LEAK@
+SANITIZE_ADDRESS=@SANITIZE_ADDRESS@
+X=@X@
+FSMONITOR_DAEMON_BACKEND=@FSMONITOR_DAEMON_BACKEND@
+FSMONITOR_OS_SETTINGS=@FSMONITOR_OS_SETTINGS@
+TEST_OUTPUT_DIRECTORY=@TEST_OUTPUT_DIRECTORY@
+GIT_TEST_OPTS=@GIT_TEST_OPTS@
+GIT_TEST_CMP=@GIT_TEST_CMP@
+GIT_TEST_CMP_USE_COPIED_CONTEXT=@GIT_TEST_CMP_USE_COPIED_CONTEXT@
+GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@
+NO_GETTEXT=@NO_GETTEXT@
+GIT_PERF_REPEAT_COUNT=@GIT_PERF_REPEAT_COUNT@
+GIT_PERF_REPO=@GIT_PERF_REPO@
+GIT_PERF_LARGE_REPO=@GIT_PERF_LARGE_REPO@
+GIT_PERF_MAKE_OPTS=@GIT_PERF_MAKE_OPTS@
+GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
+GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
+GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
+GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
+RUNTIME_PREFIX=@RUNTIME_PREFIX@
Makefile +38 -70

114 lines not on this page · raw message

contrib/buildsystems/CMakeLists.txt +39 -19

66 lines not on this page · raw message

t/test-lib.sh +7 -6
index a278181a056..4dd641baefe 100644
@@ -35,12 +35,6 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
-if test -z "$TEST_OUTPUT_DIRECTORY"
-then
-	# Similarly, override this to store the test-results subdir
-	# elsewhere
-	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
-fi
 GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
 then
@@ -100,6 +94,13 @@ fi
 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
 export PERL_PATH SHELL_PATH
 
+if test -z "$TEST_OUTPUT_DIRECTORY"
+then
+	# Similarly, override this to store the test-results subdir
+	# elsewhere
+	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
+fi
+
 # In t0000, we need to override test directories of nested testcases. In case
 # the developer has TEST_OUTPUT_DIRECTORY part of his build options, then we'd
 # reset this value to instead contain what the developer has specified. We thus
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#60 lore raw

RFC PATCH v2 17/24 Makefile: consistently use @PLACEHOLDER@ to substitute

In reply to Patrick Steinhardt

We have a bunch of placeholders in our scripts that we replace at build time, for example by using sed(1). These placeholders come in three different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Next to being inconsistent it also creates a bit of a problem with CMake, which only supports the first syntax in its configure_file() function. To work around that we instead manually replace placeholders via string operations, which is a hassle and removes safeguards that CMake has to verify that we didn't forget to replace any placeholders. Besides that, other build systems like Meson also support the CMake syntax.

Unify our codebase to consistently use the syntax supported by such build systems.

---
 Makefile                                      | 42 +++++++++---------
 configure.ac                                  |  2 +-
 contrib/buildsystems/CMakeLists.txt           | 34 +++++++-------
 generate-perl.sh                              |  2 +-
 git-cvsserver.perl                            |  2 +-
 git-instaweb.sh                               |  8 ++--
 git-request-pull.sh                           |  2 +-
 git-send-email.perl                           |  2 +-
 git-sh-i18n.sh                                |  6 +--
 git-sh-setup.sh                               |  6 +--
 git-svn.perl                                  |  2 +-
 gitk-git/po/vi.po                             |  2 +-
 gitweb/Makefile                               | 44 +++++++++----------
 gitweb/gitweb.perl                            | 44 +++++++++----------
 perl/Git/I18N.pm                              |  6 +--
 perl/Git/LoadCPAN.pm                          |  6 +--
 .../header_templates/fixed_prefix.template.pl |  2 +-
 .../runtime_prefix.template.pl                |  8 ++--
 unimplemented.sh                              |  2 +-
 wrap-for-bin.sh                               | 18 ++++----
 20 files changed, 120 insertions(+), 120 deletions(-)
Makefile +21 -21
index 3079822da40..9f710a7cba9 100644
@@ -1556,10 +1556,10 @@ endif
 
 ifdef SANE_TOOL_PATH
 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
-BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
+BROKEN_PATH_FIX = 's|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
 PATH := $(SANE_TOOL_PATH):${PATH}
 else
-BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
+BROKEN_PATH_FIX = '/^\# @BROKEN_PATH_FIX@$$/d'
 endif
 
 ifeq (,$(HOST_CPU))
@@ -2549,13 +2549,13 @@ GIT-SCRIPT-DEFINES: FORCE
 define cmd_munge_script
 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
-    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
-    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
+    -e 's|@DIFF@|$(DIFF_SQ)|' \
+    -e 's|@LOCALEDIR@|$(localedir_SQ)|g' \
+    -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
-    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-    -e 's|@@PAGER_ENV@@|$(PAGER_ENV_SQ)|g' \
+    -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
+    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
 
@@ -2622,11 +2622,11 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
 	INSTLIBDIR='$(perllibdir_SQ)' && \
 	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
 	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
-	sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
-	    -e "s=@@INSTLIBDIR@@=$$INSTLIBDIR=g" \
-	    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
-	    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
-	    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
+	sed -e 's=@PATHSEP@=$(pathsep)=g' \
+	    -e "s=@INSTLIBDIR@=$$INSTLIBDIR=g" \
+	    -e 's=@PERLLIBDIR_REL@=$(perllibdir_relative_SQ)=g' \
+	    -e 's=@GITEXECDIR_REL@=$(gitexecdir_relative_SQ)=g' \
+	    -e 's=@LOCALEDIR_REL@=$(localedir_relative_SQ)=g' \
 	    $< >$@+ && \
 	mv $@+ $@
 
@@ -2642,7 +2642,7 @@ else # NO_PERL
 $(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
+	    -e 's|@REASON@|NO_PERL=$(NO_PERL)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -2663,13 +2663,13 @@ else # NO_PYTHON
 $(SCRIPT_PYTHON_GEN): % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
+	    -e 's|@REASON@|NO_PYTHON=$(NO_PYTHON)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 endif # NO_PYTHON
 
-CONFIGURE_RECIPE = sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+CONFIGURE_RECIPE = sed -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
 			configure.ac >configure.ac+ && \
 		   autoconf -o configure configure.ac+ && \
 		   $(RM) configure.ac+
@@ -3098,9 +3098,9 @@ endif
 perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN) \
-	sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
-	    -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \
-	    -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
+	sed -e 's|@LOCALEDIR@|$(perl_localedir_SQ)|g' \
+	    -e 's|@NO_GETTEXT@|$(NO_GETTEXT_SQ)|g' \
+	    -e 's|@NO_PERL_CPAN_FALLBACKS@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
 	< $< > $@
 
 perl/build/man/man3/Git.3pm: perl/Git.pm
@@ -3218,8 +3218,8 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
 bin-wrappers/%: wrap-for-bin.sh
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	     -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-	     -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
+	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
 	chmod +x $@
 
 # GNU make supports exporting all variables by "export" without parameters.
configure.ac +1 -1
index d1a96da14eb..5923edc44aa 100644
@@ -142,7 +142,7 @@ fi
 ## Configure body starts here.
 
 AC_PREREQ(2.59)
-AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
+AC_INIT([git], [@GIT_VERSION@], [[email protected]])
 
 AC_CONFIG_SRCDIR([git.c])
 
contrib/buildsystems/CMakeLists.txt +17 -17
index 842879976a2..73008bf2d18 100644
@@ -833,14 +833,14 @@ set(git_shell_scripts
 foreach(script ${git_shell_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
 	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
-	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@DIFF@" "diff" content "${content}")
 	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
 	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
-	string(REPLACE "@@NO_CURL@@" "" content "${content}")
-	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
-	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
-	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	string(REPLACE "@NO_CURL@" "" content "${content}")
+	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
+	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
+	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -849,13 +849,13 @@ parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
-string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
-string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
+string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
 
 foreach(script ${git_perl_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
 	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
-	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -870,8 +870,8 @@ file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
 foreach(pm ${perl_modules})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
 	file(STRINGS ${pm} content NEWLINE_CONSUME)
-	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
 #test-lib.sh requires perl/build/lib to be the build directory of perl modules
 endforeach()
@@ -1079,21 +1079,21 @@ set(wrapper_test_scripts
 
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
 #options for configuring test options
generate-perl.sh +1 -1
index b9e04d6f42a..41d78da029b 100755
@@ -17,6 +17,6 @@ sed -e '1{' \
     -e "	r $PERL_HEADER" \
     -e '	G' \
     -e '}' \
-    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
+    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
     "$PERL_SCRIPT" >"$OUT"
 chmod a+x "$OUT"
git-cvsserver.perl +1 -1
index 124f598bdc0..70ae7cb8e45 100755
@@ -26,7 +26,7 @@
 use File::Basename;
 use Getopt::Long qw(:config require_order no_ignore_case);
 
-my $VERSION = '@@GIT_VERSION@@';
+my $VERSION = '@GIT_VERSION@';
 
 my $log = GITCVS::log->new();
 my $cfg;
git-instaweb.sh +4 -4
index 8dbe21d5887..c8efb1205a8 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@@PERL@@'
+PERL='@PERL@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -38,8 +38,8 @@ conf="$GIT_DIR/gitweb/httpd.conf"
 # if installed, it doesn't need further configuration (module_path)
 test -z "$httpd" && httpd='lighttpd -f'
 
-# Default is @@GITWEBDIR@@
-test -z "$root" && root='@@GITWEBDIR@@'
+# Default is @GITWEBDIR@
+test -z "$root" && root='@GITWEBDIR@'
 
 # any untaken local port will do...
 test -z "$port" && port=1234
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@@PERL@@
+#!@PERL@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 01640a044bb..10c88639e28 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
git-send-email.perl +1 -1
index c835d4c11af..02805c43e52 100755
@@ -1501,7 +1501,7 @@ sub gen_header {
 	@recipients = unique_email_list(@recipients,@cc,@initial_bcc);
 	@recipients = (map { extract_valid_address_or_die($_) } @recipients);
 	my $date = format_2822_time($time++);
-	my $gitversion = '@@GIT_VERSION@@';
+	my $gitversion = '@GIT_VERSION@';
 	if ($gitversion =~ m/..GIT_VERSION../) {
 	    $gitversion = Git::version();
 	}
git-sh-i18n.sh +3 -3
index a15c0620db6..ae4b2d6ba9d 100644
@@ -9,7 +9,7 @@ TEXTDOMAIN=git
 export TEXTDOMAIN
 if test -z "$GIT_TEXTDOMAINDIR"
 then
-	TEXTDOMAINDIR="@@LOCALEDIR@@"
+	TEXTDOMAINDIR="@LOCALEDIR@"
 else
 	TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
 fi
@@ -17,9 +17,9 @@ export TEXTDOMAINDIR
 
 # First decide what scheme to use...
 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
-if test -n "@@USE_GETTEXT_SCHEME@@"
+if test -n "@USE_GETTEXT_SCHEME@"
 then
-	GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
+	GIT_INTERNAL_GETTEXT_SH_SCHEME="@USE_GETTEXT_SCHEME@"
 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
 then
 	: no probing necessary
git-sh-setup.sh +3 -3
index ce273fe0e48..19aef72ec25 100644
@@ -41,7 +41,7 @@ git_broken_path_fix () {
 	esac
 }
 
-# @@BROKEN_PATH_FIX@@
+# @BROKEN_PATH_FIX@
 
 # Source git-sh-i18n for gettext support.
 . "$(git --exec-path)/git-sh-i18n"
@@ -154,7 +154,7 @@ git_pager() {
 	else
 		GIT_PAGER=cat
 	fi
-	for vardef in @@PAGER_ENV@@
+	for vardef in @PAGER_ENV@
 	do
 		var=${vardef%%=*}
 		eval ": \"\${$vardef}\" && export $var"
@@ -280,7 +280,7 @@ get_author_ident_from_commit () {
 # remove lines from $1 that are not in $2, leaving only common lines.
 create_virtual_base() {
 	sz0=$(wc -c <"$1")
-	@@DIFF@@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
+	@DIFF@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
 	sz1=$(wc -c <"$1")
 
 	# If we do not have enough common material, it is not
git-svn.perl +1 -1
index 01e7a70de1c..dcf65cf1d1d 100755
@@ -9,7 +9,7 @@
 		$_revision $_repository
 		$_q $_authors $_authors_prog %users/;
 $AUTHOR = 'Eric Wong <[email protected]>';
-$VERSION = '@@GIT_VERSION@@';
+$VERSION = '@GIT_VERSION@';
 
 use Carp qw/croak/;
 use File::Basename qw/dirname basename/;
gitk-git/po/vi.po +1 -1
index 59674986604..184430dcdee 100644
@@ -5,7 +5,7 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: gitk @@GIT_VERSION@@\n"
+"Project-Id-Version: gitk @GIT_VERSION@\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2015-05-17 14:32+1000\n"
 "PO-Revision-Date: 2015-09-15 07:33+0700\n"
gitweb/Makefile +22 -22

50 lines not on this page · raw message

gitweb/gitweb.perl +22 -22

116 lines not on this page · raw message

perl/Git/I18N.pm +3 -3
index 475e90a6df5..f8f0ca31254 100644
@@ -20,14 +20,14 @@ BEGIN
 # this "'@@' [...] '@@'" pattern.
 use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
 use constant NO_GETTEXT => (
-	q[@@NO_GETTEXT@@] ne ''
+	q[@NO_GETTEXT@] ne ''
 	and
-	q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
+	q[@NO_GETTEXT@] ne NO_GETTEXT_STR
 );
 
 sub __bootstrap_locale_messages {
 	our $TEXTDOMAIN = 'git';
-	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@LOCALEDIR@';
 	die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
 
 	require POSIX;
perl/Git/LoadCPAN.pm +3 -3
index 8c7fa805f97..6be99840f84 100644
@@ -31,11 +31,11 @@ =head1 DESCRIPTION
 # Makefile, and allows for detecting whether the module is loaded from
 # perl/Git as opposed to perl/build/Git, which is useful for one-off
 # testing without having Error.pm et al installed.
-use constant NO_PERL_CPAN_FALLBACKS_STR => '@@' . 'NO_PERL_CPAN_FALLBACKS' . '@@';
+use constant NO_PERL_CPAN_FALLBACKS_STR => '@' . 'NO_PERL_CPAN_FALLBACKS' . '@';
 use constant NO_PERL_CPAN_FALLBACKS => (
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne ''
+	q[@NO_PERL_CPAN_FALLBACKS@] ne ''
 	and
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne NO_PERL_CPAN_FALLBACKS_STR
+	q[@NO_PERL_CPAN_FALLBACKS@] ne NO_PERL_CPAN_FALLBACKS_STR
 );
 
 sub import {
perl/header_templates/fixed_prefix.template.pl +1 -1
index 857b4391a49..d571ca5cde5 100644
@@ -1 +1 @@
-use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || '@@INSTLIBDIR@@'));
+use lib (split(/@PATHSEP@/, $ENV{GITPERLLIB} || '@INSTLIBDIR@'));
perl/header_templates/runtime_prefix.template.pl +4 -4
index 9d28b3d8636..e6f8e661a16 100644
@@ -3,7 +3,7 @@
 # This finds our Git::* libraries relative to the script's runtime path.
 sub __git_system_path {
 	my ($relpath) = @_;
-	my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
+	my $gitexecdir_relative = '@GITEXECDIR_REL@';
 
 	# GIT_EXEC_PATH is supplied by `git` or the test suite.
 	my $exec_path;
@@ -24,11 +24,11 @@ sub __git_system_path {
 }
 
 BEGIN {
-	use lib split /@@PATHSEP@@/,
+	use lib split /@PATHSEP@/,
 	(
 		$ENV{GITPERLLIB} ||
 		do {
-			my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
+			my $perllibdir = __git_system_path('@PERLLIBDIR_REL@');
 			(-e $perllibdir) || die("Invalid system path ($relpath): $path");
 			$perllibdir;
 		}
@@ -36,7 +36,7 @@ BEGIN
 
 	# Export the system locale directory to the I18N module. The locale directory
 	# is only installed if NO_GETTEXT is set.
-	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
+	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@LOCALEDIR_REL@');
 }
 
 # END RUNTIME_PREFIX generated code.
unimplemented.sh +1 -1
index fee21d24e8a..41776b279d4 100644
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-echo >&2 "fatal: git was built without support for $(basename $0) (@@REASON@@)."
+echo >&2 "fatal: git was built without support for $(basename $0) (@REASON@)."
 exit 128
wrap-for-bin.sh +9 -9
index 95851b85b6b..7898a1c238d 100644
@@ -4,33 +4,33 @@
 # to run test suite against sandbox, but with only bindir-installed
 # executables in PATH.  The Makefile copies this into various
 # files in bin-wrappers, substituting
-# @@BUILD_DIR@@ and @@PROG@@.
+# @BUILD_DIR@ and @PROG@.
 
-GIT_EXEC_PATH='@@BUILD_DIR@@'
+GIT_EXEC_PATH='@BUILD_DIR@'
 if test -n "$NO_SET_GIT_TEMPLATE_DIR"
 then
 	unset GIT_TEMPLATE_DIR
 else
-	GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
+	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
 	export GIT_TEMPLATE_DIR
 fi
-GITPERLLIB='@@BUILD_DIR@@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
-PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
+GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
 export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
 case "$GIT_DEBUGGER" in
 '')
-	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 1)
 	unset GIT_DEBUGGER
-	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec gdb --args "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 *)
 	GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
 	unset GIT_DEBUGGER
-	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 esac
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#61 lore raw

RFC PATCH v2 18/24 Makefile: consistently use PERL_PATH

In reply to Patrick Steinhardt

When injecting the Perl path into our scripts we sometimes use '@PERL@' while we othertimes use '@PERL_PATH@'. Refactor the code use the latter consistently, which makes it easier to reuse the same logic for multiple scripts.

---
 Makefile                            | 2 +-
 contrib/buildsystems/CMakeLists.txt | 2 +-
 git-instaweb.sh                     | 4 ++--
 git-request-pull.sh                 | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
Makefile +1 -1
index 9f710a7cba9..46327596275 100644
@@ -2554,7 +2554,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
     -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
-    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' \
     -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
contrib/buildsystems/CMakeLists.txt +1 -1
index 73008bf2d18..d63c9078345 100644
@@ -839,7 +839,7 @@ foreach(script ${git_shell_scripts})
 	string(REPLACE "@NO_CURL@" "" content "${content}")
 	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
 	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
-	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PERL_PATH@" "${PERL_PATH}" content "${content}")
 	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
git-instaweb.sh +2 -2
index c8efb1205a8..5ad50160bb0 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@PERL@'
+PERL='@PERL_PATH@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@PERL@
+#!@PERL_PATH@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 10c88639e28..775ba8ea11a 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL_PATH@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#62 lore raw

RFC PATCH v2 19/24 Makefile: allow "bin-wrappers/" directory to exist

In reply to Patrick Steinhardt

The "bin-wrappers/" directory gets created by our build system and is populated with one script for each of our binaries. There isn't anything inherently wrong with the current layout, but it is somewhat hard to adapt for out-of-tree build systems.

Adapt the layout such that our "bin-wrappers/" directory always exists and contains our "wrap-for-bin.sh" script to make things a little bit easier for subsequent steps.

---
 .gitignore                                      | 1 -
 Documentation/CodingGuidelines                  | 2 +-
 Makefile                                        | 6 +++---
 bin-wrappers/.gitignore                         | 9 +++++++++
 wrap-for-bin.sh => bin-wrappers/wrap-for-bin.sh | 0
 contrib/buildsystems/CMakeLists.txt             | 6 +++---
 6 files changed, 16 insertions(+), 8 deletions(-)
 create mode 100644 bin-wrappers/.gitignore
 rename wrap-for-bin.sh => bin-wrappers/wrap-for-bin.sh (100%)
 mode change 100644 => 100755
.gitignore +0 -1
index 6687bd6db4c..349673c55c9 100644
@@ -12,7 +12,6 @@
 /GIT-TEST-SUITES
 /GIT-USER-AGENT
 /GIT-VERSION-FILE
-/bin-wrappers/
 /git
 /git-add
 /git-am
Documentation/CodingGuidelines +1 -1
index 3263245b032..ad831567444 100644
@@ -583,7 +583,7 @@ For C programs:
    Run `GIT_DEBUGGER=1 ./bin-wrappers/git foo` to simply use gdb as is, or
    run `GIT_DEBUGGER="<debugger> <debugger-args>" ./bin-wrappers/git foo` to
    use your own debugger and arguments. Example: `GIT_DEBUGGER="ddd --gdb"
-   ./bin-wrappers/git log` (See `wrap-for-bin.sh`.)
+   ./bin-wrappers/git log` (See `bin-wrappers/wrap-for-bin.sh`.)
 
  - The primary data structure that a subsystem 'S' deals with is called
    `struct S`. Functions that operate on `struct S` are named
Makefile +3 -3
index 46327596275..554d8ea83b2 100644
@@ -3215,8 +3215,7 @@ test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PROG)
 
-bin-wrappers/%: wrap-for-bin.sh
-	$(call mkdir_p_parent_template)
+bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
 	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
@@ -3712,7 +3711,8 @@ clean: profile-clean coverage-clean cocciclean
 	$(RM) $(FUZZ_PROGRAMS)
 	$(RM) $(SP_OBJ)
 	$(RM) $(HCC)
-	$(RM) -r bin-wrappers $(dep_dirs) $(compdb_dir) compile_commands.json
+	$(RM) -r $(dep_dirs) $(compdb_dir) compile_commands.json
+	$(RM) $(test_bindir_programs)
 	$(RM) -r po/build/
 	$(RM) *.pyc *.pyo */*.pyc */*.pyo $(GENERATED_H) $(ETAGS_TARGET) tags cscope*
 	$(RM) -r .dist-tmp-dir .doc-tmp-dir
bin-wrappers/.gitignore new file +9 -0
new file mode 100644
index 00000000000..1c6c90458b7
@@ -0,0 +1,9 @@
+/git
+/git-cvsserver
+/git-receive-pack
+/git-shell
+/git-upload-archive
+/git-upload-pack
+/scalar
+/test-fake-ssh
+/test-tool
bin-wrappers/wrap-for-bin.sh renamed from wrap-for-bin.sh +0 -0
old mode 100644
new mode 100755
similarity index 100%
rename from wrap-for-bin.sh
rename to bin-wrappers/wrap-for-bin.sh
contrib/buildsystems/CMakeLists.txt +3 -3
index d63c9078345..e32ce8ce8b7 100644
@@ -1078,20 +1078,20 @@ set(wrapper_test_scripts
 
 
 foreach(script ${wrapper_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
-file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
 string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#63 lore raw

RFC PATCH v2 20/24 Makefile: simplify building of templates

In reply to Patrick Steinhardt

When we install Git we also install a set of default templates that both git-init(1) and git-clone(1) populate into our build directories. The way the pristine templates are layed out in our source directory is somewhat weird though: instead of reconstructing the actual directory hierarchy in "templates/", we represent directory separators with "--".

The only reason I could come up with for why we have this is the "branches/" directory, which is supposed to be empty when installing it. And as Git famously doesn't store empty directories at all we have to work around this limitation.

Now the thing is that the "branches/" directory is a leftover to how branches used to be stored in the dark ages. gitrepository-layout(5) lists this directory as "slightly deprecated", which I would claim is a strong understatement. I have never encountered anybody using it today and would be surprised if it even works as expected. So having the "--" hack in place for an item that is basically unused, unmaintained and deprecated doesn't only feel unreasonable, but installing that entry by default may also cause confusion for users that do not know what this is supposed to be in the first place.

Remove this directory from our templates and, now that we do not require the workaround anymore, restructure the templates to form a proper hierarchy. This makes it way easier for build systems to install these templates into place.

We should likely think about removing support for "branch/" altogether, but that is outside of the scope of this patch series.

---
 contrib/buildsystems/CMakeLists.txt           |  8 +---
 templates/Makefile                            | 38 ++++++++++++-------
 templates/branches--                          |  1 -
 templates/{this--description => description}  |  0
 .../applypatch-msg.sample}                    |  0
 .../commit-msg.sample}                        |  0
 .../fsmonitor-watchman.sample}                |  0
 .../post-update.sample}                       |  0
 .../pre-applypatch.sample}                    |  0
 .../pre-commit.sample}                        |  0
 .../pre-merge-commit.sample}                  |  0
 .../pre-push.sample}                          |  0
 .../pre-rebase.sample}                        |  0
 .../pre-receive.sample}                       |  0
 .../prepare-commit-msg.sample}                |  0
 .../push-to-checkout.sample}                  |  0
 .../sendemail-validate.sample}                |  0
 .../update.sample}                            |  0
 templates/{info--exclude => info/exclude}     |  0
 19 files changed, 25 insertions(+), 22 deletions(-)
 delete mode 100644 templates/branches--
 rename templates/{this--description => description} (100%)
 rename templates/{hooks--applypatch-msg.sample => hooks/applypatch-msg.sample} (100%)
 rename templates/{hooks--commit-msg.sample => hooks/commit-msg.sample} (100%)
 rename templates/{hooks--fsmonitor-watchman.sample => hooks/fsmonitor-watchman.sample} (100%)
 rename templates/{hooks--post-update.sample => hooks/post-update.sample} (100%)
 rename templates/{hooks--pre-applypatch.sample => hooks/pre-applypatch.sample} (100%)
 rename templates/{hooks--pre-commit.sample => hooks/pre-commit.sample} (100%)
 rename templates/{hooks--pre-merge-commit.sample => hooks/pre-merge-commit.sample} (100%)
 rename templates/{hooks--pre-push.sample => hooks/pre-push.sample} (100%)
 rename templates/{hooks--pre-rebase.sample => hooks/pre-rebase.sample} (100%)
 rename templates/{hooks--pre-receive.sample => hooks/pre-receive.sample} (100%)
 rename templates/{hooks--prepare-commit-msg.sample => hooks/prepare-commit-msg.sample} (100%)
 rename templates/{hooks--push-to-checkout.sample => hooks/push-to-checkout.sample} (100%)
 rename templates/{hooks--sendemail-validate.sample => hooks/sendemail-validate.sample} (100%)
 rename templates/{hooks--update.sample => hooks/update.sample} (100%)
 rename templates/{info--exclude => info/exclude} (100%)
contrib/buildsystems/CMakeLists.txt +1 -7
index e32ce8ce8b7..b95287468cd 100644
@@ -878,23 +878,17 @@ endforeach()
 
 
 #templates
-file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
+file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/**")
 list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
 list(REMOVE_ITEM templates ".gitignore")
 list(REMOVE_ITEM templates "Makefile")
 list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
 
-list(REMOVE_ITEM templates "branches--")
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
-
 #templates have @.*@ replacement so use configure_file instead
 foreach(tm ${templates})
-	string(REPLACE "--" "/" blt_tm ${tm})
-	string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
 	configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
 endforeach()
 
-
 #translations
 if(MSGFMT_EXE)
 	file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
templates/Makefile +24 -14
index 367ad00c24c..0b91d189257 100644
@@ -29,24 +29,34 @@ all: boilerplates.made custom
 # in a file direc--tory--file in the source.  They will be
 # just copied to the destination.
 
-bpsrc = $(filter-out %~,$(wildcard *--*))
-boilerplates.made : $(bpsrc)
-	$(QUIET)umask 022 && ls *--* 2>/dev/null | \
-	while read boilerplate; \
+TEMPLATES  = description
+TEMPLATES += hooks/applypatch-msg.sample
+TEMPLATES += hooks/commit-msg.sample
+TEMPLATES += hooks/fsmonitor-watchman.sample
+TEMPLATES += hooks/post-update.sample
+TEMPLATES += hooks/pre-applypatch.sample
+TEMPLATES += hooks/pre-commit.sample
+TEMPLATES += hooks/pre-merge-commit.sample
+TEMPLATES += hooks/prepare-commit-msg.sample
+TEMPLATES += hooks/pre-push.sample
+TEMPLATES += hooks/pre-rebase.sample
+TEMPLATES += hooks/pre-receive.sample
+TEMPLATES += hooks/push-to-checkout.sample
+TEMPLATES += hooks/sendemail-validate.sample
+TEMPLATES += hooks/update.sample
+TEMPLATES += info/exclude
+
+boilerplates.made: $(TEMPLATES)
+	$(QUIET)umask 022 && for template in $(TEMPLATES); \
 	do \
-		case "$$boilerplate" in *~) continue ;; esac && \
-		dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
-		dir=`expr "$$dst" : '\(.*\)/'` && \
+		dir=$$(dirname "$$template") && \
 		mkdir -p blt/$$dir && \
-		case "$$boilerplate" in \
-		*--) continue;; \
-		esac && \
 		sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 		    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-		    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
-			blt/$$dst && \
-		if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
-		chmod a+$$rx "blt/$$dst" || exit; \
+		    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$template > \
+			blt/$$template && \
+		if test -x "$$template"; then rx=rx; else rx=r; fi && \
+		chmod a+$$rx "blt/$$template" || exit; \
 	done && \
 	date >$@
 
templates/branches-- deleted +0 -1
deleted file mode 100644
index fae88709a63..00000000000
@@ -1 +0,0 @@
-: this is just to ensure the directory exists.
templates/description renamed from templates/this--description +0 -0
similarity index 100%
rename from templates/this--description
rename to templates/description
templates/hooks/applypatch-msg.sample renamed from templates/hooks--applypatch-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--applypatch-msg.sample
rename to templates/hooks/applypatch-msg.sample
templates/hooks/commit-msg.sample renamed from templates/hooks--commit-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--commit-msg.sample
rename to templates/hooks/commit-msg.sample
templates/hooks/fsmonitor-watchman.sample renamed from templates/hooks--fsmonitor-watchman.sample +0 -0
similarity index 100%
rename from templates/hooks--fsmonitor-watchman.sample
rename to templates/hooks/fsmonitor-watchman.sample
templates/hooks/post-update.sample renamed from templates/hooks--post-update.sample +0 -0
similarity index 100%
rename from templates/hooks--post-update.sample
rename to templates/hooks/post-update.sample
templates/hooks/pre-applypatch.sample renamed from templates/hooks--pre-applypatch.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-applypatch.sample
rename to templates/hooks/pre-applypatch.sample
templates/hooks/pre-commit.sample renamed from templates/hooks--pre-commit.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-commit.sample
rename to templates/hooks/pre-commit.sample
templates/hooks/pre-merge-commit.sample renamed from templates/hooks--pre-merge-commit.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-merge-commit.sample
rename to templates/hooks/pre-merge-commit.sample
templates/hooks/pre-push.sample renamed from templates/hooks--pre-push.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-push.sample
rename to templates/hooks/pre-push.sample
templates/hooks/pre-rebase.sample renamed from templates/hooks--pre-rebase.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-rebase.sample
rename to templates/hooks/pre-rebase.sample
templates/hooks/pre-receive.sample renamed from templates/hooks--pre-receive.sample +0 -0
similarity index 100%
rename from templates/hooks--pre-receive.sample
rename to templates/hooks/pre-receive.sample
templates/hooks/prepare-commit-msg.sample renamed from templates/hooks--prepare-commit-msg.sample +0 -0
similarity index 100%
rename from templates/hooks--prepare-commit-msg.sample
rename to templates/hooks/prepare-commit-msg.sample
templates/hooks/push-to-checkout.sample renamed from templates/hooks--push-to-checkout.sample +0 -0
similarity index 100%
rename from templates/hooks--push-to-checkout.sample
rename to templates/hooks/push-to-checkout.sample
templates/hooks/sendemail-validate.sample renamed from templates/hooks--sendemail-validate.sample +0 -0
similarity index 100%
rename from templates/hooks--sendemail-validate.sample
rename to templates/hooks/sendemail-validate.sample
templates/hooks/update.sample renamed from templates/hooks--update.sample +0 -0
similarity index 100%
rename from templates/hooks--update.sample
rename to templates/hooks/update.sample
templates/info/exclude renamed from templates/info--exclude +0 -0
similarity index 100%
rename from templates/info--exclude
rename to templates/info/exclude
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#64 lore raw

RFC PATCH v2 21/24 t: better support for out-of-tree builds

In reply to Patrick Steinhardt

Our in-tree builds used by the Makefile use various different build directories scattered around different locations. The paths to those build directories have to be propagated to our tests such that they can find the contained files. This is done via a mixture of hardcoded paths in our test library and injected variables in our bin-wrappers or "GIT-BUILD-OPTIONS".

The latter two mechanisms are preferable over using hardcoded paths. For one, we have all paths which are subject to change stored in a small set of central files instead of having the knowledge of build paths in many files. And second, it allows build systems which build files elsewhere to adapt those paths based on their own needs. This is especially nice in the context of build systems that use out-of-tree builds like CMake or Meson.

Remove hardcoded knowledge of build paths from our test library and move it into our bin-wrappers and "GIT-BUILD-OPTIONS".

---
 GIT-BUILD-OPTIONS.in                |  5 +++++
 Makefile                            |  9 +++++++++
 bin-wrappers/wrap-for-bin.sh        | 11 ++++++-----
 contrib/buildsystems/CMakeLists.txt |  8 ++++++++
 t/lib-gettext.sh                    |  4 ++--
 t/t7609-mergetool--lib.sh           |  2 +-
 t/test-lib.sh                       |  6 +++---
 7 files changed, 34 insertions(+), 11 deletions(-)
GIT-BUILD-OPTIONS.in +5 -0
index f0ca240493c..cce06577840 100644
@@ -33,4 +33,9 @@ GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
 GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
 GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
 GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
+GIT_TEST_TEXTDOMAINDIR=@GIT_TEST_TEXTDOMAINDIR@
+GIT_TEST_POPATH=@GIT_TEST_POPATH@
+GIT_TEST_TEMPLATE_DIR=@GIT_TEST_TEMPLATE_DIR@
+GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
+GIT_TEST_MERGE_TOOLS_DIR=@GIT_TEST_MERGE_TOOLS_DIR@
 RUNTIME_PREFIX=@RUNTIME_PREFIX@
Makefile +9 -0
index 554d8ea83b2..7764d3e284c 100644
@@ -3194,6 +3194,11 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@GIT_INTEROP_MAKE_OPTS@|\'$(GIT_INTEROP_MAKE_OPTS)\'|" \
 		-e "s|@GIT_TEST_INDEX_VERSION@|\'$(GIT_TEST_INDEX_VERSION)\'|" \
 		-e "s|@GIT_TEST_PERL_FATAL_WARNINGS@|\'$(GIT_TEST_PERL_FATAL_WARNINGS)\'|" \
+		-e "s|@GIT_TEST_TEXTDOMAINDIR@|\'$(shell pwd)/po/build/locale\'|" \
+		-e "s|@GIT_TEST_POPATH@|\'$(shell pwd)/po\'|" \
+		-e "s|@GIT_TEST_TEMPLATE_DIR@|\'$(shell pwd)/templates/blt\'|" \
+		-e "s|@GIT_TEST_GITPERLLIB@|\'$(shell pwd)/perl/build/lib\'|" \
+		-e "s|@GIT_TEST_MERGE_TOOLS_DIR@|\'$(shell pwd)/mergetools\'|" \
 		-e "s|@RUNTIME_PREFIX@|\'$(RUNTIME_PREFIX)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
@@ -3218,6 +3223,10 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
 bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@GIT_TEXTDOMAINDIR@|$(shell pwd)/po/build/locale|' \
+	     -e 's|@GITPERLLIB@|$(shell pwd)/perl/build/lib|' \
+	     -e 's|@MERGE_TOOLS_DIR@|$(shell pwd)/mergetools|' \
+	     -e 's|@TEMPLATE_DIR@|$(shell pwd)/templates/blt|' \
 	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
 	chmod +x $@
 
bin-wrappers/wrap-for-bin.sh +6 -5
index 7898a1c238d..1d3a59a0081 100755
@@ -4,21 +4,22 @@
 # to run test suite against sandbox, but with only bindir-installed
 # executables in PATH.  The Makefile copies this into various
 # files in bin-wrappers, substituting
-# @BUILD_DIR@ and @PROG@.
+# @BUILD_DIR@, @TEMPLATE_DIR@ and @PROG@.
 
 GIT_EXEC_PATH='@BUILD_DIR@'
 if test -n "$NO_SET_GIT_TEMPLATE_DIR"
 then
 	unset GIT_TEMPLATE_DIR
 else
-	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
+	GIT_TEMPLATE_DIR='@TEMPLATE_DIR@'
 	export GIT_TEMPLATE_DIR
 fi
-GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+MERGE_TOOLS_DIR='@MERGE_TOOLS_DIR@'
+GITPERLLIB='@GITPERLLIB@'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@GIT_TEXTDOMAINDIR@'
 PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
-export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
+export MERGE_TOOLS_DIR GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
 case "$GIT_DEBUGGER" in
 '')
contrib/buildsystems/CMakeLists.txt +8 -0
index b95287468cd..bf5e2b5c08d 100644
@@ -1087,6 +1087,9 @@ endforeach()
 
 file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
 string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@GIT_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" content "${content}")
+string(REPLACE "@GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" content "${content}")
+string(REPLACE "@MERGE_TOOLS_DIR@" "${CMAKE_SOURCE_DIR}/mergetools" content "${content}")
 string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
@@ -1171,6 +1174,11 @@ string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_optio
 string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
 string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
 string(REPLACE "@RUNTIME_PREFIX@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_POPATH@" "${CMAKE_BINARY_DIR}/po" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "${CMAKE_BINARY_DIR}/templates/blt" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_MERGE_TOOLS_DIR@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
t/lib-gettext.sh +2 -2
index cc6bb2cdeaa..7a734c6973e 100644
@@ -6,8 +6,8 @@
 
 . ./test-lib.sh
 
-GIT_TEXTDOMAINDIR="$GIT_BUILD_DIR/po/build/locale"
-GIT_PO_PATH="$GIT_BUILD_DIR/po"
+GIT_TEXTDOMAINDIR="$GIT_TEST_TEXTDOMAINDIR"
+GIT_PO_PATH="$GIT_TEST_POPATH"
 export GIT_TEXTDOMAINDIR GIT_PO_PATH
 
 if test -n "$GIT_TEST_INSTALLED"
t/t7609-mergetool--lib.sh +1 -1
index 8b1c3bd39f2..a9273ba58d7 100755
@@ -8,7 +8,7 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'mergetool --tool=vimdiff creates the expected layout' '
-	. "$GIT_BUILD_DIR"/mergetools/vimdiff &&
+	. "$GIT_TEST_MERGE_TOOLS_DIR"/vimdiff &&
 	run_unit_tests
 '
 
t/test-lib.sh +3 -3
index 4dd641baefe..677424ced06 100644
@@ -1478,7 +1478,7 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
 		PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"
 	fi
 fi
-GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
+GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR"
 GIT_CONFIG_NOSYSTEM=1
 GIT_ATTR_NOSYSTEM=1
 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/.."
@@ -1494,9 +1494,9 @@ then
 	fi
 fi
 
-GITPERLLIB="$GIT_BUILD_DIR"/perl/build/lib
+GITPERLLIB="$GIT_TEST_GITPERLLIB"
 export GITPERLLIB
-test -d "$GIT_BUILD_DIR"/templates/blt || {
+test -d "$GIT_TEMPLATE_DIR" || {
 	BAIL_OUT "You haven't built things yet, have you?"
 }
 
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#65 lore raw

RFC PATCH v2 22/24 t: allow overriding build dir

In reply to Patrick Steinhardt

Our "test-lib.sh" assumes that our build directory is the parent directory of "t/". While true when using our Makefile, it's not when using build systems that support out-of-tree builds.

In commit ee9e66e4e7 (cmake: avoid editing t/test-lib.sh, 2022-10-18), we have introduce support for overriding the GIT_BIULD_DIR by creating the file "$GIT_BUILD_DIR/GIT-BUILD-DIR" with its contents pointing to the location of the build directory. The intent was to stop modifying "t/test-lib.sh" with the CMake build systems while allowing out-of-tree builds. But "$GIT_BUILD_DIR" is somewhat misleadingly named, as it in fact points to the _source_ directory. So while that commit solved part of the problem for out-of-tree builds, CMake still has to write files into the source tree.

Solve the second part of the problem, namely not having to write any data into the source directory at all, by also supporting an environment variable that allows us to point to a different build directory. This allows us to perform properly self-contained out-of-tree builds.

---
 t/test-lib.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/test-lib.sh +2 -1
index 677424ced06..096af9be6b1 100644
@@ -35,7 +35,7 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
-GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
+GIT_BUILD_DIR="${GIT_BUILD_DIR:-${TEST_DIRECTORY%/t}}"
 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
 then
 	echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2
@@ -513,6 +513,7 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 		PERF_
 		CURL_VERBOSE
 		TRACE_CURL
+		BUILD_DIR
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
 	print join("\n", @vars);
Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#66 lore raw

RFC PATCH v2 23/24 Documentation: add comparison of build systems

In reply to Patrick Steinhardt

We're contemplating whether to eventually replace our build systems with a build system that is easier to use. Add a comparison of build systems to our technical documentation as a baseline for discussion.

---
 Documentation/Makefile                    |   1 +
 Documentation/technical/build-systems.txt | 224 ++++++++++++++++++++++
 2 files changed, 225 insertions(+)
 create mode 100644 Documentation/technical/build-systems.txt
Documentation/Makefile +1 -0
index 0f55baa252f..e23cffb5f9a 100644
@@ -111,6 +111,7 @@ TECH_DOCS += MyFirstObjectWalk
 TECH_DOCS += SubmittingPatches
 TECH_DOCS += ToolsForGit
 TECH_DOCS += technical/bitmap-format
+TECH_DOCS += technical/build-systems
 TECH_DOCS += technical/bundle-uri
 TECH_DOCS += technical/hash-function-transition
 TECH_DOCS += technical/long-running-process-protocol
Documentation/technical/build-systems.txt new file +224 -0

224 lines not on this page · raw message

Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty
#67 lore raw

Re: [RFC PATCH v2 23/24] Documentation: add comparison of build systems

Hi Patrick

On 09/10/2024 15:57, Patrick Steinhardt wrote:

Thanks for putting this together, I've left a few comments below.

Documentation/technical/build-systems.txt line 15

Quoted 5 lines

+== Requirements

Documentation/technical/build-systems.txt new file +4 -0
+
+The following subsections present a list of requirements that we have for any
+potential build system. Sections are sorted by decreasing priority, even though
+these priorities will naturally differ between users.

This last sentence sounds a bit self contradictory - whose priorities are we using?

Documentation/technical/build-systems.txt line 20

Quoted 4 lines

+=== Platform support

Documentation/technical/build-systems.txt new file +3 -0
+
+The build system must have support for all of our primary platforms as outlined
+by. These platforms are:

Something seems to have been lost when the first sentence was edited.

Quoted 4 lines
Documentation/technical/build-systems.txt new file +4 -0
+  - Linux
+  - Windows
+  - macOS
+

Documentation/technical/build-systems.txt line 35

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+Furthermore, the build system should have support for the following secondary
+platforms:
+
+  - AIX
+  - FreeBSD
+  - NetBSD
+  - OpenBSD
+
+The platforms which must be supported by the tool should be aligned with our
+[platform support policy](platform-support.txt).

The platform support document does not use the terms primary or secondary when talking about support so I'm not sure what distinction we're trying to make here. Also where does NonStop fit into this?

Documentation/technical/build-systems.txt line 56

Quoted 5 lines

+=== Ease of use

Documentation/technical/build-systems.txt new file +4 -0
+
+The build system should be both easy to use and easy to extend. While this is
+naturally a subjective metric it is likely not controversial to say that some
+build systems are considerably harder to use than others.

The tricky part is deciding how to measure ease of use if we're going to use it as a metric for selecting a build system.

Review

Quoted 3 lines

+=== Out-of-tree builds

(quoted diff) +2 -0
+
+The build system should support out-of-tree builds.

Yes please!

Quoted 9 lines

+=== Language support

Documentation/technical/build-systems.txt new file +8 -0
+
+The following languages and toolchains are of relevance and should be supported
+by the build system:
+
+  - C: the primary compiled language used by Git, must be supported. Relevant
+    toolchains are GCC, Clang and MSVC.
+  - Rust: candidate as a second compiled lanugage, should be supported. Relevant
+    toolchains is the LLVM-based rustc.

Documentation/technical/build-systems.txt line 117

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+
+Built-in support for the respective languages is preferred over support that
+needs to be wired up manually to avoid unnecessary complexity. Native support
+includes the following features:
+
+  - Compiling objects.
+  - Dependency tracking.
+  - Detection of available features.
+  - Discovery of relevant toolchains.
+  - Linking libraries and executables.

Do we want a section about templating (i.e. substituting @XXX@) support which we use when installing scripts?

Documentation/technical/build-systems.txt line 129

Quoted 11 lines

+=== Test integration

Documentation/technical/build-systems.txt new file +10 -0
+
+It should be possible to integrate tests into the build system such that it is
+possible to build and test Git within the build system. Features which are nice
+to have:
+
+  - Track build-time dependencies for respective tests. Unit tests have
+    different requirements than integration tests.
+  - Allow filtering of which tests to run.
+  - Allow interactive tests that drop the user into a shell with `test_pause` or
+    `debug`.

Does this last point mean we want to be able to selectively pass --interactive to the test script(s) being run?

Documentation/technical/build-systems.txt line 183

Quoted 12 lines

+=== CMake

Documentation/technical/build-systems.txt new file +11 -0
+
+- Platform support: not as extensive as GNU Make or autoconf, but all major
+  platforms are supported.
+  - AIX
+  - Cygwin
+  - FreeBSD
+  - Linux
+  - OpenBSD
+  - Solaris
+  - Windows
+  - macOS

This matches the list in the CMake README but in practice it is available for a much wider range of platforms including all those listed below for meson.

Quoted 24 lines

+- Ease of use: easy to use, discovering available options is not always

Documentation/technical/build-systems.txt new file +23 -0
+  trivial. The scripting language used by CMake is somewhat cumbersome to use,
+  but extending CMake build instructions is doable.
+- IDE support: natively integrated into Microsoft Visual Studio. Can generate
+  project descriptions for Xcode. An extension is available for Visual Studio
+  Code. Many other IDEs have plugins for CMake.
+- Out-of-tree builds: supported.
+- Cross-platform builds: supported.
+- Language support:
+  - C: Supported for GCC, Clang, MSVC and other toolchains.
+  - Rust: No built-in support, needs to be wired up manually.
+- Test integration: supported, even though test dependencies are a bit
+  cumbersome to use via "test fixtures". Interactive test runs are not
+  supported.
+
+=== Meson
+
+- Platform: not as extensive as GNU Make or autoconf, but all major platforms
+  and some smaller ones are supported.
+  - AIX
+  - Cygwin
+  - DragonflyBSD
+  - FreeBSD
+  - Haiku

Documentation/technical/build-systems.txt line 217

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+  - Linux
+  - NetBSD
+  - OpenBSD
+  - Solaris
+  - Windows
+  - macOS
+- Ease of use: easy to use, discovering available options is easy. The
+  scripting language is straight-forward to use.
+- IDE support: Supports generating build instructions for Xcode and Microsoft
+  Visual Studio, a plugin exists for Visual Studio Code.

This is my main concern about meson - it means we either loose the nice integration on Windows that we have with CMake or we have to continue to maintain both. As I understand it Microsoft Visual Studio support requires the user to open a mingw terminal and run some to generate a build description which they can then use form the GUI which is what the CMake support was added to avoid. I guess they also need to install meson somehow as well.

Best Wishes

Phillip

Quoted 7 lines
+- Out-of-tree builds: supported.
+- Cross-platform builds: supported.
+- Language support:
Documentation/technical/build-systems.txt new file +4 -0
+  - C: Supported for GCC, Clang, MSVC and other toolchains.
+  - Rust: Supported for rustc.
+- Test integration: supported. Interactive tests are supported starting with
+  Meson 1.5.0 via the `--interactive` flag.
#68 lore raw

Re: [RFC PATCH v2 23/24] Documentation: add comparison of build systems

Quoted 9 lines · Phillip Wood

Documentation/technical/build-systems.txt line 15

Quoted 5 lines · Patrick Steinhardt

+== Requirements

Documentation/technical/build-systems.txt new file +4 -0
+
+The following subsections present a list of requirements that we have for any
+potential build system. Sections are sorted by decreasing priority, even though
+these priorities will naturally differ between users.

This last sentence sounds a bit self contradictory - whose priorities are we using?

I guess it's priorities as received by the author, namely me. I didn't quite know how to write this, as I didn't want to force my own prios on everybody else without saying so. But if people agree with the general ordering I'm happy to drop this sentence.

Quoted 17 lines

Documentation/technical/build-systems.txt line 20

Quoted 4 lines

+=== Platform support

Documentation/technical/build-systems.txt new file +3 -0
+
+The build system must have support for all of our primary platforms as outlined
+by. These platforms are:

Something seems to have been lost when the first sentence was edited.

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+  - Linux
+  - Windows
+  - macOS
+
+Furthermore, the build system should have support for the following secondary
+platforms:
+
+  - AIX
+  - FreeBSD
+  - NetBSD
Quoted 8 lines

Documentation/technical/build-systems.txt line 35

Quoted 4 lines
Documentation/technical/build-systems.txt new file +4 -0
+  - OpenBSD
+
+The platforms which must be supported by the tool should be aligned with our
+[platform support policy](platform-support.txt).

The platform support document does not use the terms primary or secondary when talking about support so I'm not sure what distinction we're trying to make here. Also where does NonStop fit into this?

Yes, true, and that's an issue from my point of view. I think we should make explicit the different kinds of support we have and have a proper list of systems that are supported and their general "support tier". Anyway, that's a different can of worms that I don't want to open right now. My table is still crawling with worms from previously-opened cans.

I've reworded this slightly now and added NonStop.

Quoted 8 lines

Documentation/technical/build-systems.txt line 56

Quoted 5 lines

+=== Ease of use

Documentation/technical/build-systems.txt new file +4 -0
+
+The build system should be both easy to use and easy to extend. While this is
+naturally a subjective metric it is likely not controversial to say that some
+build systems are considerably harder to use than others.

The tricky part is deciding how to measure ease of use if we're going to use it as a metric for selecting a build system.

Yup. It's part of the reason why I wanted to have all build systems in the tree, such that it is possible to compare them by just having a look for how it looks like.

Things are naturally going to be subjective, and that is fine. But I guess that we can mostly agree on some general things, like "autoconf looks like gibberish".

Quoted 14 lines
Quoted 14 lines

+=== Language support

Documentation/technical/build-systems.txt new file +13 -0
+
+The following languages and toolchains are of relevance and should be supported
+by the build system:
+
+  - C: the primary compiled language used by Git, must be supported. Relevant
+    toolchains are GCC, Clang and MSVC.
+  - Rust: candidate as a second compiled lanugage, should be supported. Relevant
+    toolchains is the LLVM-based rustc.
+
+Built-in support for the respective languages is preferred over support that
+needs to be wired up manually to avoid unnecessary complexity. Native support
+includes the following features:
+
Quoted 8 lines

Documentation/technical/build-systems.txt line 117

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+  - Compiling objects.
+  - Dependency tracking.
+  - Detection of available features.
+  - Discovery of relevant toolchains.
+  - Linking libraries and executables.

Do we want a section about templating (i.e. substituting @XXX@) support which we use when installing scripts?

It doesn't hurt.

Quoted 6 lines
Quoted 6 lines

+=== Test integration

Documentation/technical/build-systems.txt new file +5 -0
+
+It should be possible to integrate tests into the build system such that it is
+possible to build and test Git within the build system. Features which are nice
+to have:
+
Quoted 8 lines

Documentation/technical/build-systems.txt line 129

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+  - Track build-time dependencies for respective tests. Unit tests have
+    different requirements than integration tests.
+  - Allow filtering of which tests to run.
+  - Allow interactive tests that drop the user into a shell with `test_pause` or
+    `debug`.

Does this last point mean we want to be able to selectively pass --interactive to the test script(s) being run?

What I mean by this is that when I see that a specific test fails, I want to be able to execute only that single test such that things like test_pause fail. What I don't mean is that the build system should know to automatically rerun failing tests with that.

I've reformulated it to "Allow running tests such that utilities like test_pause or debug work."

Quoted 13 lines

Documentation/technical/build-systems.txt line 183

Quoted 12 lines

+=== CMake

Documentation/technical/build-systems.txt new file +11 -0
+
+- Platform support: not as extensive as GNU Make or autoconf, but all major
+  platforms are supported.
+  - AIX
+  - Cygwin
+  - FreeBSD
+  - Linux
+  - OpenBSD
+  - Solaris
+  - Windows
+  - macOS
Quoted 3 lines

This matches the list in the CMake README but in practice it is available for a much wider range of platforms including all those listed below for meson.

I was searching for an official statement, but couldn't find anything. Do you maybe have a pointer?

Quoted 35 lines
Quoted 24 lines

+- Ease of use: easy to use, discovering available options is not always

Documentation/technical/build-systems.txt new file +23 -0
+  trivial. The scripting language used by CMake is somewhat cumbersome to use,
+  but extending CMake build instructions is doable.
+- IDE support: natively integrated into Microsoft Visual Studio. Can generate
+  project descriptions for Xcode. An extension is available for Visual Studio
+  Code. Many other IDEs have plugins for CMake.
+- Out-of-tree builds: supported.
+- Cross-platform builds: supported.
+- Language support:
+  - C: Supported for GCC, Clang, MSVC and other toolchains.
+  - Rust: No built-in support, needs to be wired up manually.
+- Test integration: supported, even though test dependencies are a bit
+  cumbersome to use via "test fixtures". Interactive test runs are not
+  supported.
+
+=== Meson
+
+- Platform: not as extensive as GNU Make or autoconf, but all major platforms
+  and some smaller ones are supported.
+  - AIX
+  - Cygwin
+  - DragonflyBSD
+  - FreeBSD
+  - Haiku

Documentation/technical/build-systems.txt line 217

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+  - Linux
+  - NetBSD
+  - OpenBSD
+  - Solaris
+  - Windows
+  - macOS
+- Ease of use: easy to use, discovering available options is easy. The
+  scripting language is straight-forward to use.
+- IDE support: Supports generating build instructions for Xcode and Microsoft
+  Visual Studio, a plugin exists for Visual Studio Code.
Quoted 7 lines

This is my main concern about meson - it means we either loose the nice integration on Windows that we have with CMake or we have to continue to maintain both. As I understand it Microsoft Visual Studio support requires the user to open a mingw terminal and run some to generate a build description which they can then use form the GUI which is what the CMake support was added to avoid. I guess they also need to install meson somehow as well.

I'm personally not particularly worried about having to generate the MSVC solution from the command line once, as long as things just work from thereon without requiring the developer to jump through hoops to get it set up. It certainly doesn't seem like a particularly high barrier to me, and should be a huge improvement compared to our current Makefile.

I'm mostly there by now with the subprojects added in this version of the patch series, which make it way easier to use MSVC without all deps having been installed. But I still have to port over the SANE_TOOL_PATH hack that we have in CMake.

I do understand that just clicking a button to import a CMakeLists.txt is easier. It's mostly that I personally value the sanity that Meson brings with it higher, which is of course a subjective opinion.

Patrick

#69 lore raw

Re: [RFC PATCH v2 23/24] Documentation: add comparison of build systems

Hi Patrick

Quoted 11 lines · Patrick Steinhardt
Quoted 9 lines · Phillip Wood

Documentation/technical/build-systems.txt line 15

Quoted 5 lines · Patrick Steinhardt

+== Requirements

Documentation/technical/build-systems.txt new file +4 -0
+
+The following subsections present a list of requirements that we have for any
+potential build system. Sections are sorted by decreasing priority, even though
+these priorities will naturally differ between users.

This last sentence sounds a bit self contradictory - whose priorities are we using?

Quoted 4 lines

I guess it's priorities as received by the author, namely me. I didn't quite know how to write this, as I didn't want to force my own prios on everybody else without saying so. But if people agree with the general ordering I'm happy to drop this sentence.

I think that would make sense - anyone who objects to the order you've selected can also say so in a review.

Quoted 26 lines
Quoted 17 lines

Documentation/technical/build-systems.txt line 20

Quoted 4 lines

+=== Platform support

Documentation/technical/build-systems.txt new file +3 -0
+
+The build system must have support for all of our primary platforms as outlined
+by. These platforms are:

Something seems to have been lost when the first sentence was edited.

Quoted 10 lines
Documentation/technical/build-systems.txt new file +10 -0
+  - Linux
+  - Windows
+  - macOS
+
+Furthermore, the build system should have support for the following secondary
+platforms:
+
+  - AIX
+  - FreeBSD
+  - NetBSD
Quoted 8 lines

Documentation/technical/build-systems.txt line 35

Quoted 4 lines
Documentation/technical/build-systems.txt new file +4 -0
+  - OpenBSD
+
+The platforms which must be supported by the tool should be aligned with our
+[platform support policy](platform-support.txt).

The platform support document does not use the terms primary or secondary when talking about support so I'm not sure what distinction we're trying to make here. Also where does NonStop fit into this?

Quoted 3 lines

Yes, true, and that's an issue from my point of view. I think we should make explicit the different kinds of support we have and have a proper list of systems that are supported and their general "support tier".

That would probably be clearer but as you say it can wait

Quoted 2 lines

Anyway, that's a different can of worms that I don't want to open right now. My table is still crawling with worms from previously-opened cans.

It's going to take a while for me to get that image out of my mind!

Quoted 1 line

I've reworded this slightly now and added NonStop.

Great

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

+=== Test integration

Documentation/technical/build-systems.txt new file +5 -0
+
+It should be possible to integrate tests into the build system such that it is
+possible to build and test Git within the build system. Features which are nice
+to have:
+
Quoted 8 lines

Documentation/technical/build-systems.txt line 129

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+  - Track build-time dependencies for respective tests. Unit tests have
+    different requirements than integration tests.
+  - Allow filtering of which tests to run.
+  - Allow interactive tests that drop the user into a shell with `test_pause` or
+    `debug`.

Does this last point mean we want to be able to selectively pass --interactive to the test script(s) being run?

Quoted 7 lines

What I mean by this is that when I see that a specific test fails, I want to be able to execute only that single test such that things like test_pause fail. What I don't mean is that the build system should know to automatically rerun failing tests with that.

I've reformulated it to "Allow running tests such that utilities like test_pause or debug work."

Ah so this is basically "there should be a way to disable parallelization and let the test access the terminal"?

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

+=== CMake

Documentation/technical/build-systems.txt new file +11 -0
+
+- Platform support: not as extensive as GNU Make or autoconf, but all major
+  platforms are supported.
+  - AIX
+  - Cygwin
+  - FreeBSD
+  - Linux
+  - OpenBSD
+  - Solaris
+  - Windows
+  - macOS
Quoted 6 lines
Quoted 3 lines

This matches the list in the CMake README but in practice it is available for a much wider range of platforms including all those listed below for meson.

I was searching for an official statement, but couldn't find anything. Do you maybe have a pointer?

I've not been able to find any documentation but https://github.com/Kitware/CMake/tree/9c25632ba0ad0525b20195d371b3d78a8bcc4113/Modules/Platform seems to show which platforms and compilers are supported.

Quoted 13 lines
Quoted 5 lines

Documentation/technical/build-systems.txt line 217

Quoted 4 lines

+- Ease of use: easy to use, discovering available options is easy. The

Documentation/technical/build-systems.txt new file +3 -0
+  scripting language is straight-forward to use.
+- IDE support: Supports generating build instructions for Xcode and Microsoft
+  Visual Studio, a plugin exists for Visual Studio Code.
Quoted 7 lines

This is my main concern about meson - it means we either loose the nice integration on Windows that we have with CMake or we have to continue to maintain both. As I understand it Microsoft Visual Studio support requires the user to open a mingw terminal and run some to generate a build description which they can then use form the GUI which is what the CMake support was added to avoid. I guess they also need to install meson somehow as well.

Quoted 6 lines

I'm personally not particularly worried about having to generate the MSVC solution from the command line once, as long as things just work from thereon without requiring the developer to jump through hoops to get it set up. It certainly doesn't seem like a particularly high barrier to me, and should be a huge improvement compared to our current Makefile.

It's an improvement on our Makefile but a regression compared to our CMakeList.txt which was specifically aimed making it easy for new contributors to get started without downloading any extra software or running terminal commands.

Quoted 8 lines

I'm mostly there by now with the subprojects added in this version of the patch series, which make it way easier to use MSVC without all deps having been installed. But I still have to port over the SANE_TOOL_PATH hack that we have in CMake.

I do understand that just clicking a button to import a CMakeLists.txt is easier. It's mostly that I personally value the sanity that Meson brings with it higher, which is of course a subjective opinion.

Right, I suspect the people who added support for building git in Visual Studio with CMake have different priorities. It's a real shame the meson there isn't a meson plugin for Visual Studio.

Best Wishes

Phillip

#70 lore raw

Re: [RFC PATCH v2 23/24] Documentation: add comparison of build systems

Quoted 20 lines · On Wed, Oct 16, 2024 at 02:36:54PM +0100, [email protected] wrote:
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines

+=== Test integration

Documentation/technical/build-systems.txt new file +5 -0
+
+It should be possible to integrate tests into the build system such that it is
+possible to build and test Git within the build system. Features which are nice
+to have:
+
Quoted 8 lines

Documentation/technical/build-systems.txt line 129

Quoted 5 lines
Documentation/technical/build-systems.txt new file +5 -0
+  - Track build-time dependencies for respective tests. Unit tests have
+    different requirements than integration tests.
+  - Allow filtering of which tests to run.
+  - Allow interactive tests that drop the user into a shell with `test_pause` or
+    `debug`.

Does this last point mean we want to be able to selectively pass --interactive to the test script(s) being run?

What I mean by this is that when I see that a specific test fails, I want to be able to execute only that single test such that things like test_pause fail. What I don't mean is that the build system should know to automatically rerun failing tests with that.

Quoted 5 lines
Quoted 2 lines

I've reformulated it to "Allow running tests such that utilities like test_pause or debug work."

Ah so this is basically "there should be a way to disable parallelization and let the test access the terminal"?

Exactly.

With out-of-tree builds the development process is going to change a bit, and it is going to be closer integrated with the build system. Right now it's easy to manually execute a test and thus give it access to the terminal. And while that shouldn't go away, you'd now have to set up an additional environment variable to tell the test where the build directory lives. There isn't really a way to avoid that.

But to me that also means that it's important that features we're all used to remain easily accessible, and test_pause and debug are two things that many developers probably use on a daily basis. I was worried about that a when starting out on the Meson journey, but now I actually have to say that I already favor the Meson workflow over the Makefile workflow. Previously, I always used to do:

    $ make -C .. -j20 && ./t1234-something.sh

With Meson that becomes:

    $ meson test -i t1234-something

Which, at least to me, somehow feels way more enjoyable.

Quoted 20 lines
Quoted 13 lines
Quoted 5 lines

Documentation/technical/build-systems.txt line 217

Quoted 4 lines

+- Ease of use: easy to use, discovering available options is easy. The

Documentation/technical/build-systems.txt new file +3 -0
+  scripting language is straight-forward to use.
+- IDE support: Supports generating build instructions for Xcode and Microsoft
+  Visual Studio, a plugin exists for Visual Studio Code.
Quoted 7 lines

This is my main concern about meson - it means we either loose the nice integration on Windows that we have with CMake or we have to continue to maintain both. As I understand it Microsoft Visual Studio support requires the user to open a mingw terminal and run some to generate a build description which they can then use form the GUI which is what the CMake support was added to avoid. I guess they also need to install meson somehow as well.

Quoted 6 lines

I'm personally not particularly worried about having to generate the MSVC solution from the command line once, as long as things just work from thereon without requiring the developer to jump through hoops to get it set up. It certainly doesn't seem like a particularly high barrier to me, and should be a huge improvement compared to our current Makefile.

Quoted 4 lines

It's an improvement on our Makefile but a regression compared to our CMakeList.txt which was specifically aimed making it easy for new contributors to get started without downloading any extra software or running terminal commands.

Yeah, that's fair enough.

Quoted 5 lines
Quoted 5 lines

I'm mostly there by now with the subprojects added in this version of the patch series, which make it way easier to use MSVC without all deps having been installed. But I still have to port over the SANE_TOOL_PATH hack that we have in CMake.

Quoted 7 lines
Quoted 3 lines

I do understand that just clicking a button to import a CMakeLists.txt is easier. It's mostly that I personally value the sanity that Meson brings with it higher, which is of course a subjective opinion.

Right, I suspect the people who added support for building git in Visual Studio with CMake have different priorities. It's a real shame the meson there isn't a meson plugin for Visual Studio.

It certainly would be great to have such a plugin. There is one for Visual Studio Code, but of course MSVC and VSC aren't the same. Which reminds me, I should give that plugin a try.

In any case, my hope would be that eventually such a plugin does show up. My gut feeling tells me that Meson has been picking up quite a bit of steam over the last couple years, and more and more projects are picking it up. And that makes me hopeful that we would eventually get such a plugin.

It's of course wishful thinking, but as said, meanwhile we do have a way for MSVC by generating the solution manually. So I'd already see it as a net win if the official build system supports MSVC, even though not as easily as with the click of a button.

Patrick

#71 lore raw

Re: [RFC PATCH v2 23/24] Documentation: add comparison of build systems

Quoted 24 lines · Patrick Steinhardt
Quoted 5 lines · On Wed, Oct 16, 2024 at 02:36:54PM +0100, [email protected] wrote:
Quoted 5 lines

I'm mostly there by now with the subprojects added in this version of the patch series, which make it way easier to use MSVC without all deps having been installed. But I still have to port over the SANE_TOOL_PATH hack that we have in CMake.

Quoted 7 lines
Quoted 3 lines

I do understand that just clicking a button to import a CMakeLists.txt is easier. It's mostly that I personally value the sanity that Meson brings with it higher, which is of course a subjective opinion.

Right, I suspect the people who added support for building git in Visual Studio with CMake have different priorities. It's a real shame the meson there isn't a meson plugin for Visual Studio.

It certainly would be great to have such a plugin. There is one for Visual Studio Code, but of course MSVC and VSC aren't the same. Which reminds me, I should give that plugin a try.

In any case, my hope would be that eventually such a plugin does show up. My gut feeling tells me that Meson has been picking up quite a bit of steam over the last couple years, and more and more projects are picking it up. And that makes me hopeful that we would eventually get such a plugin.

Quoted 4 lines

It's of course wishful thinking, but as said, meanwhile we do have a way for MSVC by generating the solution manually. So I'd already see it as a net win if the official build system supports MSVC, even though not as easily as with the click of a button.

So I've had a look at Visual Studio Code now. Things didn't work as-is yet, but I've made some changes and now things work out of the box. You install the Meson plugin, clone the Git project, and Meson configures automatically. The only requirement is that you've got Git for Windows installed, which provides all the build tools and which gets picked up by Meson automatically now.

Afterwards you can just click on any build and/or test target and then VS Code builds dependencies, including subprojects like curl, zlib, openssl and the like, and executes the tests for you.

Patrick

#72 lore raw

RFC PATCH v2 24/24 Introduce support for the Meson build system

In reply to Patrick Steinhardt

Introduce support for the Meson build system, a "modern" meta build system that supports many different plaforms, including Linux, macOS, Windows and BSDs. Meson supports different backends, including Ninja, Xcode and Microsoft Visual Studio. Several common IDEs provide an integration with it.

The biggest contender compared to Meson is probably CMake as outlined in our "Documentation/technical/build-systems.txt" file. Based on my own personal experience from working with both build systems extensively I strongly favor Meson over CMake. In my opinion, it feels significantly easier to use with a syntax that feels more like a "real" programming language. The second big reason is that Meson supports Rust natively, which may prove to be important given that the project is likely to pick up Rust as another language eventually.

Using Meson is rather straight-forward. An example:

    ```
    # Meson uses out-of-tree builds. You can set up multiple build
    # directories, how you name them is completely up to you.
    $ mkdir build
    $ cd build
    $ meson setup .. -Dprefix=/tmp/git-installation

    # Build the project. This also provides several other targets like
    e.g. `install` or `test`.
    $ ninja

    # Meson has been wired up to support execution of our test suites.
    # Both our unit tests and our integration tests are supported.
    # Running `meson test` without any arguments will execute all tests,
    # but the syntax supports globbing to select only some tests.
    $ meson test 't-*'
    # Execute single test interactively to allow fordebugging.
    $ meson test 't0000-*' --interactive --test-args=-ix
    ```

The build instructions have been successfully tested on the following systems, tests are passing:

- Apple macOS 10.15.

- FreeBSD 14.1, except gitweb-based tests.

- NixOS 24.11.

- Ubuntu 24.04.

- Windows 10 with Cygwin, using -Dperl=disabled -Dpython=disabled.

- Windows 10 with MinGW64, using -Dperl=disabled -Dpython=disabled.

- Windows 10 with MSVC 2022, using `-Dperl=disabled -Dpython=disabled

    -Dgettext=disabled -Diconv=disabled --wrap-mode=forcefallback`.

It is expected that there will still be rough edges in the current version. If this patch lands the expectation is that it will coexist with our other build systems for a while. Like this, distributions can slowly migrate over to Meson and report any findings they have to us such that we can continue to iterate. A potential cutoff date for other build systems may be Git 3.0.

Some notes:

- The installed distribution is structured somewhat differently than how it used to be the case. All of our binaries are installed into $libexec/git-core, while all binaries part of $bindir are now symbolic links pointing to the former. This rule is consistent in itself and thus easier to reason about.

- We do not install dashed binaries into $libexec/git-core anymore. So there won't e.g. be a symlink for git-add(1). These are not required by modern Git and there isn't really much of a usecase for those anymore. By not installing those symlinks we thus start the deprecation of this layout.

- Support for installing documentation has not been wired up yet. This will follow if the project can agree on Meson as build system.

- Documentation does not yet exist. Same here, it will follow if the project can agree on Meson.

- We're targeting a Meson 1.3.0, which has been released relatively recently November 2023. The only feature we use from that version is fs.relative_to(), which we could replace if necessary. If so, we could start to target Meson 1.0.0 and newer, released in December 2022.

- The whole build instructions count around 3000 lines, half of which is listing all of our code and test files. Our Makefiles are around 5000 lines, autoconf adds another 1300 lines. CMake in comparison has only 1200 linescode, but it avoids listing individual files and does not wire up auto-configuration as extensively as the Meson instructions do.

- We bundle a set of subproject wrappers for curl, expat, openssl, pcre2 and zlib. This allows developers to build Git without these dependencies preinstalled, and Meson will fetch and build them automatically. This is especially helpful on Windows.

---
 bin-wrappers/meson.build           |   28 +
 contrib/completion/meson.build     |    8 +
 contrib/meson.build                |    1 +
 gitweb/meson.build                 |   32 +
 gitweb/static/meson.build          |   28 +
 meson.build                        | 1607 ++++++++++++++++++++++++++++
 meson_options.txt                  |   70 ++
 perl/FromCPAN/Mail/meson.build     |    7 +
 perl/FromCPAN/meson.build          |    9 +
 perl/Git/LoadCPAN/Mail/meson.build |    7 +
 perl/Git/LoadCPAN/meson.build      |    9 +
 perl/Git/SVN/Memoize/meson.build   |    7 +
 perl/Git/SVN/meson.build           |   20 +
 perl/Git/meson.build               |   18 +
 perl/meson.build                   |   18 +
 po/meson.build                     |   28 +
 subprojects/curl.wrap              |   13 +
 subprojects/expat.wrap             |   13 +
 subprojects/openssl.wrap           |   15 +
 subprojects/pcre2.wrap             |   16 +
 subprojects/zlib.wrap              |   13 +
 t/helper/meson.build               |   91 ++
 t/meson.build                      | 1105 +++++++++++++++++++
 templates/hooks/meson.build        |   24 +
 templates/info/meson.build         |    5 +
 templates/meson.build              |    8 +
 26 files changed, 3200 insertions(+)
 create mode 100644 bin-wrappers/meson.build
 create mode 100644 contrib/completion/meson.build
 create mode 100644 contrib/meson.build
 create mode 100644 gitweb/meson.build
 create mode 100644 gitweb/static/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 perl/FromCPAN/Mail/meson.build
 create mode 100644 perl/FromCPAN/meson.build
 create mode 100644 perl/Git/LoadCPAN/Mail/meson.build
 create mode 100644 perl/Git/LoadCPAN/meson.build
 create mode 100644 perl/Git/SVN/Memoize/meson.build
 create mode 100644 perl/Git/SVN/meson.build
 create mode 100644 perl/Git/meson.build
 create mode 100644 perl/meson.build
 create mode 100644 po/meson.build
 create mode 100644 subprojects/curl.wrap
 create mode 100644 subprojects/expat.wrap
 create mode 100644 subprojects/openssl.wrap
 create mode 100644 subprojects/pcre2.wrap
 create mode 100644 subprojects/zlib.wrap
 create mode 100644 t/helper/meson.build
 create mode 100644 t/meson.build
 create mode 100644 templates/hooks/meson.build
 create mode 100644 templates/info/meson.build
 create mode 100644 templates/meson.build
bin-wrappers/meson.build new file +28 -0
new file mode 100644
index 00000000000..6d03a19d7b8
@@ -0,0 +1,28 @@
+bin_wrappers_config = configuration_data()
+foreach key, value : {
+      'BUILD_DIR': meson.project_build_root(),
+      'MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
+      'TEMPLATE_DIR': meson.project_build_root() / 'templates',
+      'GIT_TEXTDOMAINDIR': meson.project_build_root() / 'po',
+      'GITPERLLIB': meson.project_build_root() / 'perl/lib',
+}
+  # Paths need to be Unix-style without drive prefixes as they get added to the
+  # PATH variable. And given that drive prefixes contain a colon we'd otherwise
+  # end up with a broken PATH if we didn't convert them.
+  if cygpath.found()
+    value = run_command(cygpath, value, check: true).stdout().strip()
+  endif
+  bin_wrappers_config.set(key, value)
+endforeach
+
+foreach executable : bin_wrappers
+  executable_config = configuration_data()
+  executable_config.merge_from(bin_wrappers_config)
+  executable_config.set('PROG', fs.relative_to(executable.full_path(), meson.project_build_root()))
+
+  configure_file(
+    input: 'wrap-for-bin.sh',
+    output: fs.stem(executable.full_path()),
+    configuration: executable_config,
+  )
+endforeach
contrib/completion/meson.build new file +8 -0
new file mode 100644
index 00000000000..a9bfe2da312
@@ -0,0 +1,8 @@
+foreach script : [
+  'git-completion.bash',
+  'git-completion.tcsh',
+  'git-completion.zsh',
+  'git-prompt.sh'
+]
+  test_dependencies += fs.copyfile(script)
+endforeach
contrib/meson.build new file +1 -0
new file mode 100644
index 00000000000..a7b77b87c22
@@ -0,0 +1 @@
+subdir('completion')
gitweb/meson.build new file +32 -0
new file mode 100644
index 00000000000..f9c3a766472
@@ -0,0 +1,32 @@
+configure_file(
+  input: 'gitweb.perl',
+  output: 'gitweb.cgi',
+  configuration: {
+    'GIT_VERSION': meson.project_version(),
+    'GIT_BINDIR': get_option('prefix') / get_option('bindir'),
+    'GITWEB_CONFIG': get_option('gitweb_config'),
+    'GITWEB_CONFIG_SYSTEM': get_option('gitweb_config_system'),
+    'GITWEB_CONFIG_COMMON': get_option('gitweb_config_common'),
+    'GITWEB_HOME_LINK_STR': get_option('gitweb_home_link_str'),
+    'GITWEB_SITENAME': get_option('gitweb_sitename'),
+    'GITWEB_PROJECTROOT': get_option('gitweb_projectroot'),
+    'GITWEB_PROJECT_MAXDEPTH': get_option('gitweb_project_maxdepth'),
+    'GITWEB_EXPORT_OK': get_option('gitweb_export_ok'),
+    'GITWEB_STRICT_EXPORT': get_option('gitweb_strict_export'),
+    'GITWEB_BASE_URL': get_option('gitweb_base_url'),
+    'GITWEB_LIST': get_option('gitweb_list'),
+    'GITWEB_HOMETEXT': get_option('gitweb_hometext'),
+    'GITWEB_CSS': get_option('gitweb_css'),
+    'GITWEB_LOGO': get_option('gitweb_logo'),
+    'GITWEB_FAVICON': get_option('gitweb_favicon'),
+    'GITWEB_JS': get_option('gitweb_js'),
+    'GITWEB_SITE_HTML_HEAD_STRING': get_option('gitweb_site_html_head_string'),
+    'GITWEB_SITE_HEADER': get_option('gitweb_site_header'),
+    'GITWEB_SITE_FOOTER': get_option('gitweb_site_footer'),
+    'HIGHLIGHT_BIN': get_option('highlight_bin'),
+  },
+  install: true,
+  install_dir: get_option('datadir') / 'gitweb',
+)
+
+subdir('static')
gitweb/static/meson.build new file +28 -0
new file mode 100644
index 00000000000..1bdbe70d2d6
@@ -0,0 +1,28 @@
+foreach asset : [
+  'git-favicon.png',
+  'git-logo.png',
+  'gitweb.css',
+]
+  fs.copyfile(asset,
+    install: true,
+    install_dir: get_option('datadir') / 'gitweb/static',
+  )
+endforeach
+
+javascript_sources = [
+  meson.current_source_dir() / 'js/adjust-timezone.js',
+  meson.current_source_dir() / 'js/blame_incremental.js',
+  meson.current_source_dir() / 'js/javascript-detection.js',
+  meson.current_source_dir() / 'js/lib/common-lib.js',
+  meson.current_source_dir() / 'js/lib/cookies.js',
+  meson.current_source_dir() / 'js/lib/datetime.js',
+]
+
+custom_target(
+  input: javascript_sources,
+  output: 'gitweb.js',
+  capture: true,
+  command: ['cat'] + javascript_sources,
+  install: true,
+  install_dir: get_option('datadir') / 'gitweb/static',
+)
meson.build new file +1607 -0

1,607 lines not on this page · raw message

meson_options.txt new file +70 -0

70 lines not on this page · raw message

perl/FromCPAN/Mail/meson.build new file +7 -0
new file mode 100644
index 00000000000..8cbd90ce184
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'Address.pm',
+  output: 'Address.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail',
+)
perl/FromCPAN/meson.build new file +9 -0
new file mode 100644
index 00000000000..ff88b35c2ca
@@ -0,0 +1,9 @@
+configure_file(
+  input: 'Error.pm',
+  output: 'Error.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/FromCPAN',
+)
+
+subdir('Mail')
perl/Git/LoadCPAN/Mail/meson.build new file +7 -0
new file mode 100644
index 00000000000..fbf324307bf
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'Address.pm',
+  output: 'Address.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail',
+)
perl/Git/LoadCPAN/meson.build new file +9 -0
new file mode 100644
index 00000000000..542e1082252
@@ -0,0 +1,9 @@
+configure_file(
+  input: 'Error.pm',
+  output: 'Error.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN',
+)
+
+subdir('Mail')
perl/Git/SVN/Memoize/meson.build new file +7 -0
new file mode 100644
index 00000000000..727375c8337
@@ -0,0 +1,7 @@
+configure_file(
+  input: 'YAML.pm',
+  output: 'YAML.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5/Git/SVN',
+)
perl/Git/SVN/meson.build new file +20 -0
new file mode 100644
index 00000000000..eccc3f2263d
@@ -0,0 +1,20 @@
+foreach source : [
+  'Editor.pm',
+  'Fetcher.pm',
+  'GlobSpec.pm',
+  'Log.pm',
+  'Migration.pm',
+  'Prompt.pm',
+  'Ra.pm',
+  'Utils.pm',
+]
+  configure_file(
+    input: source,
+    output: source,
+    configuration: perl_config,
+    install: true,
+    install_dir: get_option('datadir') / 'perl5/Git/SVN',
+  )
+endforeach
+
+subdir('Memoize')
perl/Git/meson.build new file +18 -0
new file mode 100644
index 00000000000..97bd62290d2
@@ -0,0 +1,18 @@
+foreach source : [
+  'I18N.pm',
+  'IndexInfo.pm',
+  'LoadCPAN.pm',
+  'Packet.pm',
+  'SVN.pm',
+]
+  configure_file(
+    input: source,
+    output: source,
+    configuration: perl_config,
+    install: true,
+    install_dir: get_option('datadir') / 'perl5/Git',
+  )
+endforeach
+
+subdir('LoadCPAN')
+subdir('SVN')
perl/meson.build new file +18 -0
new file mode 100644
index 00000000000..0a7bf41d5b9
@@ -0,0 +1,18 @@
+perl_config = {
+  'LOCALEDIR': get_option('prefix') / get_option('datadir') / 'locale',
+  'NO_GETTEXT': iconv.found() ? '' : '1',
+  'NO_PERL_CPAN_FALLBACKS': get_option('perl_cpan_fallback') ? '' : '1',
+}
+
+configure_file(
+  input: 'Git.pm',
+  output: 'Git.pm',
+  configuration: perl_config,
+  install: true,
+  install_dir: get_option('datadir') / 'perl5',
+)
+
+subdir('Git')
+if get_option('perl_cpan_fallback')
+  subdir('FromCPAN')
+endif
po/meson.build new file +28 -0
new file mode 100644
index 00000000000..fb1b92eb0a2
@@ -0,0 +1,28 @@
+i18n = import('i18n')
+
+translations = i18n.gettext('git',
+  languages: [
+    'bg',
+    'ca',
+    'de',
+    'el',
+    'es',
+    'fr',
+    'id',
+    'is',
+    'it',
+    'ko',
+    'pl',
+    'pt_PT',
+    'ru',
+    'sv',
+    'tr',
+    'uk',
+    'vi',
+    'zh_CN',
+    'zh_TW',
+  ],
+  install: true,
+  install_dir: get_option('datadir'),
+)
+test_dependencies += translations[0]
subprojects/curl.wrap new file +13 -0
new file mode 100644
index 00000000000..f7e384b85cf
@@ -0,0 +1,13 @@
+[wrap-file]
+directory = curl-8.10.1
+source_url = https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/curl_8.10.1-1/curl-8.10.1.tar.xz
+source_filename = curl-8.10.1.tar.xz
+source_hash = 73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee
+patch_filename = curl_8.10.1-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/curl_8.10.1-1/get_patch
+patch_hash = 707c28f35fc9b0e8d68c0c2800712007612f922a31da9637ce706a2159f3ddd8
+wrapdb_version = 8.10.1-1
+
+[provide]
+dependency_names = libcurl
subprojects/expat.wrap new file +13 -0
new file mode 100644
index 00000000000..2e0427dcfd1
@@ -0,0 +1,13 @@
+[wrap-file]
+directory = expat-2.6.3
+source_url = https://github.com/libexpat/libexpat/releases/download/R_2_6_3/expat-2.6.3.tar.xz
+source_filename = expat-2.6.3.tar.bz2
+source_hash = 274db254a6979bde5aad404763a704956940e465843f2a9bd9ed7af22e2c0efc
+patch_filename = expat_2.6.3-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.6.3-1/get_patch
+patch_hash = cf017fbe105e31428b2768360bd9be39094df4e948a1e8d1c54b6f7c76460cb1
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/expat_2.6.3-1/expat-2.6.3.tar.bz2
+wrapdb_version = 2.6.3-1
+
+[provide]
+expat = expat_dep
subprojects/openssl.wrap new file +15 -0
new file mode 100644
index 00000000000..873d55106e9
@@ -0,0 +1,15 @@
+[wrap-file]
+directory = openssl-3.0.8
+source_url = https://www.openssl.org/source/openssl-3.0.8.tar.gz
+source_filename = openssl-3.0.8.tar.gz
+source_hash = 6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e
+patch_filename = openssl_3.0.8-3_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/openssl_3.0.8-3/get_patch
+patch_hash = 300da189e106942347d61a4a4295aa2edbcf06184f8d13b4cee0bed9fb936963
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/openssl_3.0.8-3/openssl-3.0.8.tar.gz
+wrapdb_version = 3.0.8-3
+
+[provide]
+libcrypto = libcrypto_dep
+libssl = libssl_dep
+openssl = openssl_dep
subprojects/pcre2.wrap new file +16 -0
new file mode 100644
index 00000000000..7e184472543
@@ -0,0 +1,16 @@
+[wrap-file]
+directory = pcre2-10.44
+source_url = https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.bz2
+source_filename = pcre2-10.44.tar.bz2
+source_hash = d34f02e113cf7193a1ebf2770d3ac527088d485d4e047ed10e5d217c6ef5de96
+patch_filename = pcre2_10.44-2_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/pcre2_10.44-2/get_patch
+patch_hash = 4336d422ee9043847e5e10dbbbd01940d4c9e5027f31ccdc33a7898a1ca94009
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/pcre2_10.44-2/pcre2-10.44.tar.bz2
+wrapdb_version = 10.44-2
+
+[provide]
+libpcre2-8 = libpcre2_8
+libpcre2-16 = libpcre2_16
+libpcre2-32 = libpcre2_32
+libpcre2-posix = libpcre2_posix
subprojects/zlib.wrap new file +13 -0
new file mode 100644
index 00000000000..aa14de17740
@@ -0,0 +1,13 @@
+[wrap-file]
+directory = zlib-1.3.1
+source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz
+source_filename = zlib-1.3.1.tar.gz
+source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
+patch_filename = zlib_1.3.1-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch
+patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095
+wrapdb_version = 1.3.1-1
+
+[provide]
+zlib = zlib_dep
t/helper/meson.build new file +91 -0

91 lines not on this page · raw message

t/meson.build new file +1105 -0

942 lines not on this page · raw message

templates/hooks/meson.build new file +24 -0
new file mode 100644
index 00000000000..9bef5d7cfad

Lines of this file are not shown. View the raw message.

templates/info/meson.build new file +5 -0
new file mode 100644
index 00000000000..4ee1cfdf896

Lines of this file are not shown. View the raw message.

templates/meson.build new file +8 -0
new file mode 100644
index 00000000000..7428aaf1e6f

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.0.rc1.33.g90fe3800b9.dirty

Part of the diff is not shown here. View the raw message.

#73 lore raw

Re: [RFC PATCH v2 24/24] Introduce support for the Meson build system

meson.build line 424

Quoted 13 lines · Patrick Steinhardt
meson.build new file +13 -0
+script_environment = environment()
+foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
+  program = find_program(tool)
+  script_environment.prepend('PATH', fs.parent(program.full_path()))
+endforeach
+
+libgit_sources += custom_target(
+  'command-list.h',
+  input: 'command-list.txt',
+  output: 'command-list.h',
+  command: [shell, meson.current_source_dir() + '/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'],
+  env: script_environment,
+)

Maybe I am missing something about the necessity of this setting up of PATH? Should these programs not already be on PATH -- how does meson find them?

meson.build line 535

Quoted 7 lines
meson.build new file +7 -0
+zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
+if zlib.type_name() != 'internal' and not compiler.has_function('deflateBound',
+  prefix: '#include <zlib.h>',
+  dependencies: zlib,
+)
+  libgit_c_args += '-DNO_DEFLATE_BOUND'
+endif

Probably should have mentioned this earlier on, but.

What about

if zlib.version().version_compare('>=1.2.0')

    libgit_c_args += '-DNO_DEFLATE_BOUND'

endif

since that is when that function was added.

Signature · 1 line
Eli Schwartz
#74 lore raw

Re: [RFC PATCH v2 24/24] Introduce support for the Meson build system

Quoted 11 lines · Eli Schwartz
Quoted 10 lines · Patrick Steinhardt
meson.build new file +10 -0
+script_environment = environment()
+foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
+  program = find_program(tool)
+  script_environment.prepend('PATH', fs.parent(program.full_path()))
+endforeach
+
+libgit_sources += custom_target(
+  'command-list.h',
+  input: 'command-list.txt',
+  output: 'command-list.h',
Quoted 8 lines

meson.build line 424

Quoted 3 lines
meson.build new file +3 -0
+  command: [shell, meson.current_source_dir() + '/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'],
+  env: script_environment,
+)

Maybe I am missing something about the necessity of this setting up of PATH? Should these programs not already be on PATH -- how does meson find them?

It is required when generating the project file in one environment so that it can be used in another one. E.g. when using MinGW64 to generate the Visual Studio solution, where the tools are not in PATH anymore.

Quoted 11 lines

meson.build line 535

Quoted 7 lines
meson.build new file +7 -0
+zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
+if zlib.type_name() != 'internal' and not compiler.has_function('deflateBound',
+  prefix: '#include <zlib.h>',
+  dependencies: zlib,
+)
+  libgit_c_args += '-DNO_DEFLATE_BOUND'
+endif

Probably should have mentioned this earlier on, but.

Quoted 8 lines

What about

if zlib.version().version_compare('>=1.2.0')

    libgit_c_args += '-DNO_DEFLATE_BOUND'

endif

since that is when that function was added.

Arguably we can also just declare a minimum required zlib version nowadays. v1.2.0 has been released in 2011, more than a decade ago. But in any case, your version is certainly cleaner, thanks!

Patrick

#75 lore raw

Re: [RFC PATCH v2 00/24] Modernize our build system

In reply to Patrick Steinhardt
Quoted 2 lines · Patrick Steinhardt

- Patches 12 to 22 refactor parts of our build system to make proper out-of-tree builds a reality.

Oooooh.

#76 lore raw

Re: [RFC PATCH v2 00/24] Modernize our build system

Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Patrick Steinhardt

- Patches 12 to 22 refactor parts of our build system to make proper out-of-tree builds a reality.

Oooooh.

I hope I didn't get you too exited: not wired up in Makefiles! I was being a bit unclear here, it basically lands all the pieces required to make that happen, but the bits only get properly wired up by Meson. There is no reasony why we cannot have it in our Makefile, too, though.

Patrick

#77 lore raw

Re: [RFC PATCH v2 00/24] Modernize our build system

Quoted 6 lines · Patrick Steinhardt
Quoted 5 lines · Junio C Hamano
Quoted 2 lines · Patrick Steinhardt

- Patches 12 to 22 refactor parts of our build system to make proper out-of-tree builds a reality.

Quoted 6 lines
Quoted 1 line

Oooooh.

I hope I didn't get you too exited: not wired up in Makefiles! I was being a bit unclear here, it basically lands all the pieces required to make that happen, but the bits only get properly wired up by Meson. There is no reasony why we cannot have it in our Makefile, too, though.

To expand on this a bit: I was wondering whether I should do that though, as it would make it was easier to split up this whole patch series into multiple parts that all provide a benefit on their own:

- Part 1: the platform-specific fixes.

- Part 2: prepare us for proper (optional) out-of-tree builds, making things work with our Makefile. A lot of the parts are a prerequisite for Meson anyway.

- Part 3: the modern build system.

So if people think that this is worth it I'd be happy to do it this way.

Patrick

#78 lore raw

Re: [RFC PATCH v2 00/24] Modernize our build system

In reply to Patrick Steinhardt
Quoted 2 lines · Patrick Steinhardt

this is the second version of the patch series that modernizes our build system by introducing Meson. This series is still in an RFC state.

I'll keep it in the broken-out repository (https://github.com/gitster/git)
but eject it out of 'seen' for now. Builds with the topic seem to be unhappy with circular dependency,

cf. https://github.com/git/git/actions/runs/11299216196

#79 lore raw

Re: [RFC PATCH v2 00/24] Modernize our build system

Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Patrick Steinhardt

this is the second version of the patch series that modernizes our build system by introducing Meson. This series is still in an RFC state.

I'll keep it in the broken-out repository (https://github.com/gitster/git)
but eject it out of 'seen' for now. Builds with the topic seem to be unhappy with circular dependency,

I'll do the same for now. The latest version of the topic is in my tree as ps/build, and I'll keep it there until we can integrate it into 'seen' without breakage.

Quoted 1 line

cf. https://github.com/git/git/actions/runs/11299216196

Thanks,
Taylor

#80 lore raw

v3 cover Modernize the build system

In reply to Patrick Steinhardt

Hi,

this is the third version of my patch series that aims to modernize our build system infrastructure. It refactors our existing build infra to be ready for out-of-tree builds and then wires up Meson.

Changes compared to v2:

- I have split out semi-related changes like the platform compatibility fixes into separate series. More on that further down below, where I explain the current base.

- I have polished the CMake-related changes I've been doing as prereqs while refactoring our build system. Some of the changes weren't tested before, but now CMake works as expected.

- Fixed up some dependencies in our Makefile, as I didn't amend them to depend on the new generator scripts.

- I have extracted some more scripts to massage our Perl library code, shells cripts and gitweb.cgi such that they can be used by Make, CMake and Meson. This also fixes generation of "gitweb.cgi" on Meson as reported by Ramsay.

- I have fixed the cyclic dependency in our Makefile that I have introduced with v2.

- I have addressed some feedback regarding "build-systems.txt".

- I have made things work with OpenBSD 7.6.

- Things now work on Cygwin and MinGW64 as expected, no more test failures except for t9700, which also fails with our Makefile.

- I have improved how we set up the required tooling on Windows such that we detect Git for Windows-provided tools as we do with CMake. Like this, VS Code can now trivially import the Meson project and configure it. Furthermore, generation of the Visual Studio solution is trivial as well. So overall, things work fine now on all the important Windows environments that I'm aware of.

- Several smaller fixes all over the place.

I've included a range-diff, but it's quite crowded overall.

In general I think that this is in a pretty good shape now. I have tested things on NixOS, macOS 10.15, OpenBSD 7.6, FreeBSD 14.1, Windows 10 with MSVC, VS Code, MinGW and Cygwin, and things are generally smooth and just work. I'm sure there's still going to be weirdnesses on some platforms regardless of that.

This series is based on 15030f9556 (The second batch, 2024-10-15) and has the following dependencies:

- ps/cmake-clar at c6d3e52c91 (cmake: set up proper dependencies for generated clar headers, 2024-10-15).

- ps/upgrade-clar at f3501edb0e (Makefile: adjust sed command for

    generating "clar-decls.h", 2024-10-14).

- ps/platform-compat-fixes at 80ebd91b83 (http: fix build error on

    FreeBSD, 2024-10-16).

These deps are mostly just there to make tests pass on all platforms, but I wouldn't want folks to go test things and discover breakage that is not caused by Meson itself :) You can also find this version of the patch series at [1], branch "pks-meson-v3". @Taylor, I'm fine with keeping this out of "seen" if you prefer to wait for those dependencies to land first.

Thanks!

Patrick

[1]: https://gitlab.com/gitlab-org/git.git

Patrick Steinhardt (15):
Makefile: use common template for GIT-BUILD-OPTIONS
Makefile: consistently use @PLACEHOLDER@ to substitute
Makefile: consistently use PERL_PATH
Makefile: extract script to massage Perl scripts
Makefile: use "generate-perl.sh" to massage Perl library
Makefile: extract script to massage Shell scripts
Makefile: extract script to generate gitweb.cgi
Makefile: refactor GIT-VERSION-GEN to be reusable
Makefile: refactor generators to be PWD-independent
Makefile: allow "bin-wrappers/" directory to exist
Makefile: simplify building of templates
t: better support for out-of-tree builds
t: allow overriding build dir
Documentation: add comparison of build systems Introduce support for the Meson build system

 .gitignore                                    |    1 -
 Documentation/CodingGuidelines                |    2 +-
 Documentation/Makefile                        |    1 +
 Documentation/technical/build-systems.txt     |  224 +++
 GIT-BUILD-OPTIONS.in                          |   47 +
 GIT-VERSION-GEN                               |   12 +-
 Makefile                                      |  208 +--
 bin-wrappers/.gitignore                       |    9 +
 bin-wrappers/meson.build                      |   28 +
 bin-wrappers/wrap-for-bin.sh                  |   37 +
 configure.ac                                  |    2 +-
 contrib/buildsystems/CMakeLists.txt           |  218 ++-
 contrib/completion/meson.build                |    8 +
 contrib/meson.build                           |    1 +
 generate-cmdlist.sh                           |   42 +-
 generate-configlist.sh                        |   20 +-
 generate-hooklist.sh                          |   15 +-
 generate-perl.sh                              |   36 +
 generate-script.sh                            |   34 +
 git-cvsserver.perl                            |    2 +-
 git-instaweb.sh                               |    8 +-
 git-request-pull.sh                           |    2 +-
 git-send-email.perl                           |    2 +-
 git-sh-i18n.sh                                |    6 +-
 git-sh-setup.sh                               |    6 +-
 git-svn.perl                                  |    2 +-
 gitk-git/po/vi.po                             |    2 +-
 gitweb/GITWEB-BUILD-OPTIONS.in                |   25 +
 gitweb/Makefile                               |   58 +-
 gitweb/generate-gitweb.sh                     |   45 +
 gitweb/gitweb.perl                            |   44 +-
 gitweb/meson.build                            |   63 +
 meson.build                                   | 1614 +++++++++++++++++
 meson_options.txt                             |   70 +
 perl/FromCPAN/Mail/meson.build                |    7 +
 perl/FromCPAN/meson.build                     |    9 +
 perl/Git/I18N.pm                              |    6 +-
 perl/Git/LoadCPAN.pm                          |    6 +-
 perl/Git/LoadCPAN/Mail/meson.build            |    7 +
 perl/Git/LoadCPAN/meson.build                 |    9 +
 perl/Git/SVN/Memoize/meson.build              |    7 +
 perl/Git/SVN/meson.build                      |   20 +
 perl/Git/meson.build                          |   18 +
 .../header_templates/fixed_prefix.template.pl |    2 +-
 .../runtime_prefix.template.pl                |    8 +-
 perl/meson.build                              |   12 +
 po/meson.build                                |   28 +
 subprojects/.gitignore                        |    1 +
 subprojects/curl.wrap                         |   13 +
 subprojects/expat.wrap                        |   13 +
 subprojects/openssl.wrap                      |   15 +
 subprojects/pcre2.wrap                        |   16 +
 subprojects/zlib.wrap                         |   13 +
 t/helper/meson.build                          |   91 +
 t/lib-gettext.sh                              |    4 +-
 t/meson.build                                 | 1103 +++++++++++
 t/t7609-mergetool--lib.sh                     |    2 +-
 t/test-lib.sh                                 |   22 +-
 templates/Makefile                            |   39 +-
 templates/branches--                          |    1 -
 templates/{this--description => description}  |    0
 .../applypatch-msg.sample}                    |    0
 .../commit-msg.sample}                        |    0
 .../fsmonitor-watchman.sample}                |    0
 templates/hooks/meson.build                   |   24 +
 .../post-update.sample}                       |    0
 .../pre-applypatch.sample}                    |    0
 .../pre-commit.sample}                        |    0
 .../pre-merge-commit.sample}                  |    0
 .../pre-push.sample}                          |    0
 .../pre-rebase.sample}                        |    0
 .../pre-receive.sample}                       |    0
 .../prepare-commit-msg.sample}                |    0
 .../push-to-checkout.sample}                  |    0
 .../sendemail-validate.sample}                |    0
 .../update.sample}                            |    0
 templates/{info--exclude => info/exclude}     |    0
 templates/info/meson.build                    |    5 +
 templates/meson.build                         |   13 +
 unimplemented.sh                              |    2 +-
 wrap-for-bin.sh                               |   36 -
 81 files changed, 4040 insertions(+), 406 deletions(-)
 create mode 100644 Documentation/technical/build-systems.txt
 create mode 100644 GIT-BUILD-OPTIONS.in
 create mode 100644 bin-wrappers/.gitignore
 create mode 100644 bin-wrappers/meson.build
 create mode 100755 bin-wrappers/wrap-for-bin.sh
 create mode 100644 contrib/completion/meson.build
 create mode 100644 contrib/meson.build
 create mode 100755 generate-perl.sh
 create mode 100755 generate-script.sh
 create mode 100644 gitweb/GITWEB-BUILD-OPTIONS.in
 create mode 100755 gitweb/generate-gitweb.sh
 create mode 100644 gitweb/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 perl/FromCPAN/Mail/meson.build
 create mode 100644 perl/FromCPAN/meson.build
 create mode 100644 perl/Git/LoadCPAN/Mail/meson.build
 create mode 100644 perl/Git/LoadCPAN/meson.build
 create mode 100644 perl/Git/SVN/Memoize/meson.build
 create mode 100644 perl/Git/SVN/meson.build
 create mode 100644 perl/Git/meson.build
 create mode 100644 perl/meson.build
 create mode 100644 po/meson.build
 create mode 100644 subprojects/.gitignore
 create mode 100644 subprojects/curl.wrap
 create mode 100644 subprojects/expat.wrap
 create mode 100644 subprojects/openssl.wrap
 create mode 100644 subprojects/pcre2.wrap
 create mode 100644 subprojects/zlib.wrap
 create mode 100644 t/helper/meson.build
 create mode 100644 t/meson.build
 delete mode 100644 templates/branches--
 rename templates/{this--description => description} (100%)
 rename templates/{hooks--applypatch-msg.sample => hooks/applypatch-msg.sample} (100%)
 rename templates/{hooks--commit-msg.sample => hooks/commit-msg.sample} (100%)
 rename templates/{hooks--fsmonitor-watchman.sample => hooks/fsmonitor-watchman.sample} (100%)
 create mode 100644 templates/hooks/meson.build
 rename templates/{hooks--post-update.sample => hooks/post-update.sample} (100%)
 rename templates/{hooks--pre-applypatch.sample => hooks/pre-applypatch.sample} (100%)
 rename templates/{hooks--pre-commit.sample => hooks/pre-commit.sample} (100%)
 rename templates/{hooks--pre-merge-commit.sample => hooks/pre-merge-commit.sample} (100%)
 rename templates/{hooks--pre-push.sample => hooks/pre-push.sample} (100%)
 rename templates/{hooks--pre-rebase.sample => hooks/pre-rebase.sample} (100%)
 rename templates/{hooks--pre-receive.sample => hooks/pre-receive.sample} (100%)
 rename templates/{hooks--prepare-commit-msg.sample => hooks/prepare-commit-msg.sample} (100%)
 rename templates/{hooks--push-to-checkout.sample => hooks/push-to-checkout.sample} (100%)
 rename templates/{hooks--sendemail-validate.sample => hooks/sendemail-validate.sample} (100%)
 rename templates/{hooks--update.sample => hooks/update.sample} (100%)
 rename templates/{info--exclude => info/exclude} (100%)
 create mode 100644 templates/info/meson.build
 create mode 100644 templates/meson.build
 delete mode 100644 wrap-for-bin.sh

Range-diff against v2:

 1:  6dd59db9b2b <  -:  ----------- t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE
 2:  5ec91ac12da <  -:  ----------- t/test-lib: wire up NO_ICONV prerequisite
 3:  94664e2cc06 <  -:  ----------- t/lib-gitweb: test against the build version of gitweb
 4:  ffb661dad71 <  -:  ----------- t/lib-gpg: fix setup of GNUPGHOME in MinGW
 5:  958cf3a6b57 <  -:  ----------- t1401: make invocation of tar(1) work with Win32-provided one
 6:  bada3a82fdd <  -:  ----------- t3404: work around platform-specific behaviour on macOS 10.15
 7:  b4bdefe9e34 <  -:  ----------- t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
 8:  48ce19d876f <  -:  ----------- t7300: work around platform-specific behaviour with long paths on MinGW
 9:  73b4362164a <  -:  ----------- t/unit-tests: update clar unit test framework
10:  161f6b063af <  -:  ----------- builtin/credential-cache: fix missing parameter for stub function
11:  e4ef4bdf1c5 <  -:  ----------- http: fix build error on FreeBSD
12:  6ea97bc92f2 <  -:  ----------- Makefile: extract script to generate clar declarations
16:  dbf9e39e3df =  1:  800fb080f45 Makefile: use common template for GIT-BUILD-OPTIONS
17:  97b9789dd68 !  2:  1a4a23c66ca Makefile: consistently use @PLACEHOLDER@ to substitute

@@ Makefile: GIT-SCRIPT-DEFINES: FORCE
[email protected] >$@+
endef

+@@ Makefile: $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
+ -e ' r GIT-PERL-HEADER' \
+ -e ' G' \
+ -e '}' \
+- -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
++ -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
+ $< >$@+ && \
+ chmod +x $@+ && \
+ mv $@+ $@
@@ Makefile: GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
INSTLIBDIR='$(perllibdir_SQ)' && \
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
@@ contrib/buildsystems/CMakeLists.txt: set(wrapper_test_scripts

#options for configuring test options

- ## generate-perl.sh ##
-@@ generate-perl.sh: sed -e '1{' \
- -e " r $PERL_HEADER" \
- -e ' G' \
- -e '}' \
-- -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
-+ -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
- "$PERL_SCRIPT" >"$OUT"
- chmod a+x "$OUT"
-
## git-cvsserver.perl ##
@@
use File::Basename;

18:  1ee9c61fc33 =  3:  8261f108968 Makefile: consistently use PERL_PATH
13:  7f567d7ce23 !  4:  4894179b948 Makefile: extract script to massage Perl scripts
    @@ Commit message
     
      ## Makefile ##
     @@ Makefile: endif
    + 
      PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
      
    - $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
    +-$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
     -	$(QUIET_GEN) \
     -	sed -e '1{' \
     -	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
     -	    -e '	r GIT-PERL-HEADER' \
     -	    -e '	G' \
     -	    -e '}' \
    --	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
    +-	    -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
     -	    $< >$@+ && \
     -	chmod +x $@+ && \
    -+	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh $(GIT_VERSION) GIT-PERL-HEADER "$(PERL_PATH_SQ)" "$<" "$@+" && \
    ++$(SCRIPT_PERL_GEN): % : %.perl generate-perl.sh GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
    ++	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh ./GIT-BUILD-OPTIONS $(GIT_VERSION) GIT-PERL-HEADER "$<" "$@+" && \
      	mv $@+ $@
      
      PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
     
    + ## contrib/buildsystems/CMakeLists.txt ##
    +@@ contrib/buildsystems/CMakeLists.txt: foreach(script ${git_shell_scripts})
    + endforeach()
    + 
    + #perl scripts
    +-parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
    ++parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
    + 
    + #create perl header
    + file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
    + string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
    + string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
    ++file(WRITE ${CMAKE_BINARY_DIR}/PERL-HEADER ${perl_header})
    + 
    + foreach(script ${git_perl_scripts})
    +-	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
    +-	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
    +-	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
    +-	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
    ++	string(REPLACE ".perl" "" perl_gen_path "${script}")
    ++
    ++	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${perl_gen_path}
    ++		COMMAND ${CMAKE_SOURCE_DIR}/generate-perl.sh
    ++			${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS
    ++			${PROJECT_VERSION}
    ++			${CMAKE_BINARY_DIR}/PERL-HEADER
    ++			${CMAKE_SOURCE_DIR}/${script}
    ++			${CMAKE_BINARY_DIR}/${perl_gen_path}
    ++		DEPENDS ${CMAKE_SOURCE_DIR}/generate-perl.sh
    ++			${CMAKE_SOURCE_DIR}/${script})
    ++	list(APPEND perl_gen ${CMAKE_BINARY_DIR}/${perl_gen_path})
    + endforeach()
    ++add_custom_target(perl-gen ALL DEPENDS ${perl_gen})
    + 
    + #python script
    + file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
    +
      ## generate-perl.sh (new) ##
     @@
     +#!/bin/sh
     +
    ++set -e
    ++
     +if test $# -ne 5
     +then
    -+	echo "USAGE: $0 <GIT_VERSION> <PERL_HEADER> <PERL_PATH> <PERL_SCRIPT> <OUT>" >&2
    ++	echo "USAGE: $0 <GIT_BUILD_OPTIONS> <GIT_VERSION> <PERL_HEADER> <INPUT> <OUTPUT>" >&2
     +	exit 1
     +fi
     +
    -+GIT_VERSION="$1"
    -+PERL_HEADER="$2"
    -+PERL_PATH="$3"
    -+PERL_SCRIPT="$4"
    -+OUT="$5"
    ++GIT_BUILD_OPTIONS="$1"
    ++GIT_VERSION="$2"
    ++PERL_HEADER="$3"
    ++INPUT="$4"
    ++OUTPUT="$5"
    ++
    ++. "$GIT_BUILD_OPTIONS"
     +
     +sed -e '1{' \
     +    -e "	s|#!.*perl|#!$PERL_PATH|" \
     +    -e "	r $PERL_HEADER" \
     +    -e '	G' \
     +    -e '}' \
    -+    -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \
    -+    "$PERL_SCRIPT" >"$OUT"
    -+chmod a+x "$OUT"
    ++    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
    ++    "$INPUT" >"$OUTPUT"
    ++chmod a+x "$OUTPUT"
 -:  ----------- >  5:  b40bc302291 Makefile: use "generate-perl.sh" to massage Perl library
 -:  ----------- >  6:  c13ce99be3a Makefile: extract script to massage Shell scripts
 -:  ----------- >  7:  ebffd855836 Makefile: extract script to generate gitweb.cgi
14:  dfc941cd18d !  8:  d2cdfad10f5 Makefile: refactor GIT-VERSION-GEN to be reusable

@@ Commit message
easier to compute the same version as our Makefile would without having to write the "GIT-VERSION-FILE".

- We should ideally refactor our CMake build instructions to stop writing
- into the source directory. But this step is out of scope of the current
- patch series.
-

## GIT-VERSION-GEN ##
@@ GIT-VERSION-GEN
#!/bin/sh

-GVF=GIT-VERSION-FILE
- DEF_VER=v2.47.0
+ DEF_VER=v2.47.GIT

LF='
@@ GIT-VERSION-GEN: fi
@@ Makefile: include shared.mak
# Set our default configuration.

## contrib/buildsystems/CMakeLists.txt ##
-@@ contrib/buildsystems/CMakeLists.txt: endif()
- if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
- message("Generating GIT-VERSION-FILE")
- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
-- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-+ OUTPUT_VARIABLE GIT_VERSION
-+ OUTPUT_STRIP_TRAILING_WHITESPACE)
-+ file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "GIT_VERSION = '${GIT_VERSION}'\n")
+@@ contrib/buildsystems/CMakeLists.txt: if(NOT SH_EXE)
+ "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
endif()

+-#Create GIT-VERSION-FILE using GIT-VERSION-GEN
+-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
+- message("Generating GIT-VERSION-FILE")
+- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
+- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+-endif()
++execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
++ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
++ OUTPUT_VARIABLE git_version
++ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
#Parse GIT-VERSION-FILE to get the version
+-file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)") +-string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
+ string(FIND ${git_version} "GIT" location)
+ if(location EQUAL -1)
+ string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
15: e468d3751f0 ! 9: 9be0719ce1b Makefile: refactor generators to be PWD-independent

    @@ contrib/buildsystems/CMakeLists.txt: set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS
     -	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
     -			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     -			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
    -+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/config.list)
    ++	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/config-list.h)
      endif()
      
      if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h)
19:  9fd1aeb1e96 ! 10:  93869e53178 Makefile: allow "bin-wrappers/" directory to exist
    @@ Makefile: test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_
      
     -bin-wrappers/%: wrap-for-bin.sh
     -	$(call mkdir_p_parent_template)
    -+bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
    ++$(test_bindir_programs): bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
      	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
      	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
      	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \

20: 4eda54cf0f5 ! 11: 1c37d6d1f19 Makefile: simplify building of templates
@@ Commit message

## contrib/buildsystems/CMakeLists.txt ##
-@@ contrib/buildsystems/CMakeLists.txt: endforeach() +@@ contrib/buildsystems/CMakeLists.txt: project(git
+ #TODO Enable NLS on windows natively

+ #macros for parsing the Makefile for sources and scripts +-macro(parse_makefile_for_sources list_var regex)
+- file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
++macro(parse_makefile_for_sources list_var makefile regex)
++ file(STRINGS ${makefile} ${list_var} REGEX "^${regex} \\+=(.*)")
+ string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+ string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+ string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+@@ contrib/buildsystems/CMakeLists.txt: include_directories(${CMAKE_BINARY_DIR})

- #templates
--file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
-+file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/**")
- list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
- list(REMOVE_ITEM templates ".gitignore")
- list(REMOVE_ITEM templates "Makefile")
- list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
+ #build
+ #libgit
+-parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS") ++parse_makefile_for_sources(libgit_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "LIB_OBJS") +
+ list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+ list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+ add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+ #libxdiff
+-parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS") ++parse_makefile_for_sources(libxdiff_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "XDIFF_OBJS") +
+ list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+ add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+ #reftable
+-parse_makefile_for_sources(reftable_SOURCES "REFTABLE_OBJS") ++parse_makefile_for_sources(reftable_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "REFTABLE_OBJS") +
+ list(TRANSFORM reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+ add_library(reftable STATIC ${reftable_SOURCES})
+@@ contrib/buildsystems/CMakeLists.txt: elseif(UNIX)
+ endif()
+
+ #git
+-parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS") ++parse_makefile_for_sources(git_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "BUILTIN_OBJS")

+ list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+ add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
+@@ contrib/buildsystems/CMakeLists.txt: file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+ string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+ file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+-#templates
+-file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
+-list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
+-list(REMOVE_ITEM templates ".gitignore")
+-list(REMOVE_ITEM templates "Makefile")
+-list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds +-
-list(REMOVE_ITEM templates "branches--")
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
-
++#${CMAKE_SOURCE_DIR}/Makefile templates
++parse_makefile_for_sources(templates ${CMAKE_SOURCE_DIR}/templates/Makefile "TEMPLATES") ++string(REPLACE " " ";" templates ${templates})
#templates have @.*@ replacement so use configure_file instead
foreach(tm ${templates})
- string(REPLACE "--" "/" blt_tm ${tm})
- string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
- configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
+- configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
++ configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${tm} @ONLY)
endforeach()

-
#translations
if(MSGFMT_EXE)
file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
+@@ contrib/buildsystems/CMakeLists.txt: add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
+ target_link_libraries(test-fake-ssh common-main)
+
+ #unit-tests
+-parse_makefile_for_sources(unit-test_SOURCES "UNIT_TEST_OBJS") ++parse_makefile_for_sources(unit-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "UNIT_TEST_OBJS")
+ list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
+ add_library(unit-test-lib STATIC ${unit-test_SOURCES})
+
+@@ contrib/buildsystems/CMakeLists.txt: if(MSVC)
+ endif()
+
+ #test-tool
+-parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS") ++parse_makefile_for_sources(test-tool_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "TEST_BUILTINS_OBJS")
+ add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
+
+ list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")

## templates/Makefile ##
@@ templates/Makefile: all: boilerplates.made custom
@@ templates/Makefile: all: boilerplates.made custom
-boilerplates.made : $(bpsrc)
- $(QUIET)umask 022 && ls *--* 2>/dev/null | \
- while read boilerplate; \
-+TEMPLATES = description
++TEMPLATES =
++TEMPLATES += description
+TEMPLATES += hooks/applypatch-msg.sample
+TEMPLATES += hooks/commit-msg.sample
+TEMPLATES += hooks/fsmonitor-watchman.sample
21: 1172c440600 ! 12: c45d2df6b8d t: better support for out-of-tree builds

    @@ GIT-BUILD-OPTIONS.in: GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
     +GIT_TEST_GITPERLLIB=@GIT_TEST_GITPERLLIB@
     +GIT_TEST_MERGE_TOOLS_DIR=@GIT_TEST_MERGE_TOOLS_DIR@
      RUNTIME_PREFIX=@RUNTIME_PREFIX@
    + GITWEBDIR=@GITWEBDIR@
    + USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
     
      ## Makefile ##
     @@ Makefile: GIT-BUILD-OPTIONS: FORCE
    @@ Makefile: GIT-BUILD-OPTIONS: FORCE
     +		-e "s|@GIT_TEST_GITPERLLIB@|\'$(shell pwd)/perl/build/lib\'|" \
     +		-e "s|@GIT_TEST_MERGE_TOOLS_DIR@|\'$(shell pwd)/mergetools\'|" \
      		-e "s|@RUNTIME_PREFIX@|\'$(RUNTIME_PREFIX)\'|" \
    - 		GIT-BUILD-OPTIONS.in >$@+
    - 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
    + 		-e "s|@GITWEBDIR@|\'$(gitwebdir_SQ)\'|" \
    + 		-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
     @@ Makefile: all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
    - bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
    + $(test_bindir_programs): bin-wrappers/%: bin-wrappers/wrap-for-bin.sh
      	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
      	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
     +	     -e 's|@GIT_TEXTDOMAINDIR@|$(shell pwd)/po/build/locale|' \
    @@ contrib/buildsystems/CMakeLists.txt: endforeach()
      string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
      file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
      
    -@@ contrib/buildsystems/CMakeLists.txt: string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_optio
    +@@ contrib/buildsystems/CMakeLists.txt: string(REPLACE "@GIT_PERF_MAKE_COMMAND@" "" git_build_options "${git_build_optio
    + string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_options}")
      string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
      string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
    - string(REPLACE "@RUNTIME_PREFIX@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
     +string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" git_build_options "${git_build_options}")
     +string(REPLACE "@GIT_TEST_POPATH@" "${CMAKE_BINARY_DIR}/po" git_build_options "${git_build_options}")
     +string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "${CMAKE_BINARY_DIR}/templates/blt" git_build_options "${git_build_options}")
     +string(REPLACE "@GIT_TEST_GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" git_build_options "${git_build_options}")
     +string(REPLACE "@GIT_TEST_MERGE_TOOLS_DIR@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
    - if(USE_VCPKG)
    - 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
    - endif()
    + string(REPLACE "@RUNTIME_PREFIX@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
    + string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" git_build_options "${git_build_options}")
    + string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
     
      ## t/lib-gettext.sh ##
     @@
22:  b5cd5250b77 = 13:  542b01515e1 t: allow overriding build dir
23:  afa2f79d46c ! 14:  bd59e31bb55 Documentation: add comparison of build systems

@@ Documentation/technical/build-systems.txt (new)
+== Requirements
+
+The following subsections present a list of requirements that we have for any
-+potential build system. Sections are sorted by decreasing priority, even though -+these priorities will naturally differ between users.
++potential build system. Sections are sorted by decreasing priority.
+
+=== Platform support
+
-+The build system must have support for all of our primary platforms as outlined -+by. These platforms are:
++The build system must have support for all of our platforms that we continually ++test against as outlined by our platform support policy. These platforms are:
+
+ - Linux
+ - Windows
+ - macOS
+
-+Furthermore, the build system should have support for the following secondary -+platforms:
++Furthermore, the build system should have support for the following platforms ++that generally have somebody running test pipelines against regularly:
+
+ - AIX
+ - FreeBSD
+ - NetBSD
++ - NonStop
+ - OpenBSD
+
+The platforms which must be supported by the tool should be aligned with our
@@ Documentation/technical/build-systems.txt (new)
+ - Detection of available features.
+ - Discovery of relevant toolchains.
+ - Linking libraries and executables.
++ - Templating placeholders in scripts.
+
+=== Test integration
+
@@ Documentation/technical/build-systems.txt (new)
+ - Track build-time dependencies for respective tests. Unit tests have
+ different requirements than integration tests.
+ - Allow filtering of which tests to run.
-+ - Allow interactive tests that drop the user into a shell with test_pause or
-+ debug.
++ - Allow running tests such that utilities like test_pause or debug work.
+
+== Comparison
+
24: 724232b0fad ! 15: ac327d98e9c Introduce support for the Meson build system
@@ Commit message

- Apple macOS 10.15.

- - FreeBSD 14.1, except gitweb-based tests.
+ - FreeBSD 14.1.

- NixOS 24.11.

+ - OpenBSD 7.6.
+
- Ubuntu 24.04.

- - Windows 10 with Cygwin, using -Dperl=disabled -Dpython=disabled.
+ - Windows 10 with Cygwin.
+
+ - Windows 10 with MinGW64, except for t9700, which is also broken with
+ our Makefile.
+
+ - Windows 10 with Visual Studio 2022 toolchain, using the Native Tools
+ Command Prompt with meson setup --vsenv. Tests pass, except for
+ t9700.

- - Windows 10 with MinGW64, using -Dperl=disabled -Dpython=disabled.
+ - Windows 10 with Visual Studio 2022 solution, using the Native Tools
+ Command Prompt with meson setup --backend vs2022. Tests pass,
+ except for t9700.

- - Windows 10 with MSVC 2022, using `-Dperl=disabled -Dpython=disabled
- -Dgettext=disabled -Diconv=disabled --wrap-mode=forcefallback`.
+ - Windows 10 with VS Code, using the Meson plug-in.

It is expected that there will still be rough edges in the current version. If this patch lands the expectation is that it will coexist
@@ Commit message
dependencies preinstalled, and Meson will fetch and build them automatically. This is especially helpful on Windows.

+ Helped-by: Eli Schwartz <[email protected]>

## bin-wrappers/meson.build (new) ##
@@ contrib/meson.build (new)

## gitweb/meson.build (new) ##
@@
++gitweb_config = configuration_data()
++gitweb_config.set_quoted('PERL_PATH', perl.full_path()) ++gitweb_config.set_quoted('CSSMIN', '')
++gitweb_config.set_quoted('JSMIN', '')
++gitweb_config.set_quoted('GIT_VERSION', git_version) ++gitweb_config.set_quoted('GIT_BINDIR', get_option('prefix') / get_option('bindir')) ++gitweb_config.set_quoted('GITWEB_CONFIG', get_option('gitweb_config')) ++gitweb_config.set_quoted('GITWEB_CONFIG_SYSTEM', get_option('gitweb_config_system')) ++gitweb_config.set_quoted('GITWEB_CONFIG_COMMON', get_option('gitweb_config_common')) ++gitweb_config.set_quoted('GITWEB_HOME_LINK_STR', get_option('gitweb_home_link_str')) ++gitweb_config.set_quoted('GITWEB_SITENAME', get_option('gitweb_sitename')) ++gitweb_config.set_quoted('GITWEB_PROJECTROOT', get_option('gitweb_projectroot')) ++gitweb_config.set_quoted('GITWEB_PROJECT_MAXDEPTH', get_option('gitweb_project_maxdepth')) ++gitweb_config.set_quoted('GITWEB_EXPORT_OK', get_option('gitweb_export_ok')) ++gitweb_config.set_quoted('GITWEB_STRICT_EXPORT', get_option('gitweb_strict_export')) ++gitweb_config.set_quoted('GITWEB_BASE_URL', get_option('gitweb_base_url')) ++gitweb_config.set_quoted('GITWEB_LIST', get_option('gitweb_list')) ++gitweb_config.set_quoted('GITWEB_HOMETEXT', get_option('gitweb_hometext')) ++gitweb_config.set_quoted('GITWEB_CSS', get_option('gitweb_css')) ++gitweb_config.set_quoted('GITWEB_LOGO', get_option('gitweb_logo')) ++gitweb_config.set_quoted('GITWEB_FAVICON', get_option('gitweb_favicon')) ++gitweb_config.set_quoted('GITWEB_JS', get_option('gitweb_js')) ++gitweb_config.set_quoted('GITWEB_SITE_HTML_HEAD_STRING', get_option('gitweb_site_html_head_string')) ++gitweb_config.set_quoted('GITWEB_SITE_HEADER', get_option('gitweb_site_header')) ++gitweb_config.set_quoted('GITWEB_SITE_FOOTER', get_option('gitweb_site_footer')) ++gitweb_config.set_quoted('HIGHLIGHT_BIN', get_option('highlight_bin'))
++
+configure_file(
++ input: 'GITWEB-BUILD-OPTIONS.in',
++ output: 'GITWEB-BUILD-OPTIONS',
++ configuration: gitweb_config,
++)
++
++test_dependencies += custom_target(script,
+ input: 'gitweb.perl',
+ output: 'gitweb.cgi',
-+ configuration: {
-+ 'GIT_VERSION': meson.project_version(),
-+ 'GIT_BINDIR': get_option('prefix') / get_option('bindir'),
-+ 'GITWEB_CONFIG': get_option('gitweb_config'),
-+ 'GITWEB_CONFIG_SYSTEM': get_option('gitweb_config_system'),
-+ 'GITWEB_CONFIG_COMMON': get_option('gitweb_config_common'),
-+ 'GITWEB_HOME_LINK_STR': get_option('gitweb_home_link_str'),
-+ 'GITWEB_SITENAME': get_option('gitweb_sitename'),
-+ 'GITWEB_PROJECTROOT': get_option('gitweb_projectroot'),
-+ 'GITWEB_PROJECT_MAXDEPTH': get_option('gitweb_project_maxdepth'),
-+ 'GITWEB_EXPORT_OK': get_option('gitweb_export_ok'),
-+ 'GITWEB_STRICT_EXPORT': get_option('gitweb_strict_export'),
-+ 'GITWEB_BASE_URL': get_option('gitweb_base_url'),
-+ 'GITWEB_LIST': get_option('gitweb_list'),
-+ 'GITWEB_HOMETEXT': get_option('gitweb_hometext'),
-+ 'GITWEB_CSS': get_option('gitweb_css'),
-+ 'GITWEB_LOGO': get_option('gitweb_logo'),
-+ 'GITWEB_FAVICON': get_option('gitweb_favicon'),
-+ 'GITWEB_JS': get_option('gitweb_js'),
-+ 'GITWEB_SITE_HTML_HEAD_STRING': get_option('gitweb_site_html_head_string'),
-+ 'GITWEB_SITE_HEADER': get_option('gitweb_site_header'),
-+ 'GITWEB_SITE_FOOTER': get_option('gitweb_site_footer'),
-+ 'HIGHLIGHT_BIN': get_option('highlight_bin'),
-+ },
++ command: [
++ shell,
++ meson.current_source_dir() / 'generate-gitweb.sh',
++ meson.current_build_dir() / 'GITWEB-BUILD-OPTIONS',
++ '@INPUT@',
++ '@OUTPUT@',
++ ],
+ install: true,
+ install_dir: get_option('datadir') / 'gitweb',
+)
+
-+subdir('static')
-
- ## gitweb/static/meson.build (new) ##
-@@
+foreach asset : [
-+ 'git-favicon.png',
-+ 'git-logo.png',
-+ 'gitweb.css',
++ 'static/git-favicon.png',
++ 'static/git-logo.png',
++ 'static/gitweb.css',
++ 'static/js/adjust-timezone.js',
++ 'static/js/blame_incremental.js',
++ 'static/js/javascript-detection.js',
++ 'static/js/lib/common-lib.js',
++ 'static/js/lib/cookies.js',
++ 'static/js/lib/datetime.js',
+]
+ fs.copyfile(asset,
+ install: true,
-+ install_dir: get_option('datadir') / 'gitweb/static',
++ install_dir: get_option('datadir') / 'gitweb' / fs.parent(asset),
+ )
+endforeach
-+
-+javascript_sources = [
-+ meson.current_source_dir() / 'js/adjust-timezone.js',
-+ meson.current_source_dir() / 'js/blame_incremental.js',
-+ meson.current_source_dir() / 'js/javascript-detection.js',
-+ meson.current_source_dir() / 'js/lib/common-lib.js',
-+ meson.current_source_dir() / 'js/lib/cookies.js',
-+ meson.current_source_dir() / 'js/lib/datetime.js',
-+]
-+
-+custom_target(
-+ input: javascript_sources,
-+ output: 'gitweb.js',
-+ capture: true,
-+ command: ['cat'] + javascript_sources,
-+ install: true,
-+ install_dir: get_option('datadir') / 'gitweb/static',
-+)

## meson.build (new) ##
@@
@@ meson.build (new)
+ # MSVC does not support GNU99, and C99 does not define __STDC_VERSION__
+ # on MSVC. So we instead fall back to C11 there.
+ default_options: ['c_std=gnu99,c11'],
-+ version: run_command('GIT-VERSION-GEN', check: true).stdout().strip(),
++ version: 'v2.47.GIT',
+)
+
+fs = import('fs')
+
-+compiler = meson.get_compiler('c')
++program_path = []
++# Git for Windows provides all the tools we need to build Git.
++if host_machine.system() == 'windows'
++ program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
++endif
+
-+cygpath = find_program('cygpath', required: false)
-+shell = find_program('sh')
-+tar = find_program('tar')
-+diff = find_program('diff')
++awk = find_program('awk', dirs: program_path)
++cygpath = find_program('cygpath', dirs: program_path, required: false)
++diff = find_program('diff', dirs: program_path)
++shell = find_program('sh', dirs: program_path)
++tar = find_program('tar', dirs: program_path)
++
++script_environment = environment()
++foreach tool : ['cat', 'cut', 'git', 'grep', 'sed', 'sort', 'tr', 'uname']
++ program = find_program(tool, dirs: program_path)
++ script_environment.prepend('PATH', fs.parent(program.full_path()))
++endforeach
++
++git_version = run_command(shell, 'GIT-VERSION-GEN', check: false, env: script_environment).stdout().strip() ++if git_version == ''
++ git_version = meson.project_version()
++endif
++
++compiler = meson.get_compiler('c')
+
+libgit_sources = [
+ 'abspath.c',
@@ meson.build (new)
+ 'reftable/block.c',
+ 'reftable/blocksource.c',
+ 'reftable/iter.c',
-+ 'reftable/publicbasics.c',
+ 'reftable/merged.c',
+ 'reftable/pq.c',
+ 'reftable/reader.c',
@@ meson.build (new)
+ 'builtin/write-tree.c',
+]
+
-+script_environment = environment()
-+foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
-+ program = find_program(tool)
-+ script_environment.prepend('PATH', fs.parent(program.full_path()))
-+endforeach
-+
+libgit_sources += custom_target(
+ 'command-list.h',
+ input: 'command-list.txt',
@@ meson.build (new)
+build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
+build_options_config.set('SANITIZE_ADDRESS', '')
+build_options_config.set('SANITIZE_LEAK', '')
++build_options_config.set('BROKEN_PATH_FIX', '')
++build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir'))) ++build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
+
+test_output_directory = get_option('test_output_directory')
+if test_output_directory == ''
@@ meson.build (new)
+
+# Note that we only set NO_PERL if the Perl features were disabled by the user.
+# It may not be set when we have found Perl, but only use it to run tests.
-+perl = find_program('perl', version: '>=5.8.1', required: perl_required)
++perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
+perl_features_enabled = perl.found() and get_option('perl').allowed()
+if perl_features_enabled
+ build_options_config.set('NO_PERL', '')
++
++ if get_option('runtime_prefix')
++ build_options_config.set('PERL_LOCALEDIR', '')
++ else
++ build_options_config.set_quoted('PERL_LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
++ endif
++
++ if get_option('perl_cpan_fallback')
++ build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
++ else
++ build_options_config.set_quoted('NO_PERL_CPAN_FALLBACKS', 'YesPlease')
++ endif
+else
+ libgit_c_args += '-DNO_PERL'
+ build_options_config.set('NO_PERL', '1')
++ build_options_config.set('PERL_LOCALEDIR', '')
++ build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
+endif
+
+zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
-+if zlib.type_name() != 'internal' and not compiler.has_function('deflateBound',
-+ prefix: '#include <zlib.h>',
-+ dependencies: zlib,
-+)
++if zlib.version().version_compare('<1.2.0')
+ libgit_c_args += '-DNO_DEFLATE_BOUND'
+endif
+libgit_dependencies += zlib
@@ meson.build (new)
+if intl.found()
+ libgit_dependencies += intl
+ build_options_config.set('NO_GETTEXT', '')
++ build_options_config.set('USE_GETTEXT_SCHEME', '')
+else
+ libgit_c_args += '-DNO_GETTEXT'
+ build_options_config.set('NO_GETTEXT', '1')
++ build_options_config.set('USE_GETTEXT_SCHEME', 'fallthrough')
+endif
+
+iconv = dependency('iconv', required: get_option('iconv'))
@@ meson.build (new)
+libgit_version_library = static_library('git-version',
+ sources: ['version.c'],
+ c_args: libgit_c_args + [
-+ '-DGIT_VERSION="' + meson.project_version() + '"',
-+ '-DGIT_USER_AGENT="' + 'git/' + meson.project_version() + '"',
++ '-DGIT_VERSION="' + git_version + '"',
++ '-DGIT_USER_AGENT="' + 'git/' + git_version + '"',
+ '-DGIT_BUILT_FROM_COMMIT="' + run_command('git', 'rev-parse', '-q', '--verify', 'HEAD', check: false).stdout().strip() + '"',
+ ],
+ dependencies: libgit_dependencies,
@@ meson.build (new)
+ '-DMINOR=1',
+ '-DMICRO=1',
+ '-DPATCHLEVEL=0',
-+ '-DGIT_VERSION=\\\"' + meson.project_version() + '.GIT\\\"',
++ '-DGIT_VERSION=\\\"' + git_version + '.GIT\\\"',
+ ])
+ if compiler.get_argument_syntax() == 'gcc'
+ common_main_link_args += [
@@ meson.build (new)
+ )
+endforeach
+
-+script_sh_config = configuration_data()
-+script_sh_config.set('BROKEN_PATH_FIX', '')
-+script_sh_config.set('DIFF', fs.as_posix(diff.full_path()))
-+script_sh_config.set('PAGER_ENV', get_option('pager_environment'))
-+script_sh_config.set('PERL_PATH', perl.found() ? fs.as_posix(perl.full_path()) : '') -+script_sh_config.set('SHELL_PATH', fs.as_posix(shell.full_path()))
-+script_sh_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
-+if intl.found()
-+ script_sh_config.set('USE_GETTEXT_SCHEME', '')
-+else
-+ script_sh_config.set('USE_GETTEXT_SCHEME', 'fallthrough')
-+endif
-+script_sh_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
-+
+scripts_sh = [
+ 'git-difftool--helper.sh',
+ 'git-filter-branch.sh',
+ 'git-merge-octopus.sh',
+ 'git-merge-one-file.sh',
+ 'git-merge-resolve.sh',
++ 'git-mergetool--lib.sh',
+ 'git-mergetool.sh',
+ 'git-quiltimport.sh',
+ 'git-request-pull.sh',
++ 'git-sh-i18n.sh',
++ 'git-sh-setup.sh',
+ 'git-submodule.sh',
+ 'git-web--browse.sh',
+]
-+
+if perl_features_enabled
+ scripts_sh += 'git-instaweb.sh'
+endif
+
+foreach script : scripts_sh
-+ configure_file(
++ test_dependencies += custom_target(script,
+ input: script,
+ output: fs.stem(script),
-+ configuration: script_sh_config,
-+ install: true,
-+ install_dir: get_option('libexecdir') / 'git-core',
-+ )
-+endforeach
-+
-+scripts_lib = [
-+ 'git-mergetool--lib.sh',
-+ 'git-sh-i18n.sh',
-+ 'git-sh-setup.sh',
-+]
-+
-+foreach script : scripts_lib
-+ configure_file(
-+ input: script,
-+ output: fs.stem(script),
-+ configuration: script_sh_config,
++ command: [
++ shell,
++ meson.project_source_root() / 'generate-script.sh',
++ '@INPUT@',
++ '@OUTPUT@',
++ meson.project_build_root() / 'GIT-BUILD-OPTIONS',
++ ],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+ )
@@ meson.build (new)
+ },
+ )
+
++ generate_perl_command = [
++ shell,
++ meson.project_source_root() / 'generate-perl.sh',
++ meson.project_build_root() / 'GIT-BUILD-OPTIONS',
++ git_version,
++ perl_header,
++ '@INPUT@',
++ '@OUTPUT@',
++ ]
++
+ foreach script : scripts_perl
+ generated_script = custom_target(script,
+ input: script,
+ output: fs.stem(script),
-+ command: [
-+ shell,
-+ meson.project_source_root() / 'generate-perl.sh',
-+ meson.project_version(),
-+ perl_header,
-+ perl.full_path(),
-+ '@INPUT@',
-+ '@OUTPUT@',
-+ ],
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5',
+ )
@@ meson_options.txt (new)
+ description: 'Build helpers used to access remotes with the HTTP transport.')
+option('expat', type: 'feature', value: 'enabled',
+ description: 'Build helpers used to push to remotes with the HTTP transport.')
-+option('gettext', type: 'feature', value: 'enabled',
++option('gettext', type: 'feature', value: 'auto',
+ description: 'Build translation files.')
-+option('iconv', type: 'feature', value: 'enabled',
++option('iconv', type: 'feature', value: 'auto',
+ description: 'Support reencoding strings with different encodings.')
+option('pcre2', type: 'feature', value: 'enabled',
+ description: 'Support Perl-compatible regular expressions in e.g. git-grep(1).')
-+option('perl', type: 'feature', value: 'enabled',
++option('perl', type: 'feature', value: 'auto',
+ description: 'Build tools written in Perl.')
+option('perl_cpan_fallback', type: 'boolean', value: true,
+ description: 'Install bundled copies of CPAN modules that serve as a fallback in case the modules are not available on the system.')
-+option('python', type: 'feature', value: 'enabled',
++option('python', type: 'feature', value: 'auto',
+ description: 'Build tools written in Python.')
+
+option('openssl', type: 'feature', value: 'auto',
@@ meson_options.txt (new)

## perl/FromCPAN/Mail/meson.build (new) ##
@@
-+configure_file(
++test_dependencies += custom_target('Address.pm',
+ input: 'Address.pm',
+ output: 'Address.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail', +)

## perl/FromCPAN/meson.build (new) ##
@@
-+configure_file(
++test_dependencies += custom_target('Error.pm',
+ input: 'Error.pm',
+ output: 'Error.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/FromCPAN', +)
@@ perl/FromCPAN/meson.build (new)

## perl/Git/LoadCPAN/Mail/meson.build (new) ##
@@
-+configure_file(
++test_dependencies += custom_target('Address.pm',
+ input: 'Address.pm',
+ output: 'Address.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail', +)

## perl/Git/LoadCPAN/meson.build (new) ##
@@
-+configure_file(
++test_dependencies += custom_target('Error.pm',
+ input: 'Error.pm',
+ output: 'Error.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN', +)
@@ perl/Git/LoadCPAN/meson.build (new)

## perl/Git/SVN/Memoize/meson.build (new) ##
@@
-+configure_file(
++test_dependencies += custom_target('YAML.pm',
+ input: 'YAML.pm',
+ output: 'YAML.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/Git/SVN', +)
@@ perl/Git/SVN/meson.build (new)
+ 'Ra.pm',
+ 'Utils.pm',
+]
-+ configure_file(
++ test_dependencies += custom_target(source,
+ input: source,
+ output: source,
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/Git/SVN',
+ )
@@ perl/Git/meson.build (new)
+ 'Packet.pm',
+ 'SVN.pm',
+]
-+ configure_file(
++ test_dependencies += custom_target(source,
+ input: source,
+ output: source,
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5/Git',
+ )
@@ perl/Git/meson.build (new)

## perl/meson.build (new) ##
@@
-+perl_config = {
-+ 'LOCALEDIR': get_option('prefix') / get_option('datadir') / 'locale', -+ 'NO_GETTEXT': iconv.found() ? '' : '1',
-+ 'NO_PERL_CPAN_FALLBACKS': get_option('perl_cpan_fallback') ? '' : '1', -+}
-+
-+configure_file(
++test_dependencies += custom_target('Git.pm',
+ input: 'Git.pm',
+ output: 'Git.pm',
-+ configuration: perl_config,
++ command: generate_perl_command,
+ install: true,
+ install_dir: get_option('datadir') / 'perl5',
+)
@@ po/meson.build (new)
+)
+test_dependencies += translations[0]

+ ## subprojects/.gitignore (new) ##
+@@
++/*/
+
## subprojects/curl.wrap (new) ##
@@
+[wrap-file]
@@ t/helper/meson.build (new)

## t/meson.build (new) ##
@@
-+awk = find_program('awk')
-+
+clar_test_suites = [
+ 'unit-tests/ctype.c',
+ 'unit-tests/strvec.c',
@@ templates/hooks/meson.build (new)
+ configure_file(
+ input: hook,
+ output: hook,
-+ configuration: script_sh_config,
++ configuration: template_config,
+ )
+endforeach

@@ templates/info/meson.build (new)
+configure_file(
+ input: 'exclude',
+ output: 'exclude',
-+ configuration: script_sh_config,
++ configuration: template_config,
+)

## templates/meson.build (new) ##
@@
++template_config = configuration_data()
++template_config.set('PERL_PATH', perl.found() ? fs.as_posix(perl.full_path()) : '') ++template_config.set('SHELL_PATH', fs.as_posix(shell.full_path())) ++template_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb')) ++
+configure_file(
+ input: 'description',
+ output: 'description',
-+ configuration: script_sh_config,
++ configuration: template_config,
+)
+
+subdir('hooks')

Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#81 lore raw

RFC PATCH v3 1/15 Makefile: use common template for GIT-BUILD-OPTIONS

The "GIT-BUILD-OPTIONS" file is generated by our build systems to propagate built-in features and paths to our tests. The generation is done ad-hoc, where both our Makefile and the CMake build instructions simply echo a bunch of strings into the file. This makes it very hard to figure out what variables are expected to exist and what format they have, and the written variables can easily get out of sync between build systems.

Introduce a new "GIT-BUILD-OPTIONS.in" template to address this issue. This has multiple advantages:

- It demonstrates which built options exist in the first place.

- It can serve as a spot to document the build options.

- Some build systems complain when not all variables could be substituted, alerting us of mismatches. Others don't, but if we forgot to substitute such variables we now have a bogus string that will likely cause our tests to fail, if they have any meaning in the first place.

Backfill values that we didn't yet set in our CMake build instructions. While at it, remove the SUPPORTS_SIMPLE_IPC variable that we only set up in CMake as it isn't used anywhere.

Note that this change requires us to move around the setup of TEST_OUTPUT_DIRECTORY in "test-lib.sh" such that it comes after sourcing the "GIT-BUILD-OPTIONS" file. This is the only instance I could find where we rely on ordering on variables.

---
 GIT-BUILD-OPTIONS.in                |  36 ++++++++++
 Makefile                            | 108 ++++++++++------------------
 contrib/buildsystems/CMakeLists.txt |  58 ++++++++++-----
 t/test-lib.sh                       |  13 ++--
 4 files changed, 120 insertions(+), 95 deletions(-)
 create mode 100644 GIT-BUILD-OPTIONS.in
GIT-BUILD-OPTIONS.in new file +36 -0
new file mode 100644
index 00000000000..f0ca240493c
@@ -0,0 +1,36 @@
+SHELL_PATH=@SHELL_PATH@
+TEST_SHELL_PATH=@TEST_SHELL_PATH@
+PERL_PATH=@PERL_PATH@
+DIFF=@DIFF@
+PYTHON_PATH=@PYTHON_PATH@
+TAR=@TAR@
+NO_CURL=@NO_CURL@
+NO_ICONV=@NO_ICONV@
+NO_EXPAT=@NO_EXPAT@
+USE_LIBPCRE2=@USE_LIBPCRE2@
+NO_PERL=@NO_PERL@
+NO_PTHREADS=@NO_PTHREADS@
+NO_PYTHON=@NO_PYTHON@
+NO_REGEX=@NO_REGEX@
+NO_UNIX_SOCKETS=@NO_UNIX_SOCKETS@
+PAGER_ENV=@PAGER_ENV@
+SANITIZE_LEAK=@SANITIZE_LEAK@
+SANITIZE_ADDRESS=@SANITIZE_ADDRESS@
+X=@X@
+FSMONITOR_DAEMON_BACKEND=@FSMONITOR_DAEMON_BACKEND@
+FSMONITOR_OS_SETTINGS=@FSMONITOR_OS_SETTINGS@
+TEST_OUTPUT_DIRECTORY=@TEST_OUTPUT_DIRECTORY@
+GIT_TEST_OPTS=@GIT_TEST_OPTS@
+GIT_TEST_CMP=@GIT_TEST_CMP@
+GIT_TEST_CMP_USE_COPIED_CONTEXT=@GIT_TEST_CMP_USE_COPIED_CONTEXT@
+GIT_TEST_UTF8_LOCALE=@GIT_TEST_UTF8_LOCALE@
+NO_GETTEXT=@NO_GETTEXT@
+GIT_PERF_REPEAT_COUNT=@GIT_PERF_REPEAT_COUNT@
+GIT_PERF_REPO=@GIT_PERF_REPO@
+GIT_PERF_LARGE_REPO=@GIT_PERF_LARGE_REPO@
+GIT_PERF_MAKE_OPTS=@GIT_PERF_MAKE_OPTS@
+GIT_PERF_MAKE_COMMAND=@GIT_PERF_MAKE_COMMAND@
+GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
+GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
+GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
+RUNTIME_PREFIX=@RUNTIME_PREFIX@
Makefile +38 -70

114 lines not on this page · raw message

contrib/buildsystems/CMakeLists.txt +39 -19

66 lines not on this page · raw message

t/test-lib.sh +7 -6
index a278181a056..4dd641baefe 100644
@@ -35,12 +35,6 @@ else
 	# needing to exist.
 	TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
-if test -z "$TEST_OUTPUT_DIRECTORY"
-then
-	# Similarly, override this to store the test-results subdir
-	# elsewhere
-	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
-fi
 GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
 then
@@ -100,6 +94,13 @@ fi
 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
 export PERL_PATH SHELL_PATH
 
+if test -z "$TEST_OUTPUT_DIRECTORY"
+then
+	# Similarly, override this to store the test-results subdir
+	# elsewhere
+	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
+fi
+
 # In t0000, we need to override test directories of nested testcases. In case
 # the developer has TEST_OUTPUT_DIRECTORY part of his build options, then we'd
 # reset this value to instead contain what the developer has specified. We thus
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#82 lore raw

Re: [RFC PATCH v3 01/15] Makefile: use common template for GIT-BUILD-OPTIONS

Quoted 8 lines · Patrick Steinhardt

Introduce a new "GIT-BUILD-OPTIONS.in" template to address this issue. This has multiple advantages:
[...]
- Some build systems complain when not all variables could be substituted, alerting us of mismatches. Others don't, but if we forgot to substitute such variables we now have a bogus string that will likely cause our tests to fail, if they have any meaning in the first place.

Regarding the above...

Makefile GIT-LDFLAGS: FORCE · line 3206

Quoted 7 lines
Makefile +5 -0
+       @sed \
+               -e "s|@SHELL_PATH@|\'$(SHELL_PATH_SQ)\'|" \
+               -e "s|@TEST_SHELL_PATH@|\'$(TEST_SHELL_PATH_SQ)\'|" \
+               [...]
+               GIT-BUILD-OPTIONS.in >$@+
        @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
        @if test -f GIT-BUILD-DIR; then rm GIT-BUILD-DIR; fi

... can't we grep whether any unsubstituted variables remain in $@+ and complain if they do?

#83 lore raw

Re: [RFC PATCH v3 01/15] Makefile: use common template for GIT-BUILD-OPTIONS

Quoted 20 lines · Eric Sunshine
Quoted 8 lines · Patrick Steinhardt

Introduce a new "GIT-BUILD-OPTIONS.in" template to address this issue. This has multiple advantages:
[...]
- Some build systems complain when not all variables could be substituted, alerting us of mismatches. Others don't, but if we forgot to substitute such variables we now have a bogus string that will likely cause our tests to fail, if they have any meaning in the first place.

Regarding the above...

Makefile GIT-LDFLAGS: FORCE · line 3206

Quoted 7 lines
Makefile +5 -0
+       @sed \
+               -e "s|@SHELL_PATH@|\'$(SHELL_PATH_SQ)\'|" \
+               -e "s|@TEST_SHELL_PATH@|\'$(TEST_SHELL_PATH_SQ)\'|" \
+               [...]
+               GIT-BUILD-OPTIONS.in >$@+
        @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
        @if test -f GIT-BUILD-DIR; then rm GIT-BUILD-DIR; fi
Quoted 2 lines

... can't we grep whether any unsubstituted variables remain in $@+ and complain if they do?

You mean with the new GIT-BUILD-OPTIONS.in template? Yes, we can. Meson generates such warnings automatically, but that of course does not help our Makefile.

I'll add that.

Patrick

#84 lore raw

RFC PATCH v3 2/15 Makefile: consistently use @PLACEHOLDER@ to substitute

In reply to Patrick Steinhardt

We have a bunch of placeholders in our scripts that we replace at build time, for example by using sed(1). These placeholders come in three different formats: @PLACEHOLDER@, @@PLACEHOLDER@@ and ++PLACEHOLDER++.

Next to being inconsistent it also creates a bit of a problem with CMake, which only supports the first syntax in its configure_file() function. To work around that we instead manually replace placeholders via string operations, which is a hassle and removes safeguards that CMake has to verify that we didn't forget to replace any placeholders. Besides that, other build systems like Meson also support the CMake syntax.

Unify our codebase to consistently use the syntax supported by such build systems.

---
 Makefile                                      | 44 +++++++++----------
 configure.ac                                  |  2 +-
 contrib/buildsystems/CMakeLists.txt           | 34 +++++++-------
 git-cvsserver.perl                            |  2 +-
 git-instaweb.sh                               |  8 ++--
 git-request-pull.sh                           |  2 +-
 git-send-email.perl                           |  2 +-
 git-sh-i18n.sh                                |  6 +--
 git-sh-setup.sh                               |  6 +--
 git-svn.perl                                  |  2 +-
 gitk-git/po/vi.po                             |  2 +-
 gitweb/Makefile                               | 44 +++++++++----------
 gitweb/gitweb.perl                            | 44 +++++++++----------
 perl/Git/I18N.pm                              |  6 +--
 perl/Git/LoadCPAN.pm                          |  6 +--
 .../header_templates/fixed_prefix.template.pl |  2 +-
 .../runtime_prefix.template.pl                |  8 ++--
 unimplemented.sh                              |  2 +-
 wrap-for-bin.sh                               | 18 ++++----
 19 files changed, 120 insertions(+), 120 deletions(-)
Makefile +22 -22
index 7d4b5f04a04..d98ce366c08 100644
@@ -1555,10 +1555,10 @@ endif
 
 ifdef SANE_TOOL_PATH
 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
-BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
+BROKEN_PATH_FIX = 's|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
 PATH := $(SANE_TOOL_PATH):${PATH}
 else
-BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
+BROKEN_PATH_FIX = '/^\# @BROKEN_PATH_FIX@$$/d'
 endif
 
 ifeq (,$(HOST_CPU))
@@ -2548,13 +2548,13 @@ GIT-SCRIPT-DEFINES: FORCE
 define cmd_munge_script
 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-    -e 's|@@DIFF@@|$(DIFF_SQ)|' \
-    -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
-    -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
+    -e 's|@DIFF@|$(DIFF_SQ)|' \
+    -e 's|@LOCALEDIR@|$(localedir_SQ)|g' \
+    -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
-    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-    -e 's|@@PAGER_ENV@@|$(PAGER_ENV_SQ)|g' \
+    -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
+    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
 
@@ -2611,7 +2611,7 @@ $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
 	    -e '	r GIT-PERL-HEADER' \
 	    -e '	G' \
 	    -e '}' \
-	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+	    -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
 	    $< >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -2629,11 +2629,11 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
 	INSTLIBDIR='$(perllibdir_SQ)' && \
 	INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
 	INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
-	sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
-	    -e "s=@@INSTLIBDIR@@=$$INSTLIBDIR=g" \
-	    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
-	    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
-	    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
+	sed -e 's=@PATHSEP@=$(pathsep)=g' \
+	    -e "s=@INSTLIBDIR@=$$INSTLIBDIR=g" \
+	    -e 's=@PERLLIBDIR_REL@=$(perllibdir_relative_SQ)=g' \
+	    -e 's=@GITEXECDIR_REL@=$(gitexecdir_relative_SQ)=g' \
+	    -e 's=@LOCALEDIR_REL@=$(localedir_relative_SQ)=g' \
 	    $< >$@+ && \
 	mv $@+ $@
 
@@ -2649,7 +2649,7 @@ else # NO_PERL
 $(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
+	    -e 's|@REASON@|NO_PERL=$(NO_PERL)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -2670,13 +2670,13 @@ else # NO_PYTHON
 $(SCRIPT_PYTHON_GEN): % : unimplemented.sh
 	$(QUIET_GEN) \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
+	    -e 's|@REASON@|NO_PYTHON=$(NO_PYTHON)|g' \
 	    unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 endif # NO_PYTHON
 
-CONFIGURE_RECIPE = sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+CONFIGURE_RECIPE = sed -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
 			configure.ac >configure.ac+ && \
 		   autoconf -o configure configure.ac+ && \
 		   $(RM) configure.ac+
@@ -3104,9 +3104,9 @@ endif
 perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN) \
-	sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
-	    -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \
-	    -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
+	sed -e 's|@LOCALEDIR@|$(perl_localedir_SQ)|g' \
+	    -e 's|@NO_GETTEXT@|$(NO_GETTEXT_SQ)|g' \
+	    -e 's|@NO_PERL_CPAN_FALLBACKS@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
 	< $< > $@
 
 perl/build/man/man3/Git.3pm: perl/Git.pm
@@ -3224,8 +3224,8 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS) $(CLAR_TEST_PR
 bin-wrappers/%: wrap-for-bin.sh
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-	     -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-	     -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
+	     -e 's|@BUILD_DIR@|$(shell pwd)|' \
+	     -e 's|@PROG@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
 	chmod +x $@
 
 # GNU make supports exporting all variables by "export" without parameters.
configure.ac +1 -1
index d1a96da14eb..5923edc44aa 100644
@@ -142,7 +142,7 @@ fi
 ## Configure body starts here.
 
 AC_PREREQ(2.59)
-AC_INIT([git], [@@GIT_VERSION@@], [[email protected]])
+AC_INIT([git], [@GIT_VERSION@], [[email protected]])
 
 AC_CONFIG_SRCDIR([git.c])
 
contrib/buildsystems/CMakeLists.txt +17 -17
index 680e5b3c8b0..a41540458b7 100644
@@ -836,14 +836,14 @@ set(git_shell_scripts
 foreach(script ${git_shell_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
 	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
-	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@DIFF@" "diff" content "${content}")
 	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
 	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
-	string(REPLACE "@@NO_CURL@@" "" content "${content}")
-	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
-	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
-	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	string(REPLACE "@NO_CURL@" "" content "${content}")
+	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
+	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
+	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -852,13 +852,13 @@ parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
-string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
-string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
+string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
 
 foreach(script ${git_perl_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
 	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
-	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
 
@@ -873,8 +873,8 @@ file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
 foreach(pm ${perl_modules})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
 	file(STRINGS ${pm} content NEWLINE_CONSUME)
-	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
 #test-lib.sh requires perl/build/lib to be the build directory of perl modules
 endforeach()
@@ -1056,21 +1056,21 @@ set(wrapper_test_scripts
 
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
+	string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@PROG@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@PROG@" "git-cvsserver" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
 
 #options for configuring test options
git-cvsserver.perl +1 -1
index 124f598bdc0..70ae7cb8e45 100755
@@ -26,7 +26,7 @@
 use File::Basename;
 use Getopt::Long qw(:config require_order no_ignore_case);
 
-my $VERSION = '@@GIT_VERSION@@';
+my $VERSION = '@GIT_VERSION@';
 
 my $log = GITCVS::log->new();
 my $cfg;
git-instaweb.sh +4 -4
index 8dbe21d5887..c8efb1205a8 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@@PERL@@'
+PERL='@PERL@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -38,8 +38,8 @@ conf="$GIT_DIR/gitweb/httpd.conf"
 # if installed, it doesn't need further configuration (module_path)
 test -z "$httpd" && httpd='lighttpd -f'
 
-# Default is @@GITWEBDIR@@
-test -z "$root" && root='@@GITWEBDIR@@'
+# Default is @GITWEBDIR@
+test -z "$root" && root='@GITWEBDIR@'
 
 # any untaken local port will do...
 test -z "$port" && port=1234
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@@PERL@@
+#!@PERL@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 01640a044bb..10c88639e28 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
git-send-email.perl +1 -1
index c835d4c11af..02805c43e52 100755
@@ -1501,7 +1501,7 @@ sub gen_header {
 	@recipients = unique_email_list(@recipients,@cc,@initial_bcc);
 	@recipients = (map { extract_valid_address_or_die($_) } @recipients);
 	my $date = format_2822_time($time++);
-	my $gitversion = '@@GIT_VERSION@@';
+	my $gitversion = '@GIT_VERSION@';
 	if ($gitversion =~ m/..GIT_VERSION../) {
 	    $gitversion = Git::version();
 	}
git-sh-i18n.sh +3 -3
index a15c0620db6..ae4b2d6ba9d 100644
@@ -9,7 +9,7 @@ TEXTDOMAIN=git
 export TEXTDOMAIN
 if test -z "$GIT_TEXTDOMAINDIR"
 then
-	TEXTDOMAINDIR="@@LOCALEDIR@@"
+	TEXTDOMAINDIR="@LOCALEDIR@"
 else
 	TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
 fi
@@ -17,9 +17,9 @@ export TEXTDOMAINDIR
 
 # First decide what scheme to use...
 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
-if test -n "@@USE_GETTEXT_SCHEME@@"
+if test -n "@USE_GETTEXT_SCHEME@"
 then
-	GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
+	GIT_INTERNAL_GETTEXT_SH_SCHEME="@USE_GETTEXT_SCHEME@"
 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
 then
 	: no probing necessary
git-sh-setup.sh +3 -3
index ce273fe0e48..19aef72ec25 100644
@@ -41,7 +41,7 @@ git_broken_path_fix () {
 	esac
 }
 
-# @@BROKEN_PATH_FIX@@
+# @BROKEN_PATH_FIX@
 
 # Source git-sh-i18n for gettext support.
 . "$(git --exec-path)/git-sh-i18n"
@@ -154,7 +154,7 @@ git_pager() {
 	else
 		GIT_PAGER=cat
 	fi
-	for vardef in @@PAGER_ENV@@
+	for vardef in @PAGER_ENV@
 	do
 		var=${vardef%%=*}
 		eval ": \"\${$vardef}\" && export $var"
@@ -280,7 +280,7 @@ get_author_ident_from_commit () {
 # remove lines from $1 that are not in $2, leaving only common lines.
 create_virtual_base() {
 	sz0=$(wc -c <"$1")
-	@@DIFF@@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
+	@DIFF@ -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
 	sz1=$(wc -c <"$1")
 
 	# If we do not have enough common material, it is not
git-svn.perl +1 -1
index 01e7a70de1c..dcf65cf1d1d 100755
@@ -9,7 +9,7 @@
 		$_revision $_repository
 		$_q $_authors $_authors_prog %users/;
 $AUTHOR = 'Eric Wong <[email protected]>';
-$VERSION = '@@GIT_VERSION@@';
+$VERSION = '@GIT_VERSION@';
 
 use Carp qw/croak/;
 use File::Basename qw/dirname basename/;
gitk-git/po/vi.po +1 -1
index 59674986604..184430dcdee 100644
@@ -5,7 +5,7 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: gitk @@GIT_VERSION@@\n"
+"Project-Id-Version: gitk @GIT_VERSION@\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2015-05-17 14:32+1000\n"
 "PO-Revision-Date: 2015-09-15 07:33+0700\n"
gitweb/Makefile +22 -22

50 lines not on this page · raw message

gitweb/gitweb.perl +22 -22

116 lines not on this page · raw message

perl/Git/I18N.pm +3 -3
index 475e90a6df5..f8f0ca31254 100644
@@ -20,14 +20,14 @@ BEGIN
 # this "'@@' [...] '@@'" pattern.
 use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@';
 use constant NO_GETTEXT => (
-	q[@@NO_GETTEXT@@] ne ''
+	q[@NO_GETTEXT@] ne ''
 	and
-	q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR
+	q[@NO_GETTEXT@] ne NO_GETTEXT_STR
 );
 
 sub __bootstrap_locale_messages {
 	our $TEXTDOMAIN = 'git';
-	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+	our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@LOCALEDIR@';
 	die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT;
 
 	require POSIX;
perl/Git/LoadCPAN.pm +3 -3
index 8c7fa805f97..6be99840f84 100644
@@ -31,11 +31,11 @@ =head1 DESCRIPTION
 # Makefile, and allows for detecting whether the module is loaded from
 # perl/Git as opposed to perl/build/Git, which is useful for one-off
 # testing without having Error.pm et al installed.
-use constant NO_PERL_CPAN_FALLBACKS_STR => '@@' . 'NO_PERL_CPAN_FALLBACKS' . '@@';
+use constant NO_PERL_CPAN_FALLBACKS_STR => '@' . 'NO_PERL_CPAN_FALLBACKS' . '@';
 use constant NO_PERL_CPAN_FALLBACKS => (
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne ''
+	q[@NO_PERL_CPAN_FALLBACKS@] ne ''
 	and
-	q[@@NO_PERL_CPAN_FALLBACKS@@] ne NO_PERL_CPAN_FALLBACKS_STR
+	q[@NO_PERL_CPAN_FALLBACKS@] ne NO_PERL_CPAN_FALLBACKS_STR
 );
 
 sub import {
perl/header_templates/fixed_prefix.template.pl +1 -1
index 857b4391a49..d571ca5cde5 100644
@@ -1 +1 @@
-use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || '@@INSTLIBDIR@@'));
+use lib (split(/@PATHSEP@/, $ENV{GITPERLLIB} || '@INSTLIBDIR@'));
perl/header_templates/runtime_prefix.template.pl +4 -4
index 9d28b3d8636..e6f8e661a16 100644
@@ -3,7 +3,7 @@
 # This finds our Git::* libraries relative to the script's runtime path.
 sub __git_system_path {
 	my ($relpath) = @_;
-	my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
+	my $gitexecdir_relative = '@GITEXECDIR_REL@';
 
 	# GIT_EXEC_PATH is supplied by `git` or the test suite.
 	my $exec_path;
@@ -24,11 +24,11 @@ sub __git_system_path {
 }
 
 BEGIN {
-	use lib split /@@PATHSEP@@/,
+	use lib split /@PATHSEP@/,
 	(
 		$ENV{GITPERLLIB} ||
 		do {
-			my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
+			my $perllibdir = __git_system_path('@PERLLIBDIR_REL@');
 			(-e $perllibdir) || die("Invalid system path ($relpath): $path");
 			$perllibdir;
 		}
@@ -36,7 +36,7 @@ BEGIN
 
 	# Export the system locale directory to the I18N module. The locale directory
 	# is only installed if NO_GETTEXT is set.
-	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
+	$Git::I18N::TEXTDOMAINDIR = __git_system_path('@LOCALEDIR_REL@');
 }
 
 # END RUNTIME_PREFIX generated code.
unimplemented.sh +1 -1
index fee21d24e8a..41776b279d4 100644
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-echo >&2 "fatal: git was built without support for $(basename $0) (@@REASON@@)."
+echo >&2 "fatal: git was built without support for $(basename $0) (@REASON@)."
 exit 128
wrap-for-bin.sh +9 -9
index 95851b85b6b..7898a1c238d 100644
@@ -4,33 +4,33 @@
 # to run test suite against sandbox, but with only bindir-installed
 # executables in PATH.  The Makefile copies this into various
 # files in bin-wrappers, substituting
-# @@BUILD_DIR@@ and @@PROG@@.
+# @BUILD_DIR@ and @PROG@.
 
-GIT_EXEC_PATH='@@BUILD_DIR@@'
+GIT_EXEC_PATH='@BUILD_DIR@'
 if test -n "$NO_SET_GIT_TEMPLATE_DIR"
 then
 	unset GIT_TEMPLATE_DIR
 else
-	GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
+	GIT_TEMPLATE_DIR='@BUILD_DIR@/templates/blt'
 	export GIT_TEMPLATE_DIR
 fi
-GITPERLLIB='@@BUILD_DIR@@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
-GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
-PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
+GITPERLLIB='@BUILD_DIR@/perl/build/lib'"${GITPERLLIB:+:$GITPERLLIB}"
+GIT_TEXTDOMAINDIR='@BUILD_DIR@/po/build/locale'
+PATH='@BUILD_DIR@/bin-wrappers:'"$PATH"
 
 export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
 
 case "$GIT_DEBUGGER" in
 '')
-	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 1)
 	unset GIT_DEBUGGER
-	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec gdb --args "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 *)
 	GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
 	unset GIT_DEBUGGER
-	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@PROG@" "$@"
 	;;
 esac
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#85 lore raw

RFC PATCH v3 3/15 Makefile: consistently use PERL_PATH

In reply to Patrick Steinhardt

When injecting the Perl path into our scripts we sometimes use '@PERL@' while we othertimes use '@PERL_PATH@'. Refactor the code use the latter consistently, which makes it easier to reuse the same logic for multiple scripts.

---
 Makefile                            | 2 +-
 contrib/buildsystems/CMakeLists.txt | 2 +-
 git-instaweb.sh                     | 4 ++--
 git-request-pull.sh                 | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
Makefile +1 -1
index d98ce366c08..394466b716d 100644
@@ -2553,7 +2553,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
     -e $(BROKEN_PATH_FIX) \
     -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
-    -e 's|@PERL@|$(PERL_PATH_SQ)|g' \
+    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' \
     -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
     [email protected] >$@+
 endef
contrib/buildsystems/CMakeLists.txt +1 -1
index a41540458b7..608ad9714d4 100644
@@ -842,7 +842,7 @@ foreach(script ${git_shell_scripts})
 	string(REPLACE "@NO_CURL@" "" content "${content}")
 	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
 	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
-	string(REPLACE "@PERL@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@PERL_PATH@" "${PERL_PATH}" content "${content}")
 	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
 endforeach()
git-instaweb.sh +2 -2
index c8efb1205a8..5ad50160bb0 100755
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Eric Wong
 #
 
-PERL='@PERL@'
+PERL='@PERL_PATH@'
 OPTIONS_KEEPDASHDASH=
 OPTIONS_STUCKLONG=
 OPTIONS_SPEC="\
@@ -716,7 +716,7 @@ EOF
 
 gitweb_conf() {
 	cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
-#!@PERL@
+#!@PERL_PATH@
 our \$projectroot = "$(dirname "$fqgitdir")";
 our \$git_temp = "$fqgitdir/gitweb/tmp";
 our \$projects_list = \$projectroot;
git-request-pull.sh +1 -1
index 10c88639e28..775ba8ea11a 100755
@@ -112,7 +112,7 @@ find_matching_ref='
 	}
 '
 
-set fnord $(git ls-remote "$url" | @PERL@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
+set fnord $(git ls-remote "$url" | @PERL_PATH@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
 remote_sha1=$2
 ref=$3
 
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#86 lore raw

RFC PATCH v3 4/15 Makefile: extract script to massage Perl scripts

In reply to Patrick Steinhardt

Extract the script to inject various build-time parameters into our Perl scripts into a standalone script. This is done such that we can reuse it in other build systems.

---
 Makefile                            | 12 ++----------
 contrib/buildsystems/CMakeLists.txt | 20 +++++++++++++++-----
 generate-perl.sh                    | 26 ++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 15 deletions(-)
 create mode 100755 generate-perl.sh
Makefile +2 -10
index 394466b716d..ee1ef7ce8fb 100644
@@ -2604,16 +2604,8 @@ endif
 
 PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
 
-$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
-	$(QUIET_GEN) \
-	sed -e '1{' \
-	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-	    -e '	r GIT-PERL-HEADER' \
-	    -e '	G' \
-	    -e '}' \
-	    -e 's/@GIT_VERSION@/$(GIT_VERSION)/g' \
-	    $< >$@+ && \
-	chmod +x $@+ && \
+$(SCRIPT_PERL_GEN): % : %.perl generate-perl.sh GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
+	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh ./GIT-BUILD-OPTIONS $(GIT_VERSION) GIT-PERL-HEADER "$<" "$@+" && \
 	mv $@+ $@
 
 PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
contrib/buildsystems/CMakeLists.txt +15 -5
index 608ad9714d4..7fb6a149f21 100644
@@ -848,19 +848,29 @@ foreach(script ${git_shell_scripts})
 endforeach()
 
 #perl scripts
-parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
 string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
 string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
+file(WRITE ${CMAKE_BINARY_DIR}/PERL-HEADER ${perl_header})
 
 foreach(script ${git_perl_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
-	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
-	string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
-	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+	string(REPLACE ".perl" "" perl_gen_path "${script}")
+
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${perl_gen_path}
+		COMMAND ${CMAKE_SOURCE_DIR}/generate-perl.sh
+			${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS
+			${PROJECT_VERSION}
+			${CMAKE_BINARY_DIR}/PERL-HEADER
+			${CMAKE_SOURCE_DIR}/${script}
+			${CMAKE_BINARY_DIR}/${perl_gen_path}
+		DEPENDS ${CMAKE_SOURCE_DIR}/generate-perl.sh
+			${CMAKE_SOURCE_DIR}/${script})
+	list(APPEND perl_gen ${CMAKE_BINARY_DIR}/${perl_gen_path})
 endforeach()
+add_custom_target(perl-gen ALL DEPENDS ${perl_gen})
 
 #python script
 file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
generate-perl.sh new file +26 -0
new file mode 100755
index 00000000000..12e116b76e5
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+if test $# -ne 5
+then
+	echo "USAGE: $0 <GIT_BUILD_OPTIONS> <GIT_VERSION> <PERL_HEADER> <INPUT> <OUTPUT>" >&2
+	exit 1
+fi
+
+GIT_BUILD_OPTIONS="$1"
+GIT_VERSION="$2"
+PERL_HEADER="$3"
+INPUT="$4"
+OUTPUT="$5"
+
+. "$GIT_BUILD_OPTIONS"
+
+sed -e '1{' \
+    -e "	s|#!.*perl|#!$PERL_PATH|" \
+    -e "	r $PERL_HEADER" \
+    -e '	G' \
+    -e '}' \
+    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
+    "$INPUT" >"$OUTPUT"
+chmod a+x "$OUTPUT"
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#87 lore raw

RFC PATCH v3 5/15 Makefile: use "generate-perl.sh" to massage Perl library

In reply to Patrick Steinhardt

Extend "generate-perl.sh" such that it knows to also massage the Perl library files. There are two major differences:

- We do not read in the Perl header. This is handled by matching on whether or not we have a Perl shebang.

- We substitute some more variables, which we read in via our GIT-BUILD-OPTIONS.

Adapt both our Makefile and the CMake build instructions to use this.

---
 GIT-BUILD-OPTIONS.in                |  2 ++
 Makefile                            | 10 ++++------
 contrib/buildsystems/CMakeLists.txt | 20 ++++++--------------
 generate-perl.sh                    | 14 ++++++++++++--
 4 files changed, 24 insertions(+), 22 deletions(-)
GIT-BUILD-OPTIONS.in +2 -0
index f0ca240493c..050432f9fc4 100644
@@ -1,6 +1,8 @@
 SHELL_PATH=@SHELL_PATH@
 TEST_SHELL_PATH=@TEST_SHELL_PATH@
 PERL_PATH=@PERL_PATH@
+PERL_LOCALEDIR=@PERL_LOCALEDIR@
+NO_PERL_CPAN_FALLBACKS=@NO_PERL_CPAN_FALLBACKS@
 DIFF=@DIFF@
 PYTHON_PATH=@PYTHON_PATH@
 TAR=@TAR@
Makefile +4 -6
index ee1ef7ce8fb..770ad830292 100644
@@ -3093,13 +3093,9 @@ endif
 NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS))
 endif
 
-perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
+perl/build/lib/%.pm: perl/%.pm generate-perl.sh GIT-BUILD-OPTIONS GIT-PERL-DEFINES
 	$(call mkdir_p_parent_template)
-	$(QUIET_GEN) \
-	sed -e 's|@LOCALEDIR@|$(perl_localedir_SQ)|g' \
-	    -e 's|@NO_GETTEXT@|$(NO_GETTEXT_SQ)|g' \
-	    -e 's|@NO_PERL_CPAN_FALLBACKS@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
-	< $< > $@
+	$(QUIET_GEN)$(SHELL_PATH) generate-perl.sh ./GIT-BUILD-OPTIONS $(GIT_VERSION) GIT-PERL-HEADER "$<" "$@"
 
 perl/build/man/man3/Git.3pm: perl/Git.pm
 	$(call mkdir_p_parent_template)
@@ -3160,6 +3156,8 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@SHELL_PATH@|\'$(SHELL_PATH_SQ)\'|" \
 		-e "s|@TEST_SHELL_PATH@|\'$(TEST_SHELL_PATH_SQ)\'|" \
 		-e "s|@PERL_PATH@|\'$(PERL_PATH_SQ)\'|" \
+		-e "s|@PERL_LOCALEDIR@|\'$(perl_localedir_SQ)\'|" \
+		-e "s|@NO_PERL_CPAN_FALLBACKS@|\'$(NO_PERL_CPAN_FALLBACKS_SQ)\'|" \
 		-e "s|@DIFF@|\'$(DIFF)\'|" \
 		-e "s|@PYTHON_PATH@|\'$(PYTHON_PATH_SQ)\'|" \
 		-e "s|@TAR@|\'$(TAR)\'|" \
contrib/buildsystems/CMakeLists.txt +6 -14
index 7fb6a149f21..ddf39dc90e7 100644
@@ -849,6 +849,9 @@ endforeach()
 
 #perl scripts
 parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+list(TRANSFORM perl_modules REPLACE "${CMAKE_SOURCE_DIR}/" "")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
@@ -856,7 +859,7 @@ string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
 string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
 file(WRITE ${CMAKE_BINARY_DIR}/PERL-HEADER ${perl_header})
 
-foreach(script ${git_perl_scripts})
+foreach(script ${git_perl_scripts} ${perl_modules})
 	string(REPLACE ".perl" "" perl_gen_path "${script}")
 
 	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${perl_gen_path}
@@ -877,19 +880,6 @@ file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
 string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
 
-#perl modules
-file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
-
-foreach(pm ${perl_modules})
-	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
-	file(STRINGS ${pm} content NEWLINE_CONSUME)
-	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" content "${content}")
-	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
-#test-lib.sh requires perl/build/lib to be the build directory of perl modules
-endforeach()
-
-
 #templates
 file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
 list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
@@ -1131,6 +1121,8 @@ file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-BUILD-OPTIONS.in git_build_options NEWLINE_
 string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" git_build_options "${git_build_options}")
 string(REPLACE "@TEST_SHELL_PATH@" "${TEST_SHELL_PATH}" git_build_options "${git_build_options}")
 string(REPLACE "@PERL_PATH@" "${PERL_PATH}" git_build_options "${git_build_options}")
+string(REPLACE "@PERL_LOCALEDIR@" "${LOCALEDIR}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" git_build_options "${git_build_options}")
 string(REPLACE "@DIFF@" "${DIFF}" git_build_options "${git_build_options}")
 string(REPLACE "@PYTHON_PATH@" "${PYTHON_PATH}" git_build_options "${git_build_options}")
 string(REPLACE "@TAR@" "${TAR}" git_build_options "${git_build_options}")
generate-perl.sh +12 -2
index 12e116b76e5..cb1629857c6 100755
@@ -17,10 +17,20 @@ OUTPUT="$5"
 . "$GIT_BUILD_OPTIONS"
 
 sed -e '1{' \
+    -e "	/^#!.*perl/!b" \
     -e "	s|#!.*perl|#!$PERL_PATH|" \
     -e "	r $PERL_HEADER" \
     -e '	G' \
     -e '}' \
-    -e "s/@GIT_VERSION@/$GIT_VERSION/g" \
+    -e "s|@GIT_VERSION@|$GIT_VERSION|g" \
+    -e "s|@LOCALEDIR@|$PERL_LOCALEDIR|g" \
+    -e "s|@NO_GETTEXT@|$NO_GETTEXT|g" \
+    -e "s|@NO_PERL_CPAN_FALLBACKS@|$NO_PERL_CPAN_FALLBACKS|g" \
     "$INPUT" >"$OUTPUT"
-chmod a+x "$OUTPUT"
+
+case "$(basename "$INPUT")" in
+*.perl)
+	chmod a+x "$OUTPUT";;
+*)
+	;;
+esac
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty
#88 lore raw

RFC PATCH v3 6/15 Makefile: extract script to massage Shell scripts

In reply to Patrick Steinhardt

Same as in the preceding commits, extract a script that allows us to unify how we massage shell scripts.

---
 GIT-BUILD-OPTIONS.in                |  4 ++++
 Makefile                            | 34 +++++++++--------------------
 contrib/buildsystems/CMakeLists.txt | 30 +++++++++++++++----------
 generate-script.sh                  | 34 +++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+), 35 deletions(-)
 create mode 100755 generate-script.sh
GIT-BUILD-OPTIONS.in +4 -0
index 050432f9fc4..9b95a6b3eee 100644
@@ -36,3 +36,7 @@ GIT_INTEROP_MAKE_OPTS=@GIT_INTEROP_MAKE_OPTS@
 GIT_TEST_INDEX_VERSION=@GIT_TEST_INDEX_VERSION@
 GIT_TEST_PERL_FATAL_WARNINGS=@GIT_TEST_PERL_FATAL_WARNINGS@
 RUNTIME_PREFIX=@RUNTIME_PREFIX@
+GITWEBDIR=@GITWEBDIR@
+USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
+LOCALEDIR=@LOCALEDIR@
+BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
Makefile +10 -24
index 770ad830292..85877b25bab 100644
@@ -1555,10 +1555,10 @@ endif
 
 ifdef SANE_TOOL_PATH
 SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
-BROKEN_PATH_FIX = 's|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
+BROKEN_PATH_FIX = s|^\# @BROKEN_PATH_FIX@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|
 PATH := $(SANE_TOOL_PATH):${PATH}
 else
-BROKEN_PATH_FIX = '/^\# @BROKEN_PATH_FIX@$$/d'
+BROKEN_PATH_FIX = /^\# @BROKEN_PATH_FIX@$$/d
 endif
 
 ifeq (,$(HOST_CPU))
@@ -2545,26 +2545,8 @@ GIT-SCRIPT-DEFINES: FORCE
 		echo "$$FLAGS" >$@; \
             fi
 
-define cmd_munge_script
-sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-    -e 's|@DIFF@|$(DIFF_SQ)|' \
-    -e 's|@LOCALEDIR@|$(localedir_SQ)|g' \
-    -e 's/@USE_GETTEXT_SCHEME@/$(USE_GETTEXT_SCHEME)/g' \
-    -e $(BROKEN_PATH_FIX) \
-    -e 's|@GITWEBDIR@|$(gitwebdir_SQ)|g' \
-    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' \
-    -e 's|@PAGER_ENV@|$(PAGER_ENV_SQ)|g' \
-    [email protected] >$@+
-endef
-
-$(SCRIPT_SH_GEN) : % : %.sh GIT-SCRIPT-DEFINES
-	$(QUIET_GEN)$(cmd_munge_script) && \
-	chmod +x $@+ && \
-	mv $@+ $@
-
-$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
-	$(QUIET_GEN)$(cmd_munge_script) && \
+$(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES
+	$(QUIET_GEN)./generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \
 	mv $@+ $@
 
 git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
@@ -2633,8 +2615,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
 perllibdir:
 	@echo '$(perllibdir_SQ)'
 
-git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES
-	$(QUIET_GEN)$(cmd_munge_script) && \
+git-instaweb: git-instaweb.sh generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES
+	$(QUIET_GEN)./generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \
 	chmod +x $@+ && \
 	mv $@+ $@
 else # NO_PERL
@@ -3191,6 +3173,10 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@GIT_TEST_INDEX_VERSION@|\'$(GIT_TEST_INDEX_VERSION)\'|" \
 		-e "s|@GIT_TEST_PERL_FATAL_WARNINGS@|\'$(GIT_TEST_PERL_FATAL_WARNINGS)\'|" \
 		-e "s|@RUNTIME_PREFIX@|\'$(RUNTIME_PREFIX)\'|" \
+		-e "s|@GITWEBDIR@|\'$(gitwebdir_SQ)\'|" \
+		-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
+		-e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
+		-e "s|@BROKEN_PATH_FIX@|\'$(BROKEN_PATH_FIX)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
 	@if test -f GIT-BUILD-DIR; then rm GIT-BUILD-DIR; fi
contrib/buildsystems/CMakeLists.txt +19 -11
index ddf39dc90e7..2e22e87d188 100644
@@ -834,18 +834,22 @@ set(git_shell_scripts
 	${git_sh_scripts} ${git_shlib_scripts} git-instaweb)
 
 foreach(script ${git_shell_scripts})
-	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
-	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
-	string(REPLACE "@DIFF@" "diff" content "${content}")
-	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
-	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
-	string(REPLACE "@NO_CURL@" "" content "${content}")
-	string(REPLACE "@USE_GETTEXT_SCHEME@" "" content "${content}")
-	string(REPLACE "# @BROKEN_PATH_FIX@" "" content "${content}")
-	string(REPLACE "@PERL_PATH@" "${PERL_PATH}" content "${content}")
-	string(REPLACE "@PAGER_ENV@" "LESS=FRX LV=-c" content "${content}")
-	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+	if ("${script}" IN_LIST git_sh_scripts)
+		string(REPLACE ".sh" "" shell_gen_path "${script}")
+	else()
+		set(shell_gen_path "${script}")
+	endif()
+
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${shell_gen_path}
+		COMMAND ${CMAKE_SOURCE_DIR}/generate-script.sh
+			${CMAKE_SOURCE_DIR}/${script}.sh
+			${CMAKE_BINARY_DIR}/${shell_gen_path}
+			${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS
+		DEPENDS ${CMAKE_SOURCE_DIR}/generate-script.sh
+			${CMAKE_SOURCE_DIR}/${script}.sh)
+	list(APPEND shell_gen ${CMAKE_BINARY_DIR}/${shell_gen_path})
 endforeach()
+add_custom_target(shell-gen ALL DEPENDS ${shell_gen})
 
 #perl scripts
 parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
@@ -1156,6 +1160,10 @@ string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_optio
 string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
 string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
 string(REPLACE "@RUNTIME_PREFIX@" "${RUNTIME_PREFIX}" git_build_options "${git_build_options}")
+string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" git_build_options "${git_build_options}")
+string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
+string(REPLACE "@LOCALEDIR@" "LOCALEDIR" git_build_options "${git_build_options}")
+string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
generate-script.sh new file +34 -0
new file mode 100755
index 00000000000..d001e43d7bf
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+
+if test $# -ne 3
+then
+	echo "USAGE: $0 <INPUT> <OUTPUT> <GIT-BUILD-OPTIONS>" >&2
+	exit 1
+fi
+
+INPUT="$1"
+OUTPUT="$2"
+BUILD_OPTIONS="$3"
+
+. "$BUILD_OPTIONS"
+
+sed -e "1s|#!.*/sh|#!$SHELL_PATH|" \
+    -e "s|@SHELL_PATH@|$SHELL_PATH|" \
+    -e "s|@DIFF@|$DIFF|" \
+    -e "s|@LOCALEDIR@|$LOCALEDIR|g" \
+    -e "s/@USE_GETTEXT_SCHEME@/$USE_GETTEXT_SCHEME/g" \
+    -e "$BROKEN_PATH_FIX" \
+    -e "s|@GITWEBDIR@|$GITWEBDIR|g" \
+    -e "s|@PERL_PATH@|$PERL_PATH|g" \
+    -e "s|@PAGER_ENV@|$PAGER_ENV|g" \
+    "$INPUT" >"$OUTPUT"
+
+case "$(basename "$INPUT")" in
+git-mergetool--lib.sh|git-sh-i18n.sh|git-sh-setup.sh)
+	;;
+*)
+	chmod a+x "$OUTPUT"
+	;;
+esac
Signature · 1 line
2.47.0.72.gef8ce8f3d4.dirty