series: Added -g option to start gitk
[guilt.git] / guilt-graph
blob5d67040881972d93851901c76c78b1e11c238dde
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 USAGE="[<patchname>]"
7 . guilt
9 if [ $# -gt 1 ]; then
10 usage
13 patchname="$1"
15 bottom=`head -1 < "$applied" | cut -d: -f1`
16 base=`git-rev-parse $bottom^`
18 if [ -z "$patchname" ]; then
19 top=`git-rev-parse HEAD`
20 else
21 top=`grep "^[0-9a-f]\{40\}:$patchname" "$applied" | cut -d: -f1`
22 if [ -z "$top" ]; then
23 die "Cannot find patch '$patchname'. Is it applied?"
27 function getfiles
29 git-diff-tree -r "$1^" "$1" | tr '\t' ' ' | cut -d' ' -f6
32 cache="$GUILT_DIR/$branch/.graphcache.$$"
33 mkdir "$cache"
35 echo "digraph G {"
37 current="$top"
39 while [ "$current" != "$base" ]; do
40 echo "# checking rev $current"
42 echo -n '' > "$cache/dep"
44 getfiles $current | while read f; do
45 # hash the filename
46 fh=`echo "$f" | sha1sum | cut -d' ' -f1`
47 if [ -e "$cache/$fh" ]; then
48 # ok, something already touched this file before us
49 cat "$cache/$fh" >> "$cache/dep"
51 echo "$current" > "$cache/$fh"
52 done
54 cat "$cache/dep" | sort | uniq | while read h; do
55 echo " \"${h:0:8}\" -> \"${current:0:8}\"; // ?"
56 done
58 current=`git-rev-parse $current^`
59 done
61 echo "}"
63 rm -rf "$cache"