I am using a smudge filter to expand keywords (e.g. Commit Hash, Author, Date). The script is written in python and triggers "git log" in a subprocess to retrieve the information. Everything works fine if I delete a file and check it out again.
But when I am switching branches, the information expanded into the files is wrong. I figured out that the smudge script runs before the HEAD switches to the branch I want to check out, which makes sense to me. So in that case "git log" will give me the information of the branch I am coming from and not the branch I am switching to.
How can I know which branch is to be checked out in a smudge script? Or how do I retrieve information from the branch I am switching to?
Neither the commit hash nor the ref being checked out are available to smudge and clean filters. It could possibly be passed in the new
filter.<driver>.processform as an attribute, but nobody has implemented that in Git yet.If you want to implement just the commit hash, you can specify the
identattribute in the.gitattributesfile in your repository, like so:and then you can write
$Id$in your code and it will be expanded automatically. That's the only thing that's possible in this case.