]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3411-rebase-preserve-around-merges.sh
Merge branch 'nd/pretty-commit-log-message'
[thirdparty/git.git] / t / t3411-rebase-preserve-around-merges.sh
CommitLineData
42f939e4
SH
1#!/bin/sh
2#
3# Copyright (c) 2008 Stephen Haberman
4#
5
6test_description='git rebase preserve merges
7
29a03348
JS
8This test runs git rebase with -p and tries to squash a commit from after
9a merge to before the merge.
42f939e4
SH
10'
11. ./test-lib.sh
12
eaf0551d 13. "$TEST_DIRECTORY"/lib-rebase.sh
42f939e4 14
29a03348 15set_fake_editor
42f939e4
SH
16
17# set up two branches like this:
18#
19# A1 - B1 - D1 - E1 - F1
20# \ /
21# -- C1 --
22
23test_expect_success 'setup' '
37e5c8f4
JS
24 test_commit A1 &&
25 test_commit B1 &&
26 test_commit C1 &&
27 git reset --hard B1 &&
28 test_commit D1 &&
29 test_merge E1 C1 &&
30 test_commit F1
42f939e4
SH
31'
32
33# Should result in:
34#
35# A1 - B1 - D2 - E2
36# \ /
37# -- C1 --
38#
80fe82e4 39test_expect_success 'squash F1 into D1' '
12bf8283 40 FAKE_LINES="1 squash 4 2 3" git rebase -i -p B1 &&
37e5c8f4 41 test "$(git rev-parse HEAD^2)" = "$(git rev-parse C1)" &&
42f939e4
SH
42 test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
43 git tag E2
44'
45
46# Start with:
47#
48# A1 - B1 - D2 - E2
49# \
50# G1 ---- L1 ---- M1
51# \ /
52# H1 -- J1 -- K1
53# \ /
54# -- I1 --
55#
56# And rebase G1..M1 onto E2
57
80fe82e4 58test_expect_success 'rebase two levels of merge' '
37e5c8f4
JS
59 test_commit G1 &&
60 test_commit H1 &&
61 test_commit I1 &&
62 git checkout -b branch3 H1 &&
63 test_commit J1 &&
64 test_merge K1 I1 &&
65 git checkout -b branch2 G1 &&
66 test_commit L1 &&
67 test_merge M1 K1 &&
42f939e4
SH
68 GIT_EDITOR=: git rebase -i -p E2 &&
69 test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" &&
70 test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" &&
71 test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"
72'
73
74test_done