Merge branch 'jd/prompt-upstream-mark'
[alt-git.git] / t / t7614-merge-signoff.sh
blobfee258d4f0c2c0d4b230891eeb93d522d27a4979
1 #!/bin/sh
3 test_description='git merge --signoff
5 This test runs git merge --signoff and makes sure that it works.
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 . ./test-lib.sh
13 # Setup test files
14 test_setup() {
15 # Expected commit message after merge --signoff
16 cat >expected-signed <<EOF &&
17 Merge branch 'main' into other-branch
19 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
20 EOF
22 # Expected commit message after merge without --signoff (or with --no-signoff)
23 cat >expected-unsigned <<EOF &&
24 Merge branch 'main' into other-branch
25 EOF
27 # Initial commit and feature branch to merge main into it.
28 git commit --allow-empty -m "Initial empty commit" &&
29 git checkout -b other-branch &&
30 test_commit other-branch file1 1
33 # Setup repository, files & feature branch
34 # This step must be run if You want to test 2,3 or 4
35 # Order of 2,3,4 is not important, but 1 must be run before
36 # For example `-r 1,4` or `-r 1,4,2 -v` etc
37 # But not `-r 2` or `-r 4,3,2,1`
38 test_expect_success 'setup' '
39 test_setup
42 # Test with --signoff flag
43 test_expect_success 'git merge --signoff adds a sign-off line' '
44 git checkout main &&
45 test_commit main-branch-2 file2 2 &&
46 git checkout other-branch &&
47 git merge main --signoff --no-edit &&
48 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
49 test_cmp expected-signed actual
52 # Test without --signoff flag
53 test_expect_success 'git merge does not add a sign-off line' '
54 git checkout main &&
55 test_commit main-branch-3 file3 3 &&
56 git checkout other-branch &&
57 git merge main --no-edit &&
58 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
59 test_cmp expected-unsigned actual
62 # Test for --no-signoff flag
63 test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
64 git checkout main &&
65 test_commit main-branch-4 file4 4 &&
66 git checkout other-branch &&
67 git merge main --no-edit --signoff --no-signoff &&
68 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
69 test_cmp expected-unsigned actual
72 test_done