-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-rev-to
executable file
·42 lines (33 loc) · 910 Bytes
/
add-rev-to
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
#!/bin/sh
## Edit given commit, run 'add-rev name' and edit to fixup things
## then go back.
#
# usage: $0 name commit
NAME="$1"
CID="$2"
EDITAFTER=false
if [ -z "$NAME" ]; then
echo "Will use default reviewer"
fi
if [ -z "$CID" ]; then
echo "Usage: $0 name <commit>"
exit 1
fi
MYBRANCH=$(git branch | gawk '/^\* / { print $2 }')
TMPBRANCH="tmp-commit-edit.$$"
echo "FINALIZE BY:" git rebase --onto "$TMPBRANCH" "$CID" "$MYBRANCH"
git checkout -f -b "$TMPBRANCH" "$CID"
echo
echo "(Shell started) Now edit the diff and run"
echo " git commit --amend"
echo
echo "(then type exit and git will continue)"
#bash
add-rev $NAME
if $EDITAFTER; then
git commit --amend -v
fi
echo git rebase --onto "$TMPBRANCH" "$CID" "$MYBRANCH"
git rebase --onto "$TMPBRANCH" "$CID" "$MYBRANCH" || { echo did not work for some reason, fix and rerun the command above; exit 1; }
git branch -d "$TMPBRANCH"
echo "done."