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

2 messages from 2011-10-09 to 2011-10-09. Participants: fkater@googlemail.com, Jonathan Nieder.
Thread: https://gitlist.dev/t/28638

## fkater@googlemail.com, 2011-10-09 16:29

Subject: Check revision and if no files modified (looking for svnversion equivalent)
Message-ID: <20111009162902.GA3000@comppasch2>
URL: https://gitlist.dev/e/20111009162902.GA3000%40comppasch2

```
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, 2011-10-09 18:10

Subject: Re: Check revision and if no files modified (looking for svnversion equivalent)
Message-ID: <20111009181040.GA31303@elie.hsd1.il.comcast.net>
URL: https://gitlist.dev/e/20111009181040.GA31303%40elie.hsd1.il.comcast.net
In-Reply-To: <20111009162902.GA3000@comppasch2>

```
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.

> 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

```
