forked from vitaly/guilt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathguilt-graph
executable file
·73 lines (57 loc) · 1.33 KB
/
guilt-graph
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#
USAGE="[<patchname>]"
. `dirname $0`/guilt
if [ $# -gt 1 ]; then
usage
fi
patchname="$1"
bottom=`git rev-parse refs/patches/$branch/$(head -1 < "$applied")`
base=`git rev-parse $bottom^`
if [ -z "$patchname" ]; then
top=`git rev-parse HEAD`
else
top=`grep "^$patchname$" "$applied"`
if [ -z "$top" ]; then
die "Cannot find patch '$patchname'. Is it applied?"
fi
fi
getfiles()
{
git diff-tree -r "$1^" "$1" | tr '\t' ' ' | cut -d' ' -f6
}
cache="$GUILT_DIR/$branch/.graphcache.$$"
mkdir "$cache"
trap "rm -rf \"$cache\"" 0
disp "digraph G {"
current="$top"
while [ "$current" != "$base" ]; do
pname=`git show-ref | sed -n -e "
/^$current refs\/patches\/$branch/ {
s,^$current refs/patches/$branch/,,
p
q
}"`
[ -z "$pname" ] && pname="?"
disp "# checking rev $current"
disp " \"$current\" [label=\"$pname\"]"
# new "hash table"
rm -f "$cache/dep"
touch "$cache/dep"
getfiles $current | while read f; do
# hash the filename
fh=`echo "$f" | sha1sum | cut -d' ' -f1`
if [ -e "$cache/$fh" ]; then
# ok, something already touched this file before us
cat "$cache/$fh" >> "$cache/dep"
fi
echo "$current" > "$cache/$fh"
done
sort -u "$cache/dep" | while read h; do
disp " \"$h\" -> \"$current\"; // ?"
done
current=`git rev-parse $current^`
done
disp "}"