[PATCH] guilt: fix "from: xxx" filtering in the patch description
[guilt.git] / guilt-graph
blob496a831f49e9e3c8950dfcae4c2eb76f9bcf294a
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007-2011
6 USAGE="[<patchname>]"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename $0` directly is no longer supported." >&2
9 exit 1
12 _main() {
14 if [ $# -gt 1 ]; then
15 usage
18 patchname="$1"
20 bottom=`git rev-parse refs/patches/$branch/$(head_n 1 < "$applied")`
21 base=`git rev-parse $bottom^`
23 if [ -z "$patchname" ]; then
24 top=`git rev-parse HEAD`
25 else
26 top=`grep "^$patchname$" "$applied"`
27 if [ -z "$top" ]; then
28 die "Cannot find patch '$patchname'. Is it applied?"
32 getfiles()
34 git diff-tree -r "$1^" "$1" | tr '\t' ' ' | cut -d' ' -f6
37 cache="$GUILT_DIR/$branch/.graphcache.$$"
38 mkdir "$cache"
39 trap "rm -rf \"$cache\"" 0
41 disp "digraph G {"
43 current="$top"
45 while [ "$current" != "$base" ]; do
46 pname=`git show-ref | sed -n -e "
47 /^$current refs\/patches\/$branch/ {
48 s,^$current refs/patches/$branch/,,
51 }"`
52 [ -z "$pname" ] && pname="?"
54 disp "# checking rev $current"
55 disp " \"$current\" [label=\"$pname\"]"
57 # new "hash table"
58 rm -f "$cache/dep"
59 touch "$cache/dep"
61 getfiles $current | while read f; do
62 # hash the filename
63 fh=`echo "$f" | sha1 | cut -d' ' -f1`
64 if [ -e "$cache/$fh" ]; then
65 # ok, something already touched this file before us
66 cat "$cache/$fh" >> "$cache/dep"
68 echo "$current" > "$cache/$fh"
69 done
71 sort -u "$cache/dep" | while read h; do
72 disp " \"$h\" -> \"$current\"; // ?"
73 done
75 current=`git rev-parse $current^`
76 done
78 disp "}"