-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathincr_checkout.sh
More file actions
45 lines (37 loc) · 768 Bytes
/
Copy pathincr_checkout.sh
File metadata and controls
45 lines (37 loc) · 768 Bytes
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
#!/bin/sh
file_to_copy=$2
num_lines=`wc -l $1 | awk '{print $1}'`
curr_line=0
while true
do
echo "Enter any line of text to proceed to the next checkout."
read resp
if test $resp = 'q'
then
break
elif test $resp = 'b'
then
if test $curr_line -lt 2
then
echo "Can't go back, you are at the beginning!"
continue
else
curr_line=`expr $curr_line - 1`
echo "Backing up to the commit on line $curr_line"
fi
else
curr_line=`expr $curr_line + 1`
fi
if test "${curr_line}" -gt "${num_lines}"
then
echo "Done!"
break
fi
next_commit=`head -n${curr_line} $1 | tail -n1`
git checkout ${next_commit}
if ! test -z $2
then
cp ${file_to_copy} copy_${file_to_copy}
fi
done
echo "You probably want to checkout master at this point!"