-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-qshow
executable file
·68 lines (60 loc) · 1.49 KB
/
git-qshow
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
#!/bin/bash
#
# Copyright (C) 2013 MORITA Kazutaka <[email protected]>
#
. git-qsh-setup
USAGE="[<patch>]"
name=$1
if [ "$name" = "" ]; then
name=$(git qnext)
fi
setup_colors()
{
local C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:patch_applied=32:clear=00
[ -n "$QUILT_COLORS" ] && C="$C:$QUILT_COLORS"
C=${C//=/=\'$'\e'[}
C=color_${C//:/m\'; color_}m\'
eval $C
}
colorize()
{
setup_colors
sed -e '
s/^\(Index:\|---\|+++\|\*\*\*\) .*/'$color_diff_hdr'&'$color_clear'/
t ; s/^+.*/'$color_diff_add'&'$color_clear'/
t ; s/^-.*/'$color_diff_rem'&'$color_clear'/
t ; s/^!.*/'$color_diff_mod'&'$color_clear'/
t ; s/^\(@@ \-[0-9]\+\(,[0-9]\+\)\? +[0-9]\+\(,[0-9]\+\)\? @@\)\([ \t]*\)\(.*\)/'$color_diff_hunk'\1'$color_clear'\4'$color_diff_ctx'\5'$color_clear'/
t ; s/^\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*.*/'$color_diff_cctx'&'$color_clear'/
'
}
_filter()
{
sed ':loop; N; $!b loop; ;s/\n\t/,/g' | \
perl -pe '
if ($commitlog) {
} elsif ($body) {
if (/^--/) {
$commitlog = 1
} elsif ($_) {
$_ = " $_";
}
} else {
if (/^\n$/) {
$body = 1;
} elsif (/^Subject: (\[.+?\] ?)*(.+)/) {
$_ = "\n $2\n";
} elsif (/^Date:/) {
} elsif (/^From:(.+)/) {
$_ = "Author:$1\n";
} else {
$_ = "";
}
}
'
}
if [ -t 1 ]; then
cat $GITQ_DIR/$branch/$name | _filter | colorize | $pager
else
cat $GITQ_DIR/$branch/$name | _filter
fi