-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitdiff_magic.sh
More file actions
87 lines (73 loc) · 1.8 KB
/
Copy pathgitdiff_magic.sh
File metadata and controls
87 lines (73 loc) · 1.8 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
scan_git() {
files1=`git status --porcelain | grep " M \".*\"" | perl -nle 'm/ M ([\"].*)/; print $1'`
files2=`git status --porcelain | grep " M [^\"].*" | perl -nle 'm/ M (.*)/; print $1'`
files="$files1 $files2"
if [ "$files" = " " ]; then
git status
echo
echo "Nothing left to diff. Everything's already checked into the index."
echo " (use \"git reset HEAD <file>...\" to unstage files)"
files=""
else
echo "Listing changes not added to index:"
files="\"***Quit***\" \"***Git Status***\" $files"
fi
}
scan_git
while [ "$files" != "" ]; do
#echo files $files
eval set $files
select opt in "$@"
do
#echo "File=\"$opt\""
if [ "$opt" = "***Quit***" ]; then
git status
exit
fi
if [ "$opt" = "***Git Status***" ]; then
git status
echo -n "Press enter to continue... "
read response
else
### DIFF? ###
echo -n " Diff file \"$opt\" [Y/n]? "
read response
if [ "$response" != "n" ]; then
echo " ~ git diff \"$opt\" ..."
git diff "$opt"
### ADD? ###
echo -n " Add file \"$opt\" [Y/n]? "
read response
if [ "$response" != "n" ]; then
echo " ~ git add \"$opt\""
git add "$opt"
else
### REVERT? ###
echo -n " Revert file \"$opt\" [y/N]? "
read response
if [ "$response" = "y" ]; then
# ### VERIFY 1 ###
# echo -n " REVERT: Are you sure [y/N]? "
# read response
# if [ "$response" = "y" ]; then
# ### VERIFY 2 ###
# echo " ****This cannot be undone****"
# echo -n " REVERT: Are you really sure [y/N]?"
# read response
#
# if [ "$response" = "y" ]; then
echo " ~ git checkout -- \"$opt\""
echo -n " [press enter to execute]"
read response
git checkout -- "$opt"
# fi
# fi
fi
fi
fi
fi
break
done
scan_git
done