Guilt v0.32-rc2
[guilt.git] / guilt-graph
blob0fb4e7931eef26ef12f42ba0e81906d77a8b0db5
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 USAGE="[<patchname>]"
7 . `dirname $0`/guilt
9 if [ $# -gt 1 ]; then
10 usage
13 patchname="$1"
15 bottom=`git rev-parse refs/patches/$branch/$(head -1 < "$applied")`
16 base=`git rev-parse $bottom^`
18 if [ -z "$patchname" ]; then
19 top=`git rev-parse HEAD`
20 else
21 top=`grep "^$patchname$" "$applied"`
22 if [ -z "$top" ]; then
23 die "Cannot find patch '$patchname'. Is it applied?"
27 getfiles()
29 git diff-tree -r "$1^" "$1" | tr '\t' ' ' | cut -d' ' -f6
32 cache="$GUILT_DIR/$branch/.graphcache.$$"
33 mkdir "$cache"
34 trap "rm -rf \"$cache\"" 0
36 disp "digraph G {"
38 current="$top"
40 while [ "$current" != "$base" ]; do
41 pname=`git show-ref | sed -n -e "
42 /^$current refs\/patches\/$branch/ {
43 s,^$current refs/patches/$branch/,,
46 }"`
47 [ -z "$pname" ] && pname="?"
49 disp "# checking rev $current"
50 disp " \"$current\" [label=\"$pname\"]"
52 # new "hash table"
53 rm -f "$cache/dep"
54 touch "$cache/dep"
56 getfiles $current | while read f; do
57 # hash the filename
58 fh=`echo "$f" | sha1sum | cut -d' ' -f1`
59 if [ -e "$cache/$fh" ]; then
60 # ok, something already touched this file before us
61 cat "$cache/$fh" >> "$cache/dep"
63 echo "$current" > "$cache/$fh"
64 done
66 sort -u "$cache/dep" | while read h; do
67 disp " \"$h\" -> \"$current\"; // ?"
68 done
70 current=`git rev-parse $current^`
71 done
73 disp "}"