File tree Expand file tree Collapse file tree 3 files changed +44
-67
lines changed Expand file tree Collapse file tree 3 files changed +44
-67
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ that the result still makes sense.
10
10
'
11
11
. ./test-lib.sh
12
12
13
+ . ../lib-rebase.sh
14
+
15
+ set_fake_editor
16
+
13
17
# set up two branches like this:
14
18
#
15
19
# A - B - C - D - E
@@ -61,39 +65,6 @@ test_expect_success 'setup' '
61
65
git tag I
62
66
'
63
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
-
97
68
test_expect_success ' no changes are a nop' '
98
69
git rebase -i F &&
99
70
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
Original file line number Diff line number Diff line change 5
5
6
6
test_description=' git rebase preserve merges
7
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
10
'
11
11
. ./test-lib.sh
12
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
43
14
44
- test_set_editor " $( pwd) /fake-editor.sh"
45
- chmod a+x fake-editor.sh
15
+ set_fake_editor
46
16
47
17
# set up two branches like this:
48
18
#
You can’t perform that action at this time.
0 commit comments