Re: Unexpected effect of log.showSignature on tformat:%H.
- From
- Niels Möller <nisse@glasklarteknik.se>
- Date
- Nov 19, 2024, 10:06 UTC
- Message-ID
- <878qtftu5e.fsf@localhost>
- In-Reply-To
- <xmqqmshvd0nn.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> It is a bit unexpected, but knowing how the command options evolved, > it is not all that surprising X-<. If you are using --format, you > are expected to use the %G placeholder and friends when you are > interested in signatures.
The thing is, I'm generally interested in signatures when using git interactively (that's why I enabled log.showSignature globally). But then I have a scripted usecase that has a tag name, and needs to query the corresponding commit hash, and in that context, I don't care about signatures at all. The docs for git show say that %H expands to the commit hash, which is exactly what I want. I didn't know about the %G formats, but after a quick look at the docs, I don't think they solves that problem.
I can work around this problem by using "export GIT_CONFIG_GLOBAL=/dev/null" in the script, which I guess might be generally good practice when using git in scripts? But I still think it would be useful if there were an easy and reliable way to get from tag to commit hash, regardless of the user's config settings.
Regards, /Niels Möller