Debian Codegraph @

texmf-dist/doc/latex/gitinfo2/gitinfo2.tex

raw
1 % gitinfo2.tex
2 % Copyright 2015 Brent Longborough
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 % The Current Maintainer of this work is Brent Longborough.
14 %
15 % This work consists of these files:
16 % gitinfo2.sty, gitexinfo.sty, gitinfo2.tex, gitinfo2.pdf,
17 % gitinfotest.tex, post-xxx-sample.txt,
18 % and gitHeadLocal.gin
19 % -----------------------------------------------------
20 \documentclass[a4paper,12pt,twoside,openany]{memoir}
21 % =====================================================
22 \usepackage[british]{babel}
23 \selectlanguage{british}
24 \usepackage[style=iso]{datetime2}
25 \usepackage[local,pcount,grumpy,mark,markifdirty]{gitinfo2}
26 \usepackage{tgpagella}
27 \usepackage{tgadventor}
28 \usepackage{fontspec}
29 \setmainfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Pagella}
30 \setsansfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Adventor}
31 \setmonofont{Consolas}
32 \usepackage{enumitem}
33 \setlist[description]{%
34 format=\ttfamily\bfseries,
35 style=nextline,
36 leftmargin=5em,
37 itemsep=0.5\onelineskip}
38 \setulmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
39 \setlrmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
40 \setheadfoot{1.2\baselineskip}{0.0849\paperwidth}
41 \setmarginnotes{0.125\foremargin}{0.75\foremargin}{\onelineskip}
42 \setheaderspaces{*}{*}{0.618}
43 \checkandfixthelayout[fixed]
44 \makepagenote
45 \continuousnotenums
46 \notepageref
47 \foottopagenote
48 \renewcommand*{\printpageinnotes}[1]{%
49 (p.\pageref{#1})\space}
50 \renewcommand\printpageinnoteshyperref[1]{%
51 (p.\pageref*{#1})\space}
52 \renewcommand*{\pagenotesubhead}[3]{%
53 \subsubsection*{#1: #3}}
54 \tightlists
55 \chapterstyle{bringhurst}
56 \pagestyle{empty}
57 \aliaspagestyle{chapter}{empty}
58 \settocdepth{subsection}
59 \setsecnumdepth{none}
60 \newcommand{\bpara}[1]{\par\vspace{\beforeparaskip}\noindent\textbf{#1}\,}
61 \newcommand{\rpara}[1]{\par\noindent\textbf{#1}\,}
62 \newcommand{\dark}[1]{\texttt\textbf{{#1}}}
63 \newcommand{\sfit}[1]{\textit{#1}}
64 \newcommand{\git}{\sfit{git}}
65 \newcommand*{\emailat}{@}
66 \newcommand{\opname}{\sfit{gitinfo}}
67 \newcommand{\tpname}{\sfit{gitinfo2}}
68 \newcommand{\tpfname}{\textsf{gitinfo2.sty}}
69 \newcommand{\ginname}{gitHeadInfo.gin}
70 \newcommand{\locname}{\texttt{gitHeadLocal.gin}}
71 \newcommand{\metaname}{\texttt{\ginname}}
72 \newcommand{\metapath}{\texttt{.git/\ginname}}
73 % -----------------------------------------------------
74 \usepackage[%
75 bookmarksnumbered,
76 bookmarksopen,
77 linktocpage,
78 ]{hyperref}
79 \hypersetup{
80 pdfauthor={Brent Longborough},
81 pdftitle={The gitinfo2 package: git metadata for LaTeX},
82 pdfkeywords={git;metadata;dvcs},
83 }
84 \begin{document}
85 \frontmatter
86 % -----------------------------------------------------
87 \title{%
88 ~\\[2\baselineskip]
89 \Huge \tpfname\\[2ex]%
90 \Large A package for accessing metadata\\from the \git\ \textsc{dvcs}
91 }
92 \author{Brent Longborough}
93 \date{\DTMenglishmonthname{\DTMfetchmonth{gitdate}} \DTMfetchyear{gitdate}}
94 \maketitle
95
96 {\centering
97 Release:\gitReln\ (\gitAbbrevHash)\\
98 }
99 % -----------------------------------------------------
100 \thispagestyle{empty}
101 \aliaspagestyle{chapter}{plain}
102 \clearforchapter
103 \tableofcontents*
104 % -----------------------------------------------------
105 \mainmatter
106 \pagestyle{giruled}
107 \aliaspagestyle{chapter}{giplain}
108 \chapter{Introduction}
109 More and more, writers are using version control systems
110 to manage the progress of their works.
111 One popular distributed version control system commonly used today
112 is \git.
113
114 Among other blessings, \git provides
115 some useful metadata concerning the history of the developers'
116 work, and, in particular, about the current state of that work.
117
118 \tpname\ allows writers to incorporate some of this metadata
119 into their documents, to show from which point in their development
120 a given formatted copy was produced.
121
122 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
123 \section{How \tpname\ works}
124 \begin{enumerate}
125 \item Whenever you commit work or check out a branch in \git,
126 \git\ executes a \textit{post-commit} or \textit{post-checkout hook}.
127
128 \item The \tpname\ package includes a sample hook
129 (placed in your \git\ hooks directory),
130 which extracts metadata from \git\ and writes it to a \TeX\ file,
131 named \metaname\ (`gin' for \textbf{g}it \textbf{in}fo).
132
133 \item When you format your document, \tpname\ reads
134 \metaname\ and stores the metadada
135 in a series of \LaTeX\ commands.
136
137 \item You may use these commands to insert
138 the metadata you need at any point in the document.
139 \end{enumerate}
140
141 It is important to note that \tpname\ reads the metadata
142 with the equivalent of \texttt{\textbackslash input\{\metapath\}}
143 in the repository (module or submodule) root.
144
145 Under some circumstances
146 (for example, when shipping something to \textsc{Ctan}),
147 a document will not be able to access the standard metadata.
148 In such a case, an option is available to read the metadata
149 from a \emph{manual} copy in the current directory,
150 called \locname.
151
152 If you actually want to use \tpname, then please read on.
153 But you may just be reading this to see whether it will be useful;
154 in this case,
155 please skip the next chapter and go on to `\titleref{ch:using}'
156 on page \pageref*{ch:using}.
157 Then, if you like what you see, come back to
158 read `\titleref{ch:setup}' later.
159
160 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
161 \clearpage
162 \section{Why a new package?}
163
164 The improvements to \opname\ version~2 mean that
165 existing repositories would not work;
166 so if I just dumped a new version of \opname\
167 on to CTAN, anyone who updated \opname\
168 would need to migrate all their active repositories
169 before they could resume work.
170
171 So in order to avoid the rebukes that would follow,
172 I have changed the package name to \tpname,
173 and the inner package name from \sfit{gitsetinfo}
174 to \sfit{gitexinfo}.
175
176 \opname\ is now informally deprecated,
177 and the first reply to any bug reports or feature requests
178 will be `try \tpname'.
179 Of course, I will support \tpname\ itself
180 to the best of my somewhat limited ability.
181
182 For obvious reasons, \emph{do not try}
183 to use both packages in the same repository;
184 for a new repository, use \tpname,
185 and for an old one, either leave it alone with \opname,
186 or migrate it to \tpname.
187
188 To the administrators of CTAN,
189 I'm sorry I caused you this clutter
190 by not getting it right the first time.
191
192 % -----------------------------------------------------
193 \chapter{Setup and tailoring}
194 \label{ch:setup}
195
196 \tpname\ will be installed by your favourite package or distribution manager,
197 but before you can start to use it,
198 you need to configure each of your \git\ working copies
199 by setting up hooks to capture the metadata.
200
201 If you're familiar with tweaking \git, you can probably work it out for yourself.
202 If not, I suggest you follow these steps:
203
204 \begin{enumerate}
205
206 \item First, you need a \git\ repository and working tree.
207 For this example, let's suppose that the root of the working tree is in
208 \texttt{\textasciitilde/compsci}
209
210 \item Copy the file \texttt{post-xxx-sample.txt}
211 (which is in the same folder of your \TeX{} distribution as this pdf)
212 into the \git\ hooks directory in your working copy.
213 In our example case, you should end up with a file called
214 \texttt{\textasciitilde/compsci/.git/hooks/post-checkout}
215
216 \item If you're using a unix-like system,
217 don't forget to make the file executable.
218 Just how you do this is outside the scope of this manual,
219 but one possible way is with commands such as this:
220
221 \begin{verbatim}
222 chmod g+x post-checkout.
223 \end{verbatim}
224
225 \item Test your setup with ``git checkout master''
226 (or another suitable branch name).
227 This should generate copies of \metaname\ in the directories
228 you intended.
229
230 \item Now make two more copies of this file in the same directory (\texttt{hooks}), calling them
231 \texttt{post-commit} and \texttt{post-merge}, and you're done.
232 As before, users of unix-like systems should ensure these files are marked as executable.
233 \end{enumerate}
234
235 If you don't want to install \tpname\ using a package manager,
236 you can instead just copy the two *.sty files into your document directory.
237 However, it may be simpler, for more complex project trees,
238 to install the package as part of your \TeX\ distribution.
239
240 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
241 \section{Migrating from version 1}
242
243 Version~2 of \tpname\ simplifies setup and brings additional convenience.
244 But this comes at a cost:
245 existing repositories need to be upgraded to be compatible.
246 This decision wasn't taken lightly; I really do think the incompatible changes
247 will give us a much firmer base for the future.
248 The changes needed, which should be applied to every repository, follow.
249
250 \bpara{Update \git\ hooks.}
251 Replace the hooks (\texttt{post-checkout}, \texttt{post-commit},
252 and \texttt{post-merge}) with the contents of the file \texttt{post-xxx-sample.txt}.
253 Since \tpname\ now uses only a single \metaname\ file for the whole repository,
254 you do \emph{not} need to tailor these hooks to map your document folders.
255
256 If you are fortunate enough to be using a unix-like system,
257 don't forget to ensure the hooks are executable.
258
259 \bpara{Recreate the new \metaname\ file.}
260 After you've replaced the hooks, the simplest way is to re-check-out the current branch,
261 using a command such as \verb!git checkout!.
262
263 \bpara{Delete the old \metaname\ files,}
264 when you're ready.
265
266 \bpara{If you're a \sfit{memoir} user,}
267 and you use the \texttt{footinfo} package option,
268 you will need to adjust your page styles.
269
270 From \tpname\ version~2, we no longer override the standard \sfit{memoir}
271 page styles.
272 Instead, \tpname\ provides three new page styles:
273 \sfit{giplain}, \sfit{giruled}, and \sfit{giheadings},
274 which you should now use to provide \tpname-tailored pages.
275
276 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
277 \section{Tailoring release tags}
278
279 As shipped, the \git\ hook code uses a certain convention
280 for identifying `release' tags:
281 the tag must begin with a numeric digit, and contain at least one decimal
282 point.\footnote{I.e. full stop or period, depending on which variant of English you use.}
283
284 Here is the line in the hook where this convention is established:
285
286 \begin{quotation}
287 {\ttfamily
288 RELTAG=\$(git describe \textellipsis\ --match '[0-9]*.*' \textellipsis)
289 }
290 \end{quotation}
291
292 By changing the \texttt{--match} parameter, you can decide exactly which tags
293 qualify as `release' tags for your needs. Thus
294
295 \begin{quotation}
296 {\ttfamily
297 RELTAG=\$(git describe \textellipsis\ --match 'R.*' \textellipsis)
298 }
299 \end{quotation}
300 would allow you to find tags like `R.2.0.1' and `R.L.Stevenson',
301 or
302
303 \begin{quotation}
304 {\ttfamily
305 RELTAG=\$(git describe \textellipsis\ --match '*' \textellipsis)
306 }
307 \end{quotation}
308 would allow you to find any tag whatsoever.
309
310 You can change the hooks without needing to alter \tpname,
311 since any tag found is used `as-is'.
312
313 \emph{Important note:} The \texttt{--match} parameter is a unix glob,
314 \emph{not} a regular expression. This has tripped up a number of users.
315
316 % -----------------------------------------------------
317 \chapter{Using the package}
318 \label{ch:using}
319 Once you've set up your \git hooks, and done your first commit,
320 merge, or checkout to drive them,
321 you can start incorporating the metadata into your document,
322 by loading the \tpname\ package in the usual way:\\[0.5\baselineskip]
323 \texttt{\textbackslash usepackage[$<options>$]\{gitinfo2\}}
324
325 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
326 \section{Package options}
327
328 The following options are available:
329
330 \subsection{General options}
331
332 \begin{description}
333
334 \item[local]
335 By default, \tpname\ normally reads \metapath\ (the metadata file).
336 If, however, the document needs to be shipped outside of its own repository,
337 this file will not be found.
338 Under these circumstances, the {\ttfamily local} option may be used.
339 This option causes \tpname\ to search
340 instead for \locname\ in the current directory \emph{only.}
341 Creating this file
342 (normally by copying from \metapath) is your responsibility.
343
344 \item[grumpy]
345 In those cases where \tpname\ is unable to find the metadata file
346 (\metapath{}, or \locname\ if the {\ttfamily\bfseries local} option is used),
347 it will set all the metadata to a common value, ``(None)'',
348 issue a package warning, and carry on.
349 If the \texttt{grumpy} option is used,
350 this warning becomes an error, and processing stops.
351
352 \item[\texttt{missing=\textit{text}, notags=\textit{text}, dirty=\textit{text}}]
353 These three options allow you to tailor the default text used by \tpname\ when
354 metadata is missing `(None)',
355 the branch head has no tags `(None)',
356 and the working copy has uncommitted changes `(*)'.
357 For example:
358
359 \begin{quote}
360 {\ttfamily
361 [missing=Help!,notags=\{No\,tags?\},dirty=Eww!]
362 }
363 \end{quote}
364 If you have complex needs, as in the second example,
365 don't forget to enclose your text in \{\}s.
366
367 \item[\texttt{maxdepth=\textit{n}}]
368 In order to locate \metapath\ in the repository root,
369 \tpname\ starts in the directory containing the master document,
370 and searches up the directory tree until it finds it.
371 This search is limited to {\ttfamily\itshape n} levels --- 4 by default.
372 If have to deal with documents
373 deeper in your repository tree, you can extend this limit with, say,
374 {\ttfamily maxdepth=8}.
375
376 \end{description}
377 \clearpage
378 \subsection{Options for watermarking}
379
380 These options allow you to place a watermark of \git\ metadata,
381 at the bottom of the paper, conditionally or unconditionally
382
383 \begin{description}
384
385 \item[mark]
386 This option causes \tpname\ to generate a watermark,
387 centred at the bottom of each sheet,
388 containing `useful' \git\ metadata.
389 The watermark is always added.
390
391 \item[markifdraft]
392 This option is like {\ttfamily\bfseries mark,}
393 but only activates the watermark if the document is being processed
394 with the {\ttfamily\bfseries draft} option.
395
396 \item[markifdirty]
397 This option is like {\ttfamily\bfseries mark,}
398 but only activates the watermark if the last commit or checkout left
399 uncommitted changes in the repository.
400
401 \item[marknotags]
402 If \tpname\ can't find any tags in the \git\ references,
403 it suppresses the second line of the watermark.
404 If, however, you would like the second line always to appear,
405 add this option to the package options.
406
407 \item[raisemark=\textit{vertical space}]
408 By default, \tpname\ sets the bottom line of the watermark
409 at 1.5 baseline
410 skips\footnote{\texttt{1.5\textbackslash{}baselineskip},
411 an admittedly arbitrary value, chosen for my Canon printer.}
412 above the bottom of the paper.
413 If you prefer something different,
414 you can specify it here.
415 For example:
416
417 \begin{quote}
418 {\ttfamily
419 [raisemark=0.95\textbackslash{}paperheight]
420 }
421 \end{quote}
422
423
424 \item[draft]
425 This option \emph{should not be used;} it only exists to `capture' the
426 {\ttfamily\bfseries draft} option from the document class definition.
427
428 \end{description}
429
430 \subsection{Options for \sfit{memoir} users}
431
432 For more about these options,
433 please read
434 %The use of these options is described in more detail in
435 `\titleref{sect:memuser}'
436 on page~\pageref*{sect:memuser}.
437
438 \begin{description}
439
440 \item[footinfo]
441 This option is no longer used, and if present is silently ignored.
442 For \sfit{memoir} users, \tpname\ now creates, automatically,
443 three new page styles.
444
445 \item[pcount]
446 For \sfit{memoir} users, this option will replace the folio
447 in the new page styles with one of the form \textit{x/y},
448 where \textit{x} is the folio and \textit{y} is the page count.
449
450 No warning is given, and no action taken,
451 if this parameter is used with another document class.
452
453 \end{description}
454 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
455 \clearpage
456 \section{The metadata}
457 The \git\ metadata, for the current HEAD commit,
458 is made available in the document
459 as a series of parameter-less \LaTeX commands.
460 Here they are:
461
462 \begin{description}
463
464 \item[gitReferences]
465 A list of any \git\ references (tags, branches) associated
466 with this commit.
467 This string is not for the faint-hearted;
468 its format and order may vary between versions of \git.\\
469 Example:\\\textit{\small\gitReferences}
470
471 \item[gitBranch]
472 The name of the current branch.
473 Depending on how you use \git,\footnote{For example, checking out unnamed branches}
474 this information may not be available,
475 and will then be shown as the default or specified value of
476 the \texttt{missing} package option.
477 For \git{} versions before 2.0.0, where the current HEAD commit refers
478 to more than one branch head, this value may be different from the
479 currectly checked-out branch.\\
480 Example: \textit{\gitBranch}
481
482 \item[gitDirty]
483 If the last commit or checkout left uncommitted changes in the working tree,
484 the default or specified value of the \texttt{dirty} package option;
485 otherwise empty.
486
487 \item[gitAbbrevHash]
488 The seven-hex-char abbreviated commit hash\\
489 Example: \textit{\gitAbbrevHash}
490
491 \item[gitHash]
492 The full 40-hex-character commit hash\\
493 Example: \textit{\gitHash}
494
495 \item[gitAuthorName]
496 The name of the author of this commit\\
497 Example: \textit{\gitAuthorName}
498
499 \item[gitAuthorEmail]
500 The email address of the author of this commit\\
501 Example: \textit{myemail\emailat evilspam.net}
502
503 \item[gitAuthorDate]
504 The date this change was committed by the author,
505 in the format \textit{yyyy-mm-dd}\\
506 Example: \textit{\gitAuthorDate}
507
508 \item[gitAuthorIsoDate]
509 The date and time this change was committed by the author,
510 in ISO format\\
511 Example: \textit{\gitAuthorIsoDate}
512 \clearpage
513 \item[gitAuthorUnixDate]
514 The date and time this change was committed by the author,
515 as a Unix timestamp\\
516 Example: \textit{\gitAuthorUnixDate}
517
518 \item[gitCommitterName]
519 The name of the committer of this commit\\
520 Example: \textit{\gitCommitterName}
521
522 \item[gitCommitterEmail]
523 The email address of the committer of this commit\\
524 Example: \textit{watcher\emailat gchq.gov.uk}
525
526 \item[gitCommitterDate]
527 The date this change was committed by the committer,
528 in the format \textit{yyyy-mm-dd}\\
529 Example: \textit{\gitCommitterDate}
530
531 \item[gitCommitterIsoDate]
532 The date and time this change was committed by the committer,
533 in ISO format\\
534 Example: \textit{\gitCommitterIsoDate}
535
536 \item[gitCommitterUnixDate]
537 The date and time this change was committed by the committer,
538 as a Unix timestamp\\
539 Example: \textit{\gitCommitterUnixDate}
540
541 \end{description}
542
543
544 \subsection{Additional metadata (Version 1)}
545
546 Three more commands are available, but their use should be considered
547 experimental. \tpname\ searches the \git\ references metadata for
548 anything (probably a \git\ tag) that looks like a number with a decimal point.
549 The first such number it finds is taken as a ``Version Number''
550 and made available in three different formats, explained here:
551
552 \begin{description}
553 \item[gitVtag]
554 The version number, without decorations. If no version number is found,
555 empty (i.e. zero width).
556 \item[gitVtags]
557 The version number, with a leading space. If no version number is found,
558 empty.
559 \item[gitVtagn]
560 The version number, with a leading space.
561 If no version number is found, a space,
562 followed by the default or specified value of
563 the \texttt{missing} package option.\\
564 Example: \textit{\gitVtagn}
565 \end{description}
566
567 These versioning tags have been superseded by release tags in Version 2,
568 although they should continue to work as before.
569
570 \subsection{Additional metadata (Version 2)}
571
572 From Version 2 onwards, additional \git\ metadata is available,
573 in general improving or extending the facilities available in Version 1.
574 The Version 1 metadata is retained for backward compatibility.
575
576 Included is a new set of \texttt{gitRel} commands,
577 designed to replace \texttt{gitVtag} and its cousins.
578 \tpname\ searches the \git\ metadata for tags
579 on the current \textsc{head} commit or its ancestors,
580 and makes the first tag found available.
581 It also looks for the latest such tag
582 whose name begins with a digit, and which contains a full stop (period),
583 and makes the tag, and the number of commits following it,
584 available as a `release number'.%
585 \footnote{\tpname\ doesn't check for numerics, so you can use a tag like `1.5-beta' if you wish.}
586 Here are the new commands in Version~2:
587
588 \begin{description}
589
590 \item[gitFirstTagDescribe]
591 The last tag reachable from the current \textsc{head}.
592 Please see git-describe for more information.
593 If the working copy is \textit{dirty} (has uncommitted changes),
594 the string has '-*' appended.\\
595 Example: \textit{\gitFirstTagDescribe}
596
597 \item[gitRel]
598 The release number, without any decorations.
599 If no release number is found, empty (i.e. zero width).
600
601 \item[gitRels]
602 The release number, with a leading space.
603 If no release number is found, empty.
604
605 \item[gitReln]
606 The release number, with a leading space.
607 If no release number is found, a space,
608 followed by the default or specified value of
609 the \texttt{missing} package option.
610
611 \item[gitRoff]
612 The number of commits between the current \textsc{head}
613 and the tag holding the release number.
614 If the tag refers to the current \textsc{head}, zero.
615
616 \item[gitTags]
617 A comma-separated list of tags associated with the current \textsc{head}.\\
618 Example: \textit{\gitTags}
619
620 \item[gitDescribe]
621 The raw output from the git-describe command for the last release tag
622 reachable from the current \textsc{head}, including tag name, commit offset,
623 short hash, and a dirty flag.
624 Please see git-describe for more information.
625 Example: \textit{\gitDescribe}
626
627 \end{description}
628
629 \clearpage
630 \subsection{Watermark tailoring commands}
631
632 If you use the Version 2 options to place a watermark,
633 you can tailor the format of the watermark to suit your needs,
634 by redefining one or more of the following commands.
635
636 \begin{description}
637
638 \item[gitMark]
639 Contains the text of the watermark.
640 Output from the default definition can be seen
641 below the footer
642 at the bottom of this page.
643 The definition
644 (here split onto four lines to fit)
645 is:
646
647 \begin{verbatim}
648 Branch: \gitBranch\,@\,\gitAbbrevHash{}
649 \textbullet{}
650 Release:\gitReln{} (\gitAuthorDate)\\
651 Head tags: \gitTags
652 \end{verbatim}
653 You can tailor this by redefining \verb!\gitMark!.
654 For example:
655
656 \begin{verbatim}
657 \renewcommand{\gitMark}{\gitHash\hfill\gitRel}
658 \end{verbatim}
659
660 \item[gitMarkFormat]
661 Defines typesetting parameters for the whole watermark.
662 The default definition is:
663
664 \begin{verbatim}
665 \color{gray}\small\sffamily
666 \end{verbatim}
667 if the \sfit{xcolor} package is loaded; if not, \verb!! is simply omitted.
668 You can tailor this by redefining \verb!\gitMarkFormat!. For example:
669
670 \begin{verbatim}
671 \renewcommand{\gitMarkFormat}{\color(red)\ttfamily}
672 \end{verbatim}
673
674 \item[gitMarkPref]
675 Contains the text of the watermark prefix,
676 which depends on the reason the document is being watermarked.
677 The default values are \sfit{[Dirty]}, \sfit{[Draft]}, or \sfit{[git]}.
678 You can tailor this by redefining \verb!\gitMarkPref!. For example:
679
680 \begin{verbatim}
681 \renewcommand{\gitMarkPref}{[Pending review]}
682 \end{verbatim}
683
684 \end{description}
685
686 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
687 \clearpage
688 \section{Handling \TeX-hostile e-mail addresses}
689 \label{sect:emailuser}
690 Occasionally, a repository will contain `\TeX-hostile'
691 e-mail addresses such as \[email protected]!.
692 As a result, using the \dark{gitAuthorEmail}
693 or \dark{gitCommitterEmail} commands can cause errors.
694
695 \tpname\ provides an e-mail wrapping command,
696 \verb!\gitWrapEmail!, to allow you to tailor your use
697 of email addresses. Its default definition does nothing:
698 \begin{verbatim}
699 \newcommand{\gitWrapEmail}[1]{#1}
700 \end{verbatim}
701 You can tailor this by redefining \verb!\gitWrapEmail!.
702 For example, a number of packages
703 (\sfit{hyperref} is one) provide a \verb!\url! command
704 which provides the necessary protection.
705 Using such a package (independently of \tpname),
706 you can redefine the \tpname\ wrapper in this way:
707 \begin{verbatim}
708 \renewcommand{\gitWrapEmail}[1]{\url{#1}}
709 \end{verbatim}
710
711 Please note that from Release 2.0.6 this precaution is optional,
712 since \tpname\ now detokenises Author and Committer names and email addresses,
713 and all \git\ reference names.
714
715 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
716 \section{For \sfit{memoir} users}
717 \label{sect:memuser}
718 If you use \sfit{memoir}, \tpname\ provides you with
719 three new pagestyles, based on
720 \sfit{plain}, \sfit{ruled}, and \sfit{headings}.
721 The new pagestyles are called
722 \sfit{giplain}, \sfit{giruled}, and \sfit{giheadings}.
723
724 For the \sfit{giplain} and \sfit{giruled} pagestyles,
725 the folio is moved from the centre to the outer margin of the footer,
726 and a revision stamp is placed in the inner margin.
727
728 For the \sfit{giheadings} pagestyle,
729 the folio is moved from the outer margin of the header
730 to the outer margin of the footer,
731 and a revision stamp is placed in the inner margin of the footer.
732
733 If you use the \texttt{pcount} option, a solidus, and the page count,
734 are appended to the folio.
735
736 The revision stamp is generated by this fragment:
737
738 \begin{verbatim}
739 Release\gitRels: \gitAbbrevHash{} (\gitAuthorDate)
740 \end{verbatim}
741 \noindent
742 which is set at tiny in the sans-serif font.
743
744 Note that, in contrast to version 1 of \tpname,
745 version 2 no longer modifies the existing page styles.
746 If you wish to use this facility,
747 you must now select
748 the appropriate \sfit{gi\textellipsis} page style
749 explicitly.
750
751 You can see an example in the footer of this page,
752 above the \tpname\ watermark.
753
754 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
755 \section{For \sfit{datetime2} users}
756 \label{sect:dtuser}
757 If you use Nicola Talbot's excellent \sfit{datetime2} package,
758 \tpname\ copies the value of the tag {\ttfamily\bfseries gitAuthorDate}
759 as a new date object named \sfit{gitdate},
760 which you can then refer to with other \sfit{datetime2}
761 functions.
762
763 Please refer to the \sfit{datetime2} manual for
764 further details,
765 especially in the section entitled `Saving Dates'.
766
767 If you use it, you must load \sfit{datetime2}
768 before you load \tpname.
769
770 The \sfit{datetime} package is also supported,
771 though deprecated.
772
773 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
774 \section{Notes on the sequence of events}
775 \label{sect:seqeve}
776 Users of \tpname\ (including me) are frequently surprised
777 by what appear to be incorrect results in their output,%
778 \footnote{Most frequent are `wrong tag' and `falsely flagged as dirty'}
779 but are determined in fact by the precise sequence of operations
780 on a working copy.
781
782 As it's impossible to foresee every possible workflow,
783 what follows is a sequence of steps of a simple workflow
784 which will serve as an example to help users
785 to understand what is happening, and to avoid it.
786
787 The example repository manages two main files:
788 \sfit{abc.tex} and its output file, \sfit{abc.pdf}.%
789 \footnote{Although derived files are often excluded from version control,
790 the .pdf file in this case might need to be archived ---
791 think of versions of a proposal, for example.}
792 Intuitively, the overall sequence of one update \& release cycle
793 might be like this:
794
795 \begin{enumerate}
796 \item Edit \sfit{abc.tex}, (perhaps) commit intermediate changes,
797 format the output into \sfit{abc.pdf}, and
798 check and repeat until ready for release;
799 \item \label{wf:tex} Commit the release version of \sfit{abc.tex};
800 \item \label{wf:tag} Tag the release;
801 \item \label{wf:git} (Missing step);
802 \item \label{wf:pdf} Format the release version of \sfit{abc.pdf}; and
803 \item Commit the release version of \sfit{abc.pdf}.
804 \end{enumerate}
805
806 \noindent For reasons that I hope will become obvious,
807 that doesn't work.
808 The \git\ metadata is extracted and stored at step (\ref{wf:tex}).
809 At that point, the release tag doesn't yet exist,
810 and the working copy is dirty,
811 since \sfit{abc.pdf} has been regenerated, and has changed
812 since the last recorded version.
813
814 It's simple to fix; all we have to do is
815 ensure the working copy is clean and regenerate
816 the saved metadata (now with correct tag information).
817 Here's the missing step, kept, perhaps, somewhere in a \sfit{makefile:}
818
819 \begin{enumerate}
820 \item[\ref{wf:git}.] \texttt{git checkout abc.pdf}
821 \end{enumerate}
822
823 \noindent This will revert the .pdf file to its repository version,
824 and then regenerate the stored metadata,
825 including the release tag.
826 Step (\ref{wf:pdf}) will now produce output showing the release tag
827 and a clean working copy.
828 % -----------------------------------------------------
829 \chapter{Etc}
830 \section{Release notes}
831
832 \rpara{R2.0.7: 2015-11-22 -- Allow metadata to be shipped}
833 \begin{itemize}
834 \item
835 Allow metadata to be read
836 from \texttt{\locname} in the current directory,
837 rather than from \metapath,
838 via the \texttt{local} package option.
839 \end{itemize}
840
841 \rpara{R2.0.6: 2015-11-14 -- Detokenise the metadata}
842 \begin{itemize}
843 \item Detokenise names, emails, branches, and tags.
844 This means you should be able to use branch names like \verb!yes@top_dol$lar! without
845 \TeX\ chewing you out.
846 I'd welcome feedback on this,
847 as I have an uneasy feeling there may be unintended consequences.
848 \end{itemize}
849
850 \rpara{R2.0.5: 2015-11-09 -- Bug fixes and general improvements}
851 \begin{itemize}
852 \item Support for the \sfit{datetime2} package
853 \item Provide correct committer metadata in hook sample
854 \item Change Warning to Info when \sfit{gitHeadinfo.gin} is found
855 \item Move all package dependencies from \sfit{gitexinfo.sty} to \sfit{gitinfo2.sty}
856 \item Support for \git{} Version 2 log output, with more accurate branch name analysis
857 \item Only use colours if the \sfit{xcolor} package is loaded
858 \end{itemize}
859
860 \rpara{R2.0.4: 2014-10-03 -- Fixes and documentation improvements}
861 \begin{itemize}
862 \item More robust \git\ hooks,
863 for improved detection of dirty working copies
864 \item A new section, \textit{\titleref{sect:seqeve}},
865 to help with doing things in the right order
866 \item Other minor improvements to the manual
867 \end{itemize}
868
869 \rpara{R2.0.3: 2014-09-05 -- Handle hostile e-mail addresses}
870 \begin{itemize}
871 \item Provide an e-mail address wrapper command,
872 to allow users to tailor protection
873 against `\_' and other characters in email addresses.
874 \item This release was not shipped to \textsc{Ctan}
875 \end{itemize}
876
877 \rpara{R2.0.2: 2014-09-04 -- Mostly cosmetic}
878 \begin{itemize}
879 \item Fix packaging problems for \textsc{Ctan} and \TeX{}~Live
880 \item Improve appearance of watermark
881 \item Improve documentation: correct file references. remove gibberish, extend acknowledgments
882 \end{itemize}
883
884 \clearpage
885 \section{Acknowledgements}
886
887 The \href{http://tex.stackexchange.com}{\TeX.SE community}
888 has been a constant source of help, inspiration, and amazement.
889 In particular, I'd like to thank
890 \href{http://tex.stackexchange.com/users/73/joseph-wright}{Joseph Wright},
891 who rescued me from the jaws of the TeX parser by explaining
892 \textbackslash expandafter.
893
894 I'd also like to register my thanks to the owners of the packages on which
895 \tpname\ depends: datetime2, eso-pic, etoolbox, kvoptions, and xstring.
896
897 Many people have written to me kindly
898 to point out some of the defects in \opname, and to offer code.
899 I owe you all an apology for the amount of time that elapsed
900 from your suggestions to the making of \tpname.
901
902 In some cases, I have not taken up suggestions other than as food for thought,
903 in others used the code or suggestions directly, and,
904 in yet others, adapted.
905 I thank you all, especially for stimulating my thought processes,
906 and thus, hopefully,
907 helping to make \tpname\ a whole lot better than \opname.
908
909 I think I owe a special mention, both for ideas and code,
910 to Clea Rees, Jörg Weber, and Kai Mindermann
911 for improving the handling of \git\ references;
912 to Jörg Weber for watermarking;
913 to Michael Rans and Ross Vandegrift for
914 the deduplication of \metaname;
915 and to \sfit{ivokabadshow} on GitHub
916 for a welcome example of how to detokenise the metadata.
917
918 My sincere thanks, too, to
919 Adrian Burd,
920 cedb12 (GitHub),
921 Maximilian Held,
922 Johannes Hoetzer,
923 Mikko Korpela,
924 Martin W Leidig,
925 Enrico Malizia,
926 Ken Mankoff,
927 Ryan Matlock,
928 Robbie Morrison,
929 Nik (gwdg nokta de),
930 Omid (gmail nokta com),
931 Sasaki~Suguru,
932 Tor\-bjørn~T (GitHub and TeX.SE),
933 and
934 Felix Wenger.
935
936 Special thanks to Karl Berry for helping me to
937 reduce my incompetence with \texttt{ctanify}.
938 And, of course, for \TeX{} Live and everything else.
939
940 Finally, but by no means least,
941 my thanks to the \textsc{Ctan} elves, and their dæmons,
942 particularly, in my case,
943 Ina Dau,
944 Manfred Lotz,
945 Petra Rübe-Pugliese,
946 and
947 Robin Fairbairns,
948 for their infinite patience and unstinting
949 dedication to the \TeX\ community.
950
951 The failings, of course, I claim for myself.
952
953 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
954 \clearpage
955 \section{Copyright \& licence}
956 Copyright \copyright\ \DTMfetchyear{gitdate}, Brent Longborough,
957 who has asserted his moral right
958 to be identified as the author of this work.
959
960 This work --- \tpname\ --- may be distributed and/or modified under the
961 conditions of the LaTeX Project Public License: either version 1.3
962 of this license, or (at your option) any later version.
963
964 The latest version of this license can be found
965 at the \LaTeX\ Project website,%
966 \footnote{(\url{http://www.latex-project.org/lppl.txt})}
967 and version 1.3 or later is part of all recent distributions of
968 \LaTeX.
969
970 This work has the LPPL maintenance status `maintained';
971 the Current Maintainer of this work is Brent Longborough.
972
973 This work consists of the files
974 gitinfo2.sty, gitexinfo.sty, gitinfo2.tex, gitinfo2.pdf,
975 gitinfotest.tex, post-xxx-sample.txt,
976 and gitHeadLocal.gin.
977
978 % - - - - - - - - - - - - - - - - - - - - - - - - - - -
979 \section{From the author}
980 Although my limitations as a \TeX nician
981 mean that I've implemented \tpname\ in a rather simplistic way
982 that needs some setup that is more complicated than I wanted,
983 I hope you find the package useful.
984 I'll be very happy to receive your comments by email.\\[\baselineskip]
985 Brent Longborough\\[\baselineskip]
986 \textsf{brent+ctancontrib (bei) longborough (punkt) org}\\
987 and at \href{http://tex.stackexchange.com/users/344/brent-longborough}{\TeX.SE}
988 % -----------------------------------------------------
989 \clearpage
990 \raggedright
991 \printpagenotes
992 \end{document}