William's miscellaneous git tools

Here are a bunch of git-related tools I've found useful at some point. The git repository for all of these is cloneable at git://gitorious.org/willgit/mainline.git/ (browse).

git-wtf

git-wtf is my primary tool for working with feature branches since I've been trying to wean myself off of gitk. If you're on a feature branch, it tells you which version branches it's merged into. If you're on a version branch, it tells you which feature branches are merged in and which aren't. For every branch, if it's a tracking branch, it tells you which commits need to be pulled and which need to be pushed.

Use immediately after git fetch.

w@entry:~/devel/sup$ git wtf
Local branch: heads/next
  [x] in sync with remote
Remote branch: origin/next (git+ssh://wmorgan@repo.or.cz/srv/git/sup.git)
  [x] in sync with local
Feature branches:
  [x] non-ascii-message-id is merged in
  [ ] ncurses-widechar is NOT merged in (1 commit ahead; 83 commits behind)
    - tmp [9676c71] (wmorgan-sup@...; 8 weeks ago)
  [ ] join-threads-bugfix is NOT merged in (1 commit ahead; 181 commits behind)
    - tmp commit: debugging [a634c29] (wmorgan-sup@...; 5 months ago)
  [ ] imap-cache-headers is NOT merged in (1 commit ahead; 181 commits behind)
    - temp commit [753c924] (wmorgan-sup@...; 5 months ago)
  [x] maildir-speedup is merged in
  [ ] release-0.4 is NOT merged in (1 commit ahead; 248 commits behind)
    - switch bin and lib versions from git -> 0.4 [df2da07] (wmorgan-sup@...; 5 months ago)
  [ ] mbox-parse-fix is NOT merged in (4 commits ahead; 76 commits behind)
    - tmp [4df28ef] (wmorgan-sup@...; 9 weeks ago)
    - tmp [772db99] (wmorgan-sup@...; 9 weeks ago)
    - tmp [5c856a1] (wmorgan-sup@...; 9 weeks ago)
    - tmp [278ab13] (wmorgan-sup@...; 9 weeks ago)
  [ ] encoding-tweaking is NOT merged in (1 commit ahead; 81 commits behind)
    - tmp [19fdca3] (wmorgan-sup@...; 9 weeks ago)
  [x] release-0.5 is merged in
  [ ] local-changes-only is NOT merged in (1 commit ahead; 6 commits behind)
    - rakefile: use local ditz [089d363] (wmorgan-sup@...; 8 days ago)
  [ ] imap-share-connections is NOT merged in (1 commit ahead; 181 commits behind)
    - temp commit [f90a937] (wmorgan-sup@...; 5 months ago)
  [ ] todo-updates is NOT merged in (24 commits ahead; 286 commits behind)
    - checkpoint bugs.yaml [e9f83af] (wmorgan-sup@...; 3 months ago)
    - checkpoint bugs.yaml [05230e3] (wmorgan-sup@...; 3 months ago)
    - checkpoint bugs.yaml [0c18af1] (wmorgan-sup@...; 3 months ago)
    - checkpoint bugs.yaml [0e0d945] (wmorgan-sup@...; 4 months ago)
    - checkpoint bugs.yaml [7e47447] (wmorgan-sup@...; 4 months ago)
      ... and 19 more.
  [x] reply-from-hook is merged in
  [x] color is merged in
  [ ] ncursesw is NOT merged in (4 commits ahead; 84 commits behind)
    - add run-this-for-sup.sh [1fb0049] (wmorgan-sup@...; 9 weeks ago)
    - tweak extconf.rb to require ncursesw instead of ncurses [e2b6018] (wmorgan-sup@...; 9 weeks ago)
    - remove generated files [e93f329] (wmorgan-sup@...; 9 weeks ago)
    - initial import of gem directory [a523ddc] (wmorgan-sup@...; 9 weeks ago)
  [x] edit-as-new-fix is merged in
  [x] attachments is merged in
  [x] find-in-buffer-fix is merged in

git-show-merges

git-show-merges is a precursor to git-wtf. It's a simple tool that shows you which branches have been merged in to the current branch, and which haven't. That's it. You can also specify multiple non-topic branches (merge branches?) on the commandline.

w@entry:~/devel/sup$ git show-merges
merged into next:
  attachments
  color
  edit-as-new-fix
  find-in-buffer-fix
  maildir-speedup
  non-ascii-message-id
  release-0.5
  reply-from-hook

not merged into next: 
  encoding-tweaking
  imap-cache-headers
  imap-share-connections
  join-threads-bugfix
  local-changes-only
  master
  mbox-parse-fix
  ncurses-widechar
  ncursesw
  release-0.4
  todo-updates

git-publish-branch

git-publish-branch is a simple script to ease the unnecessarily complex task of "publishing" a branch, i.e., taking a local branch, creating a reference to it on a remote repo, and setting up the local branch to track the remote one, all in one go.

You give it a branch name, and that branch is published in your remote repository. That's it. If you use -d, it will delete the remote reference.

Useful if you publish your topic branches to the outside world.

git-rank-contributors

git-rank-contributors is a trivial script that paws through your logs and ranks all the contributors by the size of their diffs. As always, bigger is better!

If you use -v, you'll get the raw diff sizes.

If you use -o, you'll get high-tech email obfuscation.

Output with just -o may be suitable for piping into a CREDITS file. It probably will require some editing in case people submit from more than one email address, though.

git-walkthrough-add (deprecated)

In recent gits, git add -p does exactly what this tool does. So I will not be putting a lot of energy into maintaining this any more.

git-wt-add is a darcs-style interactive staging script for git. It walks you through unstaged changes on a hunk-by-hunk basis and allows you to pick the ones you'd like staged. It features colorized diff output and a full set of navigation and dispatch commands.

git-wt-add is based on git-hunk-commit --darcs, which was very close to what I wanted, but wasn't quite it. In general git-wt-add makes no attempt to conform to the real darcs interface, but it's probably pretty close.

Credit

This collection of vaguely useful tools is brought to you by William Morgan and the following contributors: