Re: [PATCH] GIT-VERSION-GEN: allow it to be run in parallel
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Jan 9, 2025, 18:33 UTC
- Message-ID
- <CAN0heSo2pFmfx=zJgx2T6y+W1tG_PTXxf6uk2kBgi4c0kXz_oQ@mail.gmail.com>
- In-Reply-To
- <pull.1850.git.1736432663587.gitgitgadget@gmail.com>
On Thu, 9 Jan 2025 at 15:24, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 6 quoted lines
> And this is how that race surfaces: When calling `make -j2 html man` > from the top-level directory (a variant of which is invoked in Git for > Windows' release process), two sub-processes are spawned, a `make -C > Documentation html` one and a `make -C Documentation man` one. Both run > the rule to (re-)generate `asciidoctor-extensions.rb` or > `asciidoc.conf`, invoking `GIT-VERSION-GEN` to do so.
Nicely described. Indeed, there's a reason recursive make is considered harmful. This is of course not the time or place for addressing that.
Show 7 quoted lines
> Incidentally, this also fixes something else: The `+` character is > not even a valid filename character on Windows. The only reason why Git > for Windows did not need this is that above-mentioned POSIX emulation > layer also plays a couple of tricks with filenames (tricks that are not > interoperable with regular Windows programs, though), and previous > attempts to remedy this in git/git were unsuccessful, see e.g. > https://lore.kernel.org/git/pull.216.git.gitgitgadget@gmail.com/
Show 12 quoted lines
> - "$INPUT" >"$OUTPUT"+ > + "$INPUT" >"$OUTPUT".$$ > > -if ! test -f "$OUTPUT" || ! cmp "$OUTPUT"+ "$OUTPUT" >/dev/null > +if ! test -f "$OUTPUT" || ! cmp "$OUTPUT".$$ "$OUTPUT" >/dev/null > then > - mv "$OUTPUT"+ "$OUTPUT" > + mv "$OUTPUT".$$ "$OUTPUT" > else > - rm "$OUTPUT"+ > + rm "$OUTPUT".$$ > fi
Our `.gitignore` contains an entry "*+" to ignore this sort of temporary files. Yes, they're supposed to disappear within a second or so, but according to f9bbaa384e (Add intermediate build products to .gitignore, 2009-11-08), they can linger after interrupted builds. Maybe separate tooling built around git could pick up these as untracked files for a second, causing them to come and go in whatever GUI.
You could use "$OUTPUT"."$$"+ to restore this. That of course invalidates your remark about "Incidentally, ..." above, but might give this fix a tiny bit less chance of regressing something somewhere?
Martin