[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Version string with git(1) (-dirty)
From: |
Alejandro Colomar |
Subject: |
Re: Version string with git(1) (-dirty) |
Date: |
Fri, 23 Feb 2024 15:25:05 +0100 |
On Fri, Feb 23, 2024 at 03:20:58PM +0100, Alejandro Colomar wrote:
> Hi Branden,
>
> I notice that when I build groff(1) from source, it gets its version
> from git(1), and if the repository is dirty (has modifications on top of
> the last commit), the version string has a "-dirty" suffix.
>
> I was wondering how you get the version string, because I'd like to use
> that "-dirty" suffix in the Linux man-pages too. Currently, I'm doing:
>
> $ grep -rh ^DISTVERSION.*= share/mk/
> DISTVERSION := $(patsubst man-pages-%,%,$(DISTNAME))
> $ grep -rh ^DISTNAME.*= share/mk/
> DISTNAME := $(shell $(GIT) describe)
>
> which results in the following version string:
>
> $ make nothing -p | grep ^DISTVERSION.*=
> DISTVERSION := 6.06-25-g9af39fc94
>
> even with a dirty repository.
>
> So, how do you get that "-dirty" suffix? Is it autotools? Or git? Or
> is it specific to the groff build system? I could use some shell code
> in the makefile to get it, but was asking mainly in case git already
> gives that somehow.
Never mind, I should RTFM. :)
$ MANWIDTH=72 man git-describe | sed -n '/^ *--dirty/,/^$/p'
--dirty[=<mark>], --broken[=<mark>]
Describe the state of the working tree. When the working tree
matches HEAD, the output is the same as "git describe HEAD".
If the working tree has local modification "-dirty" is
appended to it. If a repository is corrupt and Git cannot
determine if there is local modification, Git will error out,
unless ‘--broken’ is given, which appends the suffix
"-broken" instead.
>
> Have a lovely day!
> Alex
>
> --
> <https://www.alejandro-colomar.es/>
> Looking for a remote C programming job at the moment.
--
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.
signature.asc
Description: PGP signature