+Due to, among other things, the cvs->git synchronization lag it is
+easy to get conflicts on version.lisp-expr so generally speaking you
+never want to edit version-lisp.expr in Git, and only edit it (and add
+the version to the commit message) just when you are about to commit
+to CVS. It is, however, nice to have an idea how a given image came to
+be, which you can take care of by putting the following code in
+branch-version.lisp-expr:
+
+ #.(flet ((git (command &rest args)
+ (with-output-to-string (s)
+ ;; Adjust for your git installation location...
+ (sb-ext:run-program (merge-pathnames "bin/git" (user-homedir-pathname))
+ (cons command args) :output s))))
+ (format nil "~A.~A~@[-dirty~]"
+ (with-input-from-string (s (git "branch"))
+ (loop for line = (read-line s)
+ when (eql #\* (char line 0))
+ return (subseq line 2)))
+ (count #\newline (git "rev-list" "HEAD...master"))
+ (plusp (length (git "diff" "HEAD")))))
+
+which leads to your Git tree build to have version names like
+
+ 1.0.20.28.master.0-dirty
+
+ 1.0.20.28 on branch master, uncommitted changes
+
+ 1.0.20.19.wip-foo.4
+
+ 1.0.20.19 on branch wip-foo, 4 commits between current HEAD and
+ master, no uncommitted changes.
+