defunkt/hub — pull request #221 by paddymul (2012-07-23 12:41:14+00:00)
Title: Submodule checkout

I am trying to write some utilities that make working with git submodules easier. I'm not an experienced ruby programmer, so this code is far from idiomatic.

When working with git submodules there are frequent annoyances that I run into, these include

1. pushing the parent repo that points at a commit from the child submodule that hasn't been pushed to the child's repo. This will result in your teammates not being able to pull and run your code.
2. changing branches, or doing a pull and forgetting to update the submodules
3. any git submodule commands require your pwd to be the repo root

To fix #1, I modified `hub push` to check if all the submodule child commits are pushed to the child "origin" remotes, if they haven't been, `hub push` exits early

I can't quite fix #2, I have a `hub submodule_update` command that works, but I can't make this command automatically run after every `hub checkout` because I don't know how to hook in after the real git command has run.

I think if I can get the above commands working properly, it will save a lot of the annoyances and chances for git submodules to get screwed up in the first place. The changes to `hub push` are probably less controversial than the changes to `hub checkout`

There are a couple of other submodule commands that I want to add (like having submodules track not only the commit, but also the branch of the submodule repo, this would enable a repo parent to push submodules also) and some better submodule diff commands.