Subject: Re: [PATCH v2 1/5] GIT-VERSION-GEN: fix overriding version via environment

From: Junio C Hamano <[email-masked]>
Date: Fri, 20 Dec 2024 08:17:14 -0800

Jeff King <[email-masked]> writes:

> So I dunno. I like keeping things simple, but I also like skipping
> unnecessary code, too. Maybe if the top hunk were:
>
>   if test -n "$GIT_VERSION"
>   then
>     : do nothing, we will use this value verbatim
>   elif ...
>
> that would make the intended flow more obvious.

True.

> There are probably other ways to structure it, too. The whole $VN thing
> could be inside the:
>
>   if test -z "$GIT_VERSION"
>
> block. Or alternatively, if each block of the if/else just ran expr and
> set $GIT_VERSION itself (perhaps with a one-liner helper function) then
> we wouldn't need $VN at all.

True again.  It has been quite a while since I wrote the original
before the meson topic came up and the script hasn't changed for a
long time (other than DEF_VER line for obvious reasons), but I think
in that ancient version, $VN _was_ the variable to be looked at and
GIT_VERSION did not even exist as a shell variable at all.

If $GIT_VERSION is serving the same role as old $VN in the
mesonified version, perhaps we should get rid of the $VN variable to
clarify the new world order.

> I don't know how much trouble it's worth to refactor all this. Mostly I
> was just surprised to see the first hunk at all in this version.
>
> -Peff