@matheusbsbs / matheus-bagliano / commits / 29a03348a3
Fork 0

t3404 & t3411: undo copy&paste

Rather than copying and pasting, which is prone to lead to fixes missing in one version, move the fake-editor generator to t/t3404/. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 27, 2009 at 23:34 UTC 29a03348a336f28025c824436a713cb9cb01b7a6
3 files changed +44 -67
t/lib-rebase.sh new
+36
@@ -0,0 +1,36 @@
1 +#!/bin/sh
2 +
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
11 + ;;
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";;
25 + *)
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
33 +
34 + test_set_editor "$(pwd)/fake-editor.sh"
35 + chmod a+x fake-editor.sh
36 +}
t/t3404-rebase-interactive.sh
+4 -33
@@ -10,6 +10,10 @@ that the result still makes sense.
10 '
11 . ./test-lib.sh
12
13 +. ../lib-rebase.sh
14 +
15 +set_fake_editor
16 +
17 # set up two branches like this:
18 #
19 # A - B - C - D - E
@@ -61,39 +65,6 @@ test_expect_success 'setup' '
65 git tag I
66 '
67
64 -echo "#!$SHELL_PATH" >fake-editor.sh
65 -cat >> fake-editor.sh <<\EOF
66 -case "$1" in
67 -*/COMMIT_EDITMSG)
68 - test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
69 - test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
70 - exit
71 - ;;
72 -esac
73 -test -z "$EXPECT_COUNT" ||
74 - test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
75 - exit
76 -test -z "$FAKE_LINES" && exit
77 -grep -v '^#' < "$1" > "$1".tmp
78 -rm -f "$1"
79 -cat "$1".tmp
80 -action=pick
81 -for line in $FAKE_LINES; do
82 - case $line in
83 - squash|edit)
84 - action="$line";;
85 - *)
86 - echo sed -n "${line}s/^pick/$action/p"
87 - sed -n "${line}p" < "$1".tmp
88 - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
89 - action=pick;;
90 - esac
91 -done
92 -EOF
93 -
94 -test_set_editor "$(pwd)/fake-editor.sh"
95 -chmod a+x fake-editor.sh
96 -
68 test_expect_success 'no changes are a nop' '
69 git rebase -i F &&
70 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
t/t3411-rebase-preserve-around-merges.sh
+4 -34
@@ -5,44 +5,14 @@
5
6 test_description='git rebase preserve merges
7
8 -This test runs git rebase with and tries to squash a commit from after a merge
9 -to before the merge.
8 +This test runs git rebase with -p and tries to squash a commit from after
9 +a merge to before the merge.
10 '
11 . ./test-lib.sh
12
13 -# Copy/paste from t3404-rebase-interactive.sh
14 -echo "#!$SHELL_PATH" >fake-editor.sh
15 -cat >> fake-editor.sh <<\EOF
16 -case "$1" in
17 -*/COMMIT_EDITMSG)
18 - test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
19 - test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
20 - exit
21 - ;;
22 -esac
23 -test -z "$EXPECT_COUNT" ||
24 - test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
25 - exit
26 -test -z "$FAKE_LINES" && exit
27 -grep -v '^#' < "$1" > "$1".tmp
28 -rm -f "$1"
29 -cat "$1".tmp
30 -action=pick
31 -for line in $FAKE_LINES; do
32 - case $line in
33 - squash|edit)
34 - action="$line";;
35 - *)
36 - echo sed -n "${line}s/^pick/$action/p"
37 - sed -n "${line}p" < "$1".tmp
38 - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
39 - action=pick;;
40 - esac
41 -done
42 -EOF
13 +. ../lib-rebase.sh
14
44 -test_set_editor "$(pwd)/fake-editor.sh"
45 -chmod a+x fake-editor.sh
15 +set_fake_editor
16
17 # set up two branches like this:
18 #