-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable_git-stash-admin
More file actions
executable file
·62 lines (59 loc) · 1.11 KB
/
executable_git-stash-admin
File metadata and controls
executable file
·62 lines (59 loc) · 1.11 KB
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
#!/bin/bash
I=0
while [ true ]; do
# Check count on each loop because stashes may be dropped
CUR_STASH_COUNT=$(git stash list | wc -l)
if [ "${CUR_STASH_COUNT}" -le "${I}" ]; then
echo "no more stashes"
exit 0
fi
STASH="stash@{${I}}"
git stash show "${STASH}"
git stash list -n $((${I} + 1 )) | tail -n 1
git show "${STASH}^3" --stat 2> /dev/null
echo -n "action [A,D,P,d,j,n,p,q,?]? "
read INPUT
case "${INPUT}" in
A)
git stash apply "${STASH}"
# does not increment
;;
D)
git stash drop "${STASH}"
;;
j)
echo -n "Jump to:"
read I
;;
P)
git stash pop "${STASH}"
;;
d)
git stash show --patch "${STASH}"
;;
n)
I=$((${I} + 1))
;;
p)
if [ "${I}" -eq 0 ]; then
echo "Already at first stash"
else
I=$((${I} - 1))
fi
;;
q)
exit 0
;;
?)
cat << EOF
A - apply this stash (apply changes, keep stash)
D - drop (delete) this stash
P - pop this stash
d - diff this stash
n - next stash
p - previous stash
q - quit
EOF
;;
esac
done