t3404 & t3411: undo copy&paste
[git/spearce.git] / t / lib-rebase.sh
blob762ffcfa0f0f25d64821ca0ffc08fe92b1a3c572
1 #!/bin/sh
3 set_fake_editor () {
4 echo "#!$SHELL_PATH" >fake-editor.sh
5 cat >> fake-editor.sh <<\EOF
6 case "$1" in
7 */COMMIT_EDITMSG)
8 test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
9 test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
10 exit
12 esac
13 test -z "$EXPECT_COUNT" ||
14 test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
15 exit
16 test -z "$FAKE_LINES" && exit
17 grep -v '^#' < "$1" > "$1".tmp
18 rm -f "$1"
19 cat "$1".tmp
20 action=pick
21 for line in $FAKE_LINES; do
22 case $line in
23 squash|edit)
24 action="$line";;
26 echo sed -n "${line}s/^pick/$action/p"
27 sed -n "${line}p" < "$1".tmp
28 sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
29 action=pick;;
30 esac
31 done
32 EOF
34 test_set_editor "$(pwd)/fake-editor.sh"
35 chmod a+x fake-editor.sh