Re: [PATCH v2 1/5] GIT-VERSION-GEN: fix overriding version via environment
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 20, 2024, 16:17 UTC
- Message-ID
- <xmqqpllme3cl.fsf@gitster.g>
- In-Reply-To
- <20241220155223.GA152570@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> 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.
Show 8 quoted lines
> 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