How about something like the following? diff --git a/VERSION b/VERSION index 998eb1f..29a22f8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -$Format:%d$ +$Format:%d;%(describe)$ diff --git a/bld/get-version b/bld/get-version index 1f51768..4ba3646 100755 --- a/bld/get-version +++ b/bld/get-version @@ -24,13 +24,19 @@ if which git >/dev/null 2>&1 && \ ([ -d .git ] || grep '^gitdir:' .git >/dev/null 2>&1) && \ git describe >/dev/null 2>&1; then git describe | sed 's/^v//' -elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then +elif grep '\$Format:%d;%(describe)\$' $1/VERSION >/dev/null 2>&1; then # unsubstituted VERSION, but no git available. echo UNKNOWN else - vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep ^v[0-9]` + vers=`cut -d';' -f1 $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep ^v[0-9]` + ret=$?
- if [ $? -eq 0 ]; then + if [ ${ret} -ne 0 ]; then + vers=`cut -d';' -f2 $1/VERSION | grep ^v[0-9]` + ret=$? + fi + + if [ ${ret} -eq 0 ]; then echo "${vers}" | sort -k1.2,1.5Vr -k1.6,1.6 -k1.8,1.9Vr -k1.10,1.11Vr | head -n 1 | sed 's/^v//' else cat $1/VERSION This appends ";%(describe)" to the format. The script will try to parse the contents of %d first, then %(describe). This should have minimal impact. On Tue, 13 Sept 2022 at 06:52, Johnny S. Lee <_...@jsl.io> wrote: > > > I'm not clear what the difference between that and %(describe) is. The > > substituted value is used subtly in get-version as part of the > > build-process, so we need to be a little careful about changing things. > > $ git log -10 --format="'%d'" > ' (HEAD -> master, origin/master, origin/HEAD)' > ' (tag: v2.87rc1)' > '' > '' > '' > '' > '' > '' > '' > ' (tag: v2.87test9)' > $ git log -10 --format="'%(describe)'" > 'v2.87rc1-1-gc4b9bc6' > 'v2.87rc1' > 'v2.87test9-7-g04cc2ae' > 'v2.87test9-6-g32588c7' > 'v2.87test9-5-g84a6d07' > 'v2.87test9-4-gd6c69f6' > 'v2.87test9-3-gce37291' > 'v2.87test9-2-g09d741f' > 'v2.87test9-1-g0666ae3' > 'v2.87test9' > > Output of get-version should be the same for tagged commits. > Note that the %(describe) placeholder is rather new. It was added in > Git 2.32 last year. > > > On Mon, 12 Sept 2022 at 23:19, Simon Kelley <si...@thekelleys.org.uk> wrote: > > > > > > The current format is %d, which is > > > > "ref names, like the --decorate option of git-log[1]" > > > > according to git help log. > > > > I'm not clear what the difference between that and %(describe) is. The > > substituted value is used subtly in get-version as part of the > > build-process, so we need to be a little careful about changing things. > > > > When the build runs on a fully-fledged git repo, rather than a tar file > > extracted from one, get-version does run "git describe". This isn't the > > case during the automated build, however. > > > > > > Simon. > > > > > > On 12/09/2022 04:51, Johnny S. Lee via Dnsmasq-discuss wrote: > > > The contents of file VERSION from the tar.gz files of the latest 3 > > > commits: > > > > > > dnsmasq-c4b9bc6/VERSION: (HEAD -> master) > > > dnsmasq-4447d48/VERSION: (tag: v2.87rc1, origin/master, origin/HEAD) > > > dnsmasq-04cc2ae/VERSION: > > > > > > Would it be better adding "%(describe)" to the format in file VERSION? > > > > > > _______________________________________________ > > > Dnsmasq-discuss mailing list > > > Dnsmasq-discuss@lists.thekelleys.org.uk > > > https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss > > > > > > > _______________________________________________ > > Dnsmasq-discuss mailing list > > Dnsmasq-discuss@lists.thekelleys.org.uk > > https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss _______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss