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.

  • 1
    You're correct; gitinfo only provides information for the current HEAD. I considered the approach you're suggesting, but it may be unsafe if, for example, you have a private style file in your project that affects the output, but doesn't actually "appear on a page". Knowing the revision id for the whole project does allow you to know exactly which versions of files were used, but obviously in a less-convenient manner. Aug 5 '12 at 22:13
  • I have a similar problem - would be great to pull revision information of each include and display as a footer. Oct 12 '12 at 13:37

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.