# 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},
authname={Abcd Efgh},
authemail={abcd@example.org},
authsdate={2018-02-19},
authidate={2018-02-19 20:00:05 +0100},
authudate={1519066805},
commname={Abcd Efgh},
commemail={abcd@example.org},
commsdate={2018-02-19},
commidate={2018-02-19 20:02:01 +0100},
commudate={1519066921},
firsttagdescribe={e78b91e},
reltag={e78b91e}
]{gitexinfo}

• if you put \show\gitBranch before the ifthenelse, what does the log message say? Feb 19, 2018 at 20:24
• > \gitBranch=\long macro: ->\detokenize \expandafter {\bcut }. l.6 \show\gitBranch
– ulm
Feb 20, 2018 at 8:23

 \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.