forked from pihhan/rpm-gitprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrej-solve
executable file
·54 lines (50 loc) · 872 Bytes
/
rej-solve
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
#!/bin/sh
[ -z "$EDITOR" ] && EDITOR="$VISUAL"
[ -z "$EDITOR" ] && EDITOR="vim"
if [ -z "$@" ]
then
FILES="$(git status --porcelain -- '**.rej' | sed -e 's/^?? //')"
else
FILES="$@"
fi
for FILE in ${FILES}
do
SOURCE="$(dirname "$FILE")/$(basename "$FILE" .rej)"
FINISH=no
VAR=r
# "$EDITOR" "$FILE"
while [ "$FINISH" != "yes" ]; do
cat << EOF
File: ${FILE}
Edit (r)eject or (s)ource file?
Show both files in (v)im or (g)vim?
(F)inished, show (d)iff or (a)bort?
Choose action:
EOF
read VAR
case "$VAR" in
r|R|rej|reject)
"$EDITOR" "$FILE"
;;
s|S|source)
"$EDITOR" "$SOURCE"
;;
d|D|diff)
git diff "$SOURCE"
;;
v|V|vim|gvim)
"$EDITOR" "+vsplit $SOURCE" "$FILE"
;;
g|G|gvim)
gvim "+vsplit $SOURCE" "$FILE"
;;
f|F|finished|ok)
git add "$SOURCE" && rm "$FILE"
FINISH=yes
;;
a|A|abort|!)
FINISH=yes
;;
esac
done
done