Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_describe() and --dirty #35

Closed
Zeex opened this issue Apr 4, 2015 · 10 comments
Closed

git_describe() and --dirty #35

Zeex opened this issue Apr 4, 2015 · 10 comments

Comments

@Zeex
Copy link

Zeex commented Apr 4, 2015

It seems that git_describe() can't be used with --dirty - it will always return -128-NOTFOUND. When running the same command from the command line yields this:

$git describe HEAD --dirty
fatal: --dirty is incompatible with commit-ishes

So basically git doesn't like that we're passing both hash and --dirty. I don't see why we have to pass commit hash to git describe in git_describe(), by default git will just assume HEAD.

@Zeex
Copy link
Author

Zeex commented Apr 4, 2015

Or is it because cmake is re-run only after a commit is done and that makes --dirty basically useless?

@rpavlik
Copy link
Owner

rpavlik commented Apr 8, 2015

Well, the script is set up to trigger a CMake re-run if a commit is done. Not sure about --dirty, haven't used it myself, though it does seem useful: is that a feature of only newer git versions? I could see changing the logic so that if we are just looking at head, we omit the commit and pass --dirty.

@LeSpocky
Copy link

No it's not new, I remember using git describe --tags --dirty for years.

@fo-fo
Copy link

fo-fo commented Jan 1, 2016

Would like to see this supported as well. Preferably it would also automatically re-run CMake if the repo changes from dirty to clean state and vice versa.

@lp35
Copy link

lp35 commented Nov 9, 2017

Hi, seems that this issue is still present. Maybe some more information here about this modification: https://stackoverflow.com/questions/16035240/why-is-git-describe-dirty-adding-a-dirty-suffix-when-describing-a-clean-ch

I'll try to fix this.

@Ecordonnier
Copy link

The issue is still happening. If I prepare a patch just removing the hash from the call to git_describe would you merge it? I don't see a use-case for calling git-describe with anothe parameter than HEAD.

@Ecordonnier
Copy link

Ecordonnier commented Jul 18, 2019

Something like this works for my use-case:

0001-cmake-fix-git_describe-not-working-with-dirty.txt

Edit: this does NOT work. Removing the hash from the list of parameters has the side-effect that cmake does not re-generate the version string when the git commit changes.

@Ecordonnier
Copy link

I also recommend removing "ERROR_QUIET". Failing the build with the git error visible in the logs is better than silently printing "128-NOTFOUND" as a version string in my opinion.

@lp35
Copy link

lp35 commented Jul 18, 2019

agreed on ERROR_QUIET

@rpavlik
Copy link
Owner

rpavlik commented Aug 5, 2020

There is now a git_describe_working_tree that does a git describe --dirty without the fancy commit-ish magic of the normal function. I think this should solve things.

@rpavlik rpavlik closed this as completed Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants