git saga

It seemed like a simple thing to do: install git on OS X.

The issue, of course, is ONL (OS X is not Linux), and git is a Linux application for version control. (The immediate motivation for getting git was that I should put my website under version control so I can have a history of changes,and I wanted to compare git to subversion/cvs/rcs.)

Getting the source code for git is straightforward, and I downloaded git-1.6.1.tar.gz, unzipped it, ran configure, built it, and ran "make test." Some of the tests failed (some seemed to be known errors, but it stopped when 3/5 errors in the 2300 series failed; they had to do with cd operations of some sort). Undaunted, I did a sudo make install and was able to run the git exectutable. But I needed the documentation (just a man page would be nice), and that's where it all got messy.

(Aside: somewhere in here I needed libintl for internationalization, which it got by downloading and installing gettext-0.17.tar.gz.)

To make the git documentation, I needed xmlto. I downloaded and built xmlto-0.0.21, only to find that it would not configure without a version of getopt(1) that supports long options, which the OS x version does not.

But getopt-1.1.4 would not build. I thought I should play it safe and use the version of getopt(3) that came in the gnu subdirectory, and did not like all the warnings I got. I got rid of those by adding a #include <string.h> to the C code. But linking getopt(1) remained a problem. Finally, I made the following changes to the Makefile: Added CFLAGS as well as LDFLAGS to the build rule for the command; changed the empty definition of LDFLAGS to -lintl -lgettextsrc. Got these by experimentation: I still do not know the difference between libgettextsrc and libgettextpo. (The latter is documented in the GNU GetText Manual; PO stands for “portable object”; libgettextsrc seems to be used by the gettextize program.)

So, with a working getopt(1) and a working xmlto I’m good to go, right? Just do make doc in the git build directory and everything works, right? Right. Provided you like seeing:

rm -f git-add.1
xmlto -m callouts.xsl man git-add.xml
I don't know how to convert docbook into man.
make[1]: *** [git-add.1] Error 1

So I set out to get docbook support. In the process I found Justin Reagor’s instructions for installing git on OS X. He shows how to do everything listed here, plus instructions on using expat to set up docbook support for generating man pages. And he has a later blog entry that does the complete git install on Leopard using just expat, git, and the man pages for git as a separate download directly from

I had a couple of issues with Justin’s docbook instructions. The first was that cut and paste for commands that used -- for options got converted to an html entity code for the first dash and had to be corrected by hand. The second was that the version of docbook-xsl that I downloaded (docbook-xsl-1.74.0) had INSTALL instructions that said to move the tarball into a permanent directory without saying where that should be, and it had a script that wanted to be run as non-root. But I followed Justin’s directions and un-tarred the file into /usr/local/share/docbook/xsl/ as root (and had to do chown -R root:wheel docbook-xsl-1.74.0 to fix up the permissions); then I had to do the install as root (which seemed to work fine) because doing it as non-root tried to write setup info into the root-owned directory under /usr/local instead of in my own .bashrc.

So now I can do man git! (And I have all those great documentation tools ready to roll.)

Thanks Justin!