\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gitinfo2}[2014/05/12 v2.00 git revision information]
\RequirePackage{etoolbox}
\RequirePackage{kvoptions}
\RequirePackage{eso-pic}
\SetupKeyvalOptions{ family=gitinfo,
prefix=gitInf@
}
\DeclareBoolOption{draft}
\DeclareBoolOption{grumpy}
\DeclareBoolOption{pcount}
\DeclareBoolOption{footinfo}
\DeclareBoolOption{mark}
\DeclareBoolOption{markifdraft}
\DeclareBoolOption{markifdirty}
\DeclareStringOption[(None)]{missing}
\DeclareStringOption[(None)]{notags}
\DeclareStringOption[(*)]{dirty}
\DeclareStringOption[4]{maxdepth}
\ProcessKeyvalOptions*
\newcommand{\gitAbbrevHash}{\gitInf@missing}
\newcommand{\gitHash}{\gitInf@missing}
\newcommand{\gitAuthorName}{\gitInf@missing}
\newcommand{\gitAuthorEmail}{\gitInf@missing}
\newcommand{\gitAuthorDate}{\gitInf@missing}
\newcommand{\gitAuthorIsoDate}{\gitInf@missing}
\newcommand{\gitAuthorUnixDate}{\gitInf@missing}
\newcommand{\gitCommitterName}{\gitInf@missing}
\newcommand{\gitCommitterEmail}{\gitInf@missing}
\newcommand{\gitCommitterDate}{\gitInf@missing}
\newcommand{\gitCommitterIsoDate}{\gitInf@missing}
\newcommand{\gitCommitterUnixDate}{\gitInf@missing}
\newcommand{\gitTags}{}
\newcommand{\gitFirstTagDescribe}{\gitInf@missing}
\newcommand{\gitReferences}{\gitInf@missing}
\newcommand{\gitBranch}{\gitInf@missing}
\newcommand{\gitVtag}{}
\newcommand{\gitVtags}{}
\newcommand{\gitVtagn}{\space\gitInf@missing}
\newcommand{\gitRel}{}
\newcommand{\gitRels}{}
\newcommand{\gitReln}{\space\gitInf@missing}
\newcommand{\gitDirty}{}
\newcommand{\gitRoff}{}
\newcommand{\gitDescribe}{(None)}
\newcommand{\gitMarkPref}{[git]}
\newcommand{\gitMarkFormat}{\color{gray}\small\sffamily}
\newcommand{\gitMark}{}
\newif\ifGI@is@a@repo@
\providecommand{\GI@repo@prefix}{}
\providecommand{\GI@githeadinfo@file}{\GI@repo@prefix.git/gitHeadInfo.gin}
\newcommand{\gitInf@dirtflag}{}
\newcommand{\gitInf@describe}{}
\newcommand{\gitInf@mcount}{}
\newcommand{\gitInf@rel}{}
\newcommand{\gitInf@off}{}
\newcommand\GI@export@macro[1]{ \edef\@tempa{\endgroup
\def\noexpand#1{#1}} \@tempa}
\newcommand\GI@check@repo@prefix{ \GI@is@a@repo@true
\IfFileExists{./\GI@githeadinfo@file}{ \edef\GI@repo@prefix{./} }{ \GI@set@repo@prefix}}
\newcommand\GI@set@repo@prefix{ \begingroup \count@\gitInf@maxdepth\relax
\GI@set@repo@prefix@}
\newcommand\GI@set@repo@prefix@{ \advance\count@\m@ne
\ifnum\count@<\z@
\endgroup\relax
\else
\edef\GI@repo@prefix{../\GI@repo@prefix} \IfFileExists{\GI@githeadinfo@file}{ \PackageWarningNoLine{gitinfo2}{ gitinfo2 found : \GI@githeadinfo@file \MessageBreak
} \GI@export@macro\GI@githeadinfo@file
}{ \expandafter\GI@set@repo@prefix@} \fi}
\GI@check@repo@prefix
\InputIfFileExists{\GI@githeadinfo@file}{}{ \ifbool{gitInf@grumpy}{ \PackageError{gitinfo2}{I can't find the file '\GI@githeadinfo@file'\MessageBreak
Please check the manual (gitinfo2.pdf) \MessageBreak
if you need more details}{}
}{ \PackageWarningNoLine{gitinfo2}{I can't find the file '\GI@githeadinfo@file'.\MessageBreak
All git metadata has been set to '\gitInf@missing'}
}
}
\@ifclassloaded{memoir}{ \ifbool{gitInf@pcount}{
\newcommand{\@gitPage}{\thepage/\thelastpage}
\addtodef{\frontmatter}{\renewcommand{\@gitPage}{\thepage}}{}
\addtodef{\mainmatter}{}{\renewcommand{\@gitPage}{\thepage/\thelastpage}}
}{ \newcommand{\@gitPage}{\thepage}
}
\newcommand{\@gitFootRev}{Release\gitRels: \gitAbbrevHash{} (\gitAuthorDate)}
\newcommand{\@gitrFootRev}{ \tiny\textsf{\raggedleft \@gitFootRev} }
\newcommand{\@gitlFootRev}{ \tiny\textsf{\@gitFootRev} }
\copypagestyle{giplain}{plain}
\copypagestyle{giruled}{ruled}
\copypagestyle{giheadings}{headings}
\makeevenfoot{giplain}{\@gitPage}{}{\@gitrFootRev}
\makeoddfoot{giplain}{\@gitlFootRev}{}{\@gitPage}
\makeevenfoot{giruled}{\@gitPage}{}{\@gitrFootRev}
\makeoddfoot{giruled}{\@gitlFootRev}{}{\@gitPage}
\makeevenfoot{giheadings}{\@gitPage}{}{\@gitrFootRev}
\makeoddfoot{giheadings}{\@gitlFootRev}{}{\@gitPage}
\makeevenhead{giheadings}{}{}{\slshape\leftmark}
\makeoddhead{giheadings}{\slshape\rightmark}{}{}
}{}
\ifbool{gitInf@markifdirty}{ \IfEq{\gitDirty}{}{}{ \booltrue{gitInf@mark}
\renewcommand{\gitMarkPref}{[Dirty]}
}}{}\ifbool{gitInf@markifdraft}{ \ifbool{gitInf@draft}{ \booltrue{gitInf@mark}
\renewcommand{\gitMarkPref}{[Draft]}
}{}}{}\ifbool{gitInf@mark}{ \AddToShipoutPictureBG{ \AtPageLowerLeft{ \raisebox{15pt}{ \makebox[\paperwidth]{ \begin{minipage}{\paperwidth} \renewcommand{\baselinestretch}{1} \centering{\gitMarkFormat\gitMarkPref{} \gitMark} \end{minipage} } } } }}{}