Skip to content

Commit 29a0334

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8712b3c commit 29a0334

File tree

3 files changed

+44
-67
lines changed

3 files changed

+44
-67
lines changed

t/lib-rebase.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ that the result still makes sense.
1010
'
1111
. ./test-lib.sh
1212

13+
. ../lib-rebase.sh
14+
15+
set_fake_editor
16+
1317
# set up two branches like this:
1418
#
1519
# A - B - C - D - E
@@ -61,39 +65,6 @@ test_expect_success 'setup' '
6165
git tag I
6266
'
6367

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-
9768
test_expect_success 'no changes are a nop' '
9869
git rebase -i F &&
9970
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&

t/t3411-rebase-preserve-around-merges.sh

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,14 @@
55

66
test_description='git rebase preserve merges
77
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.
1010
'
1111
. ./test-lib.sh
1212

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
4314

44-
test_set_editor "$(pwd)/fake-editor.sh"
45-
chmod a+x fake-editor.sh
15+
set_fake_editor
4616

4717
# set up two branches like this:
4818
#

0 commit comments

Comments
 (0)