]>
Commit | Line | Data |
---|---|---|
00f66f0e | 1 | #!/bin/sh |
beb17217 CB |
2 | |
3 | test_description='git rebase - test patch id computation' | |
4 | ||
d1c02d93 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
beb17217 CB |
8 | . ./test-lib.sh |
9 | ||
b687cd6a | 10 | scramble () { |
beb17217 CB |
11 | i=0 |
12 | while read x | |
13 | do | |
14 | if test $i -ne 0 | |
15 | then | |
16 | echo "$x" | |
17 | fi | |
00f66f0e | 18 | i=$((($i+1) % 10)) |
b687cd6a | 19 | done <"$1" >"$1.new" |
beb17217 CB |
20 | mv -f "$1.new" "$1" |
21 | } | |
22 | ||
beb17217 | 23 | test_expect_success 'setup' ' |
02380389 | 24 | git commit --allow-empty -m initial && |
beb17217 CB |
25 | git tag root |
26 | ' | |
27 | ||
bb2dbe30 JK |
28 | test_expect_success 'setup: 500 lines' ' |
29 | rm -f .gitattributes && | |
d1c02d93 | 30 | git checkout -q -f main && |
bb2dbe30 JK |
31 | git reset --hard root && |
32 | test_seq 500 >file && | |
33 | git add file && | |
34 | git commit -q -m initial && | |
35 | git branch -f other && | |
36 | ||
37 | scramble file && | |
38 | git add file && | |
39 | git commit -q -m "change big file" && | |
40 | ||
41 | git checkout -q other && | |
42 | : >newfile && | |
43 | git add newfile && | |
44 | git commit -q -m "add small file" && | |
45 | ||
d1c02d93 | 46 | git cherry-pick main >/dev/null 2>&1 |
bb2dbe30 | 47 | ' |
beb17217 | 48 | |
bb2dbe30 JK |
49 | test_expect_success 'setup attributes' ' |
50 | echo "file binary" >.gitattributes | |
51 | ' | |
beb17217 | 52 | |
bb2dbe30 | 53 | test_expect_success 'detect upstream patch' ' |
d1c02d93 | 54 | git checkout -q main && |
bb2dbe30 JK |
55 | scramble file && |
56 | git add file && | |
57 | git commit -q -m "change big file again" && | |
58 | git checkout -q other^{} && | |
d1c02d93 JS |
59 | git rebase main && |
60 | git rev-list main...HEAD~ >revs && | |
21e3bb12 | 61 | test_must_be_empty revs |
bb2dbe30 | 62 | ' |
beb17217 | 63 | |
bb2dbe30 | 64 | test_expect_success 'do not drop patch' ' |
d1c02d93 | 65 | git branch -f squashed main && |
bb2dbe30 JK |
66 | git checkout -q -f squashed && |
67 | git reset -q --soft HEAD~2 && | |
68 | git commit -q -m squashed && | |
69 | git checkout -q other^{} && | |
70 | test_must_fail git rebase squashed && | |
71 | git rebase --quit | |
72 | ' | |
beb17217 CB |
73 | |
74 | test_done |