ifthen condition fails for gitinfo2 metadata

ifthen condition fails for gitinfo2 metadata

I am using the gitinfo2 package (2.0.7) together with the ifthen package (v1.1c), both from TeXLive 2017, in order to include Git metadata in my document:

\documentclass{article}
\usepackage[local]{gitinfo2}
\usepackage{ifthen}
\begin{document}
commit \gitAbbrevHash
\ifthenelse{\equal{\gitBranch}{master}}{}{ on branch \gitBranch}%
\ifthenelse{\equal{\gitDirty}{}}{}{ with local changes}
\end{document}

The intention is that the name of the branch should be printed, but only if it is not the master branch. So for the example I would expect only "commit e78b91e". However, the result is "commit e78b91e on branch master".

In other words, the test for \gitBranch always evaluates to false (while the test for \gitDirty works correctly). What am I missing?

Here is the contents of the gitHeadLocal.gin file:

\usepackage[%
    shash={e78b91e},
    lhash={e78b91e0e8582d75273ad4f04bda5ae3c52055bd},
    authname={Abcd Efgh},
    authemail={[email protected]},
    authsdate={2018-02-19},
    authidate={2018-02-19 20:00:05 +0100},
    authudate={1519066805},
    commname={Abcd Efgh},
    commemail={[email protected]},
    commsdate={2018-02-19},
    commidate={2018-02-19 20:02:01 +0100},
    commudate={1519066921},
    refnames={ (HEAD -> master)},
    firsttagdescribe={e78b91e},
    reltag={e78b91e}
]{gitexinfo}

답변1

If the package sets

 \gitBranch=\long macro: ->\detokenize \expandafter {\bcut }

Then you get the same issue that occurs if you try to test the current filename as \jobname the characters are all catcode 12 (like punctuation) not catcode 11 (letters) however you can use the same \detokenize e-tex primitive to get a catcode 12 test string, test against \detokenize{master} rather than master.

관련 정보