# get git metadata (using gitinfo2) of input file directory rather than current directory

I have one git repository that I'm calling my book directory.

Within that I have a tex file that calls a bunch of chapters or sections that are in their own git directories.

My goal is to the get the watermark throughout the book to display the git information for the book repository, while the header of each chapter displays the git metadata for the individual chapter repository.

A slightly simplified version of the book file looks like this.

\documentclass[twoside, openright]{book}
\usepackage{standalone}
%many more packages here
%git package
\usepackage{gitinfo2}
%watermark
\usepackage{draftwatermark}
\SetWatermarkText{\gitDescribe}

\begin{document}
\begin{titlepage}
\tableofcontents
\input{../graciliscommentary/pg-b1q1/pg-b1q1}
\input{../graciliscommentary/pg-b1q2/pg-b1q2}
\input{../graciliscommentary/pg-b1q3/pg-b1q3}
\input{../graciliscommentary/pg-b1q4/pg-b1q4}
\input{../graciliscommentary/pg-b1q5/pg-b1q5}
\input{../graciliscommentary/pg-b1q6/pg-b1q6}
\printindex[persons]
\printindex[works]
\end{document}


But the beginning of an input file also asks for a git metadata about the individual chapter.

 \begin{document}
\chapter*{Librum I, Quaestio 1}


Here you can see that each chapter has its own git source history. And I'd like the header of that chapter to display the current tag information (i.e. \gitDescribe) unique to the chapter itself.

Nevertheless, I'd like the watermark to continue to display the git tag information for the book as a whole.

Right now, it's almost working. But the information in the header of chapter 1 is actually the git metadata for the book repository and not the information from its own repository.

I'm grateful for any and all suggestions.

This is more a git comment, but if your book is one project with interrelated pieces (chapters, whatever), you should handle it as one repository with common history. What you describe made sense with one-file version control, like the venerable rcs(1).