[PATCH] Fix guilt-import patch naming
[guilt/mob.git] / guilt-graph
blob094cad0f1436737230afc72d2d1493645bd88f62
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=`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 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 echo "digraph G {"
38 current="$top"
40 while [ "$current" != "$base" ]; do
41 echo "# 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 echo " \"${h:0:8}\" -> \"${current:0:8}\"; // ?"
59 done
61 current=`git-rev-parse $current^`
62 done
64 echo "}"