-
Notifications
You must be signed in to change notification settings - Fork 11
/
guilt-files
executable file
·86 lines (75 loc) · 1.3 KB
/
guilt-files
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
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
#
# Copyright (C) 2007 Yasushi SHOJI <[email protected]>
#
USAGE="[-v] [-a] [-l]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename "$0"` directly is no longer supported." >&2
exit 1
fi
_main() {
opt_verbose=
opt_all=
opt_labels=
while case "$#" in 0) break ;; esac
do
case "$1" in
-v)
opt_verbose=t ;;
-a)
opt_all=t ;;
-l)
opt_labels=t ;;
*)
usage ;;
esac
shift
done
top_patch=`get_top`
IFS=:
if [ -n "$opt_all" ]; then
cat "$applied"
else
tail -n 1 "$applied"
fi | while read patch; do
obj=`git rev-parse refs/patches/$branch/$patch`
# shamelessly taken from Quilt(quilt/quilt/files)
if [ -n "$opt_all" ] && [ -n "$opt_verbose" ] && [ -z "$opt_labels" ]; then
disp "$patch"
fi
if [ -n "$opt_verbose" ] && [ -z "$opt_labels" ]; then
use_status=yes
fi
IFS=' '
(
if [ "$top_patch" != "$patch" ]; then
git diff-tree -r $obj^ $obj
else
git diff-index HEAD^
fi
) | tr '\t' ' '|
while read omode nmode osha1 nsha1 st file; do
if [ -n "$opt_labels" ]; then
if [ -n "$opt_verbose" ]; then
_disp "[$patch] "
else
_disp "$patch "
fi
fi
if [ -z "$use_status" ]; then
disp "$file"
else
case $st in
A)
status="+" ;;
D)
status="-" ;;
*)
status=" " ;;
esac
disp "$status $file"
fi
done
IFS=:
done
}