Skip to content

Commit f62d870

Browse files
committed
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. The paragraph 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/[email protected]/ no longer applies. It is not like this cript was the only offender.
1 parent 1ff76f5 commit f62d870

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

GIT-VERSION-GEN

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail
7878
$(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ')
7979
EOF
8080

81+
OUTPUT_TMP="$OUTPUT.$$+"
82+
8183
sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \
8284
-e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \
8385
-e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \
@@ -86,11 +88,11 @@ sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \
8688
-e "s|@GIT_BUILT_FROM_COMMIT@|$GIT_BUILT_FROM_COMMIT|" \
8789
-e "s|@GIT_USER_AGENT@|$GIT_USER_AGENT|" \
8890
-e "s|@GIT_DATE@|$GIT_DATE|" \
89-
"$INPUT" >"$OUTPUT".$$
91+
"$INPUT" >"$OUTPUT_TMP"
9092

91-
if ! test -f "$OUTPUT" || ! cmp "$OUTPUT".$$ "$OUTPUT" >/dev/null
93+
if ! test -f "$OUTPUT" || ! cmp "$OUTPUT_TMP" "$OUTPUT" >/dev/null
9294
then
93-
mv "$OUTPUT".$$ "$OUTPUT"
95+
mv "$OUTPUT_TMP" "$OUTPUT"
9496
else
95-
rm "$OUTPUT".$$
97+
rm "$OUTPUT_TMP"
9698
fi

0 commit comments

Comments
 (0)