Bash – extracting “tag” information from git with a shell script

awkbashgit

The vc bundle is a neat little package that extracts information about a git repo for easy insertion into a LaTeX document. It doesn't currently extract information about whether the current commit is tagged and what the tag name is. How would I edit the vc script to do this?

And then how would I edit the vc-git.awk script to add an extra line to the generated vc.tex file? Presumably I want a line that looks like:

print "\\gdef\\GITTag{" Tag "}%"

but I need an earlier line that tells awk what " Tag " means?

This isn't a question about LaTeX, it is about git, awk and bash…

Best Answer

git log --decorate -1 [commit]

If commit (HEAD if omitted) has tags, the commit hash will be followed by (tag: name) (and possibly multiple other symbolic references too). You can pick this out more specifically with

git log --pretty=%d
Related Question