|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='test git post |
| 4 | +
|
| 5 | +We build this history: |
| 6 | +
|
| 7 | + A--B--C <-- master, HEAD |
| 8 | + / |
| 9 | + O <-- side-base, side |
| 10 | +
|
| 11 | +Then we post B and C on top of branch "side": |
| 12 | +
|
| 13 | + A--B--C <-- master, HEAD |
| 14 | + / |
| 15 | + O <-- side-base |
| 16 | + \ |
| 17 | + B*--C* <-- side |
| 18 | +
|
| 19 | +B has a different author, which must be copied to B*. |
| 20 | +' |
| 21 | + |
| 22 | +. ./test-lib.sh |
| 23 | + |
| 24 | +test_expect_success setup ' |
| 25 | +
|
| 26 | + printf "a%s\n" 1 2 3 4 >file-a && |
| 27 | + printf "b%s\n" 5 6 7 8 >file-b && |
| 28 | +
|
| 29 | + test_tick && |
| 30 | + git add file-a file-b && |
| 31 | + git commit -m initial && |
| 32 | + git tag side-base && |
| 33 | +
|
| 34 | + test_tick && |
| 35 | + echo "Advance master" >>file-a && |
| 36 | + git commit -a -m advance-master && |
| 37 | +
|
| 38 | + test_tick && |
| 39 | + echo "Unrelated fix" >>file-b && |
| 40 | + GIT_AUTHOR_NAME="S O Else" git commit -a -m fix-for-b && |
| 41 | +
|
| 42 | + test_tick && |
| 43 | + echo "Another fix" >>file-b && |
| 44 | + git commit -a -m another-fix-for-b |
| 45 | +' |
| 46 | + |
| 47 | +test_expect_success 'post two commits on top of side' ' |
| 48 | +
|
| 49 | + git branch -f side side-base && |
| 50 | + test_tick && |
| 51 | + git post side HEAD^ && |
| 52 | + test_tick && |
| 53 | + git post side && |
| 54 | +
|
| 55 | + git log --pretty="%at %an %ae %s" HEAD~2.. >expect && |
| 56 | + git log --pretty="%at %an %ae %s" side-base..side >actual && |
| 57 | +
|
| 58 | + test_cmp expect actual && |
| 59 | + git cat-file blob side:file-b >actual && |
| 60 | + test_cmp file-b actual && |
| 61 | +
|
| 62 | + git diff --exit-code side-base side -- file-a # no change |
| 63 | +' |
| 64 | + |
| 65 | +test_expect_success 'post requiring merge resolution fails' ' |
| 66 | +
|
| 67 | + git branch -f side side-base && |
| 68 | + test_must_fail git post side HEAD |
| 69 | +' |
| 70 | + |
| 71 | +test_expect_success 'cannot post onto arbitrary commit name' ' |
| 72 | +
|
| 73 | + git branch -f side side-base && |
| 74 | + test_must_fail git post side^0 HEAD^ |
| 75 | +' |
| 76 | + |
| 77 | +test_done |
0 commit comments