1

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={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},
    refnames={ (HEAD -> master)},
    firsttagdescribe={e78b91e},
    reltag={e78b91e}
]{gitexinfo}
2
  • 1
    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

1 Answer 1

2

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.

0

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.