Present Perfect


Picture Gallery
Present Perfect

git bash prompt

Filed under: General — Thomas @ 20:39


I've been having fun recently on a new project where I put myself through all sorts of pain by nesting git submodules into team submodules into platform submodules and so on. The goal here is to be able to tag a root repository and thus identify exact commit hashes of all the submodules to any level. This was an idea Andoni had when he was working on livetranscoding in response to a request of mine where I want to be able to use a single 'tag' to identify a complete deployment.

That's been working better than I expected, and I even hacked git-submodule-tools so that I can do git rlog and get a recursive git log between two root version tags, and get a list of every commit between the master and all submodules. That's pretty neat for writing out release notes.

However, the way I embedded submodules causes a bit of pain when going back and forth. One of my hackers once gave me a PS1 bash prompt that includes info of which git branch you're on in your shell prompt. So today I decided to extend that a little, and I now have this:

(b:release-0.2.x d:deploy-pro-2012-03-29) [thomas@otto platform]$ ls
Makefile platform puppet RELEASE-0.2.1
(b:release-0.2.x d:deploy-pro-2012-03-29) [thomas@otto platform]$ cd puppet/pro/
(s:puppet/pro b:release-0.2.x d:v0.2.1) [thomas@otto pro]$

This is showing me submodule name, branch, and description of the current commit.

If you want this for your prompting fun too, here's the github repo

In the near future, simple portknocking for fun and profit with bash!


  1. Hi,

    I’m really interested in this recursive log and your hacks on git-submodules-tools, did you push that also to github or somewhere else? I’m working with a lot of submodules (actually I use mr.developer[1]) but it’s a bit of a pain. Mostly for trying to create branches on some submodules and everything.

    Cool script for the PS1 btw!


    [1] pypi.python.org/pypi/mr.developer

    Comment by Gil Forcada — 2012-03-30 @ 13:06

  2. Here you go: https://github.com/thomasvs/git-submodule-tools/commit/2e78fd820efe29e331f1be9bfc4910a4e4fc20c9

    Comment by Thomas — 2012-04-01 @ 18:45

RSS feed for comments on this post. TrackBack URL

Leave a comment