regression: 011 should test guilt-commit as well
[guilt/mob.git] / guilt-graph
blob7d063b19507557ecd5a0df1c0d5e23ac3dc34f1c
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 disp "# checking rev $current"
43 # new "hash table"
44 rm -f "$cache/dep"
45 touch "$cache/dep"
47 getfiles $current | while read f; do
48 # hash the filename
49 fh=`echo "$f" | sha1sum | cut -d' ' -f1`
50 if [ -e "$cache/$fh" ]; then
51 # ok, something already touched this file before us
52 cat "$cache/$fh" >> "$cache/dep"
54 echo "$current" > "$cache/$fh"
55 done
57 sort -u "$cache/dep" | while read h; do
58 disp " \"${h:0:8}\" -> \"${current:0:8}\"; // ?"
59 done
61 current=`git rev-parse $current^`
62 done
64 disp "}"