]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3431-rebase-fork-point.sh
Merge branch 'jc/codingstyle-compare-with-null'
[thirdparty/git.git] / t / t3431-rebase-fork-point.sh
CommitLineData
359ecebc
DL
1#!/bin/sh
2#
3# Copyright (c) 2019 Denton Liu
4#
5
6test_description='git rebase --fork-point test'
7
8. ./test-lib.sh
9
10# A---B---D---E (master)
11# \
12# C*---F---G (side)
13#
14# C was formerly part of master but master was rewound to remove C
15#
16test_expect_success setup '
17 test_commit A &&
18 test_commit B &&
19 test_commit C &&
20 git branch -t side &&
21 git reset --hard HEAD^ &&
22 test_commit D &&
23 test_commit E &&
24 git checkout side &&
25 test_commit F &&
26 test_commit G
27'
28
29test_rebase () {
30 expected="$1" &&
31 shift &&
32 test_expect_success "git rebase $*" "
33 git checkout master &&
34 git reset --hard E &&
35 git checkout side &&
36 git reset --hard G &&
37 git rebase $* &&
38 test_write_lines $expected >expect &&
39 git log --pretty=%s >actual &&
40 test_cmp expect actual
41 "
42}
43
44test_rebase 'G F E D B A'
45test_rebase 'G F D B A' --onto D
414d924b 46test_rebase 'G F B A' --keep-base
359ecebc
DL
47test_rebase 'G F C E D B A' --no-fork-point
48test_rebase 'G F C D B A' --no-fork-point --onto D
414d924b 49test_rebase 'G F C B A' --no-fork-point --keep-base
f08132f8 50
359ecebc 51test_rebase 'G F E D B A' --fork-point refs/heads/master
f08132f8
JH
52test_rebase 'G F E D B A' --fork-point master
53
359ecebc 54test_rebase 'G F D B A' --fork-point --onto D refs/heads/master
f08132f8
JH
55test_rebase 'G F D B A' --fork-point --onto D master
56
414d924b 57test_rebase 'G F B A' --fork-point --keep-base refs/heads/master
f08132f8
JH
58test_rebase 'G F B A' --fork-point --keep-base master
59
359ecebc 60test_rebase 'G F C E D B A' refs/heads/master
f08132f8
JH
61test_rebase 'G F C E D B A' master
62
359ecebc 63test_rebase 'G F C D B A' --onto D refs/heads/master
f08132f8
JH
64test_rebase 'G F C D B A' --onto D master
65
414d924b 66test_rebase 'G F C B A' --keep-base refs/heads/master
f08132f8
JH
67test_rebase 'G F C B A' --keep-base master
68
69test_expect_success 'git rebase --fork-point with ambigous refname' '
70 git checkout master &&
71 git checkout -b one &&
72 git checkout side &&
73 git tag one &&
74 test_must_fail git rebase --fork-point --onto D one
75'
359ecebc
DL
76
77test_done