[Tex/LaTex] Can you put git revision information in a multifile document

githeader-footerincluderevision control

I have my PhD thesis under revision control (git), with a master file (~/Thesis/thesis.tex) using the \include command to include the chapters (~/Thesis/tex/chapter1.tex, etc).

Is there a way to include the revision information of each separate chapter in the header of each page for each respective chapter?

I thought I was getting somewhere with a combination of the gitinfo and fancyhdr packages, but I'm not sure if you can have different revision headers under gitinfo.

Best Answer

Not directly, no; git doesn't distinguish between files (or something like that) and it doesn't store metadata on the last revision that affected each file.

I think the best option would be to write a post-commit hook that looked at the changed files and wrote a timestamp corresponding to each. E.g., iterate through the output of

git show --pretty="format:" --name-only master

and write a <filename>.datestamp file when each file is seen. This file could then be read directly into a header/footer to show when the chapter was lasted edited.