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

Re: [PATCH v2] GIT-VERSION-GEN: allow it to be run in parallel

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 10, 2025, 16:55 UTC
Message-ID
<xmqqldvi8v83.fsf@gitster.g>
In-Reply-To
<pull.1850.v2.git.1736509717426.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

>      * Appended + again, to get the benefit of the .gitignore pattern that
>        prevents the temporary files from being committed.

I had queued an incremental fix-up in my tree on top, which may have been easier to read, but you did the testing on a system that showed the problem earlier, so I'll drop it (together with the v1) and replace them with this one.

Thanks.
--- >8 ---
Subject: [PATCH] Make sure the name of the temporary file ends with "+"

To avoid regression by leaving untracked cruft that is not covered by the .gitignore file, match the convention to generate into $name$suffix and then move to $name where $suffix ends with "+", which is used everywhere else in the system.

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 5b49e2d72f..bc11258d9b 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -78,6 +78,8 @@ read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail
 $(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ')
 EOF
 
+OUTPUT_TMP="$OUTPUT.$$+"
+
 sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \
 	-e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \
 	-e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \
@@ -86,11 +88,11 @@ sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \
 	-e "s|@GIT_BUILT_FROM_COMMIT@|$GIT_BUILT_FROM_COMMIT|" \
 	-e "s|@GIT_USER_AGENT@|$GIT_USER_AGENT|" \
 	-e "s|@GIT_DATE@|$GIT_DATE|" \
-	"$INPUT" >"$OUTPUT".$$
+	"$INPUT" >"$OUTPUT_TMP"
 
-if ! test -f "$OUTPUT" || ! cmp "$OUTPUT".$$ "$OUTPUT" >/dev/null
+if ! test -f "$OUTPUT" || ! cmp "$OUTPUT_TMP" "$OUTPUT" >/dev/null
 then
-	mv "$OUTPUT".$$ "$OUTPUT"
+	mv "$OUTPUT_TMP" "$OUTPUT"
 else
-	rm "$OUTPUT".$$
+	rm "$OUTPUT_TMP"
 fi

--- 8< ---

>  GIT-VERSION-GEN | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index 6d1cb66d69a..2e2d0811581 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -86,11 +86,11 @@ sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \
>  	-e "s|@GIT_BUILT_FROM_COMMIT@|$GIT_BUILT_FROM_COMMIT|" \
>  	-e "s|@GIT_USER_AGENT@|$GIT_USER_AGENT|" \
>  	-e "s|@GIT_DATE@|$GIT_DATE|" \
> -	"$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
>
> base-commit: a60673e9252b08d4eca90543b3729f4798b9aafd
Previous: Johannes Schindelin via GitGitGadget
Message 5 of 5 in “GIT-VERSION-GEN: allow it to be run in parallel”
  1. GIT-VERSION-GEN: allow it to be run in parallelJohannes Schindelin via GitGitGadget, Jan 9, 2025
  2. Martin ÅgrenJan 9, 2025
  3. Junio C HamanoJan 9, 2025
  4. GIT-VERSION-GEN: allow it to be run in parallelJohannes Schindelin via GitGitGadget, Jan 10, 2025
  5. Junio C HamanoJan 10, 2025

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

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