threads / discuss / 28638

Check revision and if no files modified (looking for svnversion equivalent)

Subject: Check revision and if no files modified (looking for svnversion equivalent)

## tl;dr

2 messages between Oct 9, 2011 and Oct 9, 2011.

replies: 1people: 2as markdown or json

fkater@googlemail.com· Oct 9, 2011, 16:29 UTC · lore
Hi,

in my subversion software repository I use the 'svnversion' command to do both:

- get the last revision (e.g. r1001)
- check for modified files not yet checked in (e.g. r1001 M)

Both information is required for the application's build process (Makefiles):

- to display the version in the application
- to refuse to build a proper 'release' version if something
  was not checked in
Would there be a way to do both in git somehow?
 Felix
Jonathan Nieder· Oct 9, 2011, 18:10 UTC · re: fkater@googlemail.com · lore

Re: Check revision and if no files modified (looking for svnversion equivalent)

fkater@googlemail.com wrote:
> - get the last revision (e.g. r1001)
> - check for modified files not yet checked in (e.g. r1001 M)

"git describe --dirty", maybe. Thanks to Jean Privat for inventing it.

Show 6 quoted lines
> Both information is required for the application's build
> process (Makefiles):
>
> - to display the version in the application
> - to refuse to build a proper 'release' version if something
>   was not checked in
Ok, this seems like two different needs.
- For the former, see GIT-VERSION-GEN in git.git for inspiration.
- For the latter, I'd recommend something like
	git update-index -q --refresh &&
	git diff-index --quiet HEAD ||
	{
		echo >&2 fail
		exit 1
	}

Hope that helps, Jonathan

← back to recent threads