9

I think I do not understand the workflow of the gitinfo2 package correctly. The documentation says (shortend):

  1. Edit and format abc.tex until ready for release
  2. Commit the release version of abc.tex
  3. Tag the release
  4. checkout abc.pdf
  5. Format & commit the release version of abc.pdf

My question: How can the Git tag be aligned with the formatted PDF? The described workflow is showing two commits... When I am following it, the given tag in the commit history is "one behind". As consequence: when checking out the version where the tag is given, the PDF does not contain the tag.

I do not see different behaviour when using smartgit or commandline tool git.

Is this supposed to be? Can somebody help me?

Thank you,

Thomas

Edit: Added picture to specify my question.

As shown in the screenshot (graphical log view of Smartgit) the commit where the tag is given and the commit where the pdf was added - containing the right release info - are not identical. --> When checking out "Release 1.34" the PDF has not the right info. Only the following commit contains a correct set of data. The commit with the pdf containing the right Release info is not the same like the one where the tag was added.

Edit 2:

As current workaround I am moving the tag after the PDF commit as described in this post.

5
  • 1
    Welcome to the site! I've wondered this exact question before, and I'll be interested to know if it can be clarified, perhaps by the author
    – cmhughes
    Commented Jan 25, 2016 at 11:34
  • 1
    to the close voters: if you're voting to close, at the very least give a reason. this question, imho, seems perfectly ontopic (texdoc gitinfo2, for example)
    – cmhughes
    Commented Jan 25, 2016 at 11:35
  • naive question: if you only want to get a tag into your pdf, why don't you add the tag in your .tex source before the commit, then commit, then git tag ? this is bypassing gitinfo2 though which you may use for other things. And it also avoids control versioning the pdf, thus reducing the repo size.
    – user4686
    Commented Jan 27, 2016 at 8:50
  • addendum: I usually have a set-up where the release pdf's are archived separately in another repo dedicated to that task; in case some evolution of LaTeX or packages makes compiling sources either impossible, or buggy, or with differences in output. But the main dev repo will only version control the tex source.
    – user4686
    Commented Jan 27, 2016 at 8:55
  • Hi jfbu, the idea of an external place with the compiled pdf sounds interesting. That would avoid the described problem... Commented Jan 27, 2016 at 18:00

2 Answers 2

4

The main assumption is that abc.pdf is being tracked by git.

Here is a list of command line steps, that keeps the release number up to date (this assumes that abc.pdf has been committed at some point previously)

(start with clean repo, make changes to abc.tex and compile)

git add abc.tex
git commit -m "my commit message goes here"
git tag -a 1.34
git checkout abc.pdf
pdflatex  abc
git add abc.pdf
git commit -m "updated release number in pdf"

Here is the file I have used for abc.tex

\documentclass{article}
\usepackage[mark,grumpy]{gitinfo2}

% gitinfo2 settings
\renewcommand{\gitMark}{Release: \gitRel}

\begin{document}
hello world
\end{document}

One reason your release tag might not be as you intend could be because it isn't being picked up by

RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*

files. If your tag starts with anything other than a number, then you need to change the --match part accordingly. For example, if your tag starts with a V, as in V3.2.2, then you might use

RELTAG=$(git describe --tags --long --always --dirty='-*' --match 'V[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*
2
  • Thank you cmhughes for your answer. I think my question was not precise enough. I used your example to show my problem and edited the question. The hint with --match is important as well, though... Commented Jan 25, 2016 at 22:42
  • @ThomasMichel thanks for the update, now I understand the problem a little better. I'd be tempted to say that your question is really more of git issue, rather than a gitinfo2 issue. The release tag in the .gin file is only updated after a commit, merge, or checkout. As such, you need to perform one of these operations, and then recompile. One possible alternative to the method you've linked to in your question is to follow the method I've outlined, and then use git rebase -i to merge your last two commits together. I'm not sure what this would do to the tagging history,,,
    – cmhughes
    Commented Jan 26, 2016 at 10:02
2

Thanks for the support cmhughes!

I will wrap it up:

My question is a question related to git. gitinfo2 is supposed to work like this - that's fine for me.

Starting from here:

Starting point

we can

  • move the tag, as described in this post by doing

    git tag -fa 1.34

  • or merge the commits (rebase) as described in this post.

    git rebase -i HEAD~2

and than change in the upcoming dialog (looks something like this):

pick 2840179 Changing abc.tex
pick 00d844f Adding abc.pdf

# Rebase 8c99d54..00d844f onto 8c99d54
#
....

the second pick (pointing to the last commit) into a squash.

This ends up in a (maybe) more nice history. However, we have to retag afterwards as well with git tag -fa 1.34. Otherwise we loose the tag...:

enter image descripand than change the second and than change the second tion here

Thomas

2
  • Great work! In fact, you can do a combination of the two ideas: rebase to merge two commits, and then move the tag :) Perhaps you could update your answer to show this? While you're doing that, I think that it would be great to provide more details in your answer; for example, showing the git commands as I did in my post
    – cmhughes
    Commented Jan 27, 2016 at 9:30
  • Very nice, +1 from me :) you can use the green check mark to mark your answer as accepted
    – cmhughes
    Commented Jan 27, 2016 at 20:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .