Re: [PATCH 1/2] GIT-VERSION-GEN: fix overriding version via environment
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 19, 2024, 18:49 UTC
- Message-ID
- <xmqq8qsbik42.fsf@gitster.g>
- In-Reply-To
- <20241219-b4-pks-git-version-via-environment-v1-1-9393af058240@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> worked somewhat by chance, only: ... > > But that subtle mechanism broke with 4838deab65 (Makefile: refactor > GIT-VERSION-GEN to be reusable, 2024-12-06) and subsequent commits
With such a nice analysis, it does not look like it was "by chance" working, though ;-) And ...
Show 8 quoted lines
> because the version information is not propagated via the Makefile > variable anymore, but instead via the files that `GIT-VERSION-GEN` > started to write. And as the script never knew about the `GIT_VERSION` > environment variable in the first place it uses one of the values listed > above instead of the overridden value. > > Fix this issue by making `GIT-VERSION-GEN` handle the case where > `GIT_VERSION` has been set via the environment.
... the "fix" sounds very much the logical and only correct solution.
Thanks, queued.
Show 22 quoted lines
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> GIT-VERSION-GEN | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index de0e63bdfbac263884e2ea328cc2ef11ace7a238..787c6cfd04f0a43d0c1c8a6690185d26ccf2fc2f 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -29,7 +29,10 @@ export GIT_CEILING_DIRECTORIES
>
> # First see if there is a version file (included in release tarballs),
> # then try git-describe, then default.
> -if test -f "$SOURCE_DIR"/version
> +if test -n "$GIT_VERSION"
> +then
> + VN="$GIT_VERSION"
> +elif test -f "$SOURCE_DIR"/version
> then
> VN=$(cat "$SOURCE_DIR"/version) || VN="$DEF_VER"
> elif {