Re: [PATCH v2 1/5] GIT-VERSION-GEN: fix overriding version via environment
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 20, 2024, 16:23 UTC
- Message-ID
- <Z2WZ_6auUm0mVIqr@pks.im>
- In-Reply-To
- <xmqqpllme3cl.fsf@gitster.g>
On Fri, Dec 20, 2024 at 08:17:14AM -0800, Junio C Hamano wrote:
Show 32 quoted lines
> Jeff King <peff@peff.net> 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 think for now I'll keep $VN, if even just to discern the intermediate value without the leading "v" stripped from the final version that we have in "$GIT_VERSION". But I'll send a revised version where I make the control flow a bit more obvious.
Thanks!
Patrick