]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7614-merge-signoff.sh
Sync with 2.36.3
[thirdparty/git.git] / t / t7614-merge-signoff.sh
CommitLineData
14d01b4f
ŁG
1#!/bin/sh
2
3test_description='git merge --signoff
4
5This test runs git merge --signoff and makes sure that it works.
6'
7
1e2ae142 8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
14d01b4f
ŁG
11. ./test-lib.sh
12
13# Setup test files
14test_setup() {
15 # Expected commit message after merge --signoff
16 cat >expected-signed <<EOF &&
1e2ae142 17Merge branch 'main' into other-branch
14d01b4f
ŁG
18
19Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
20EOF
21
22 # Expected commit message after merge without --signoff (or with --no-signoff)
23 cat >expected-unsigned <<EOF &&
1e2ae142 24Merge branch 'main' into other-branch
14d01b4f
ŁG
25EOF
26
1e2ae142 27 # Initial commit and feature branch to merge main into it.
14d01b4f
ŁG
28 git commit --allow-empty -m "Initial empty commit" &&
29 git checkout -b other-branch &&
30 test_commit other-branch file1 1
31}
32
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`
38test_expect_success 'setup' '
39 test_setup
40'
41
42# Test with --signoff flag
43test_expect_success 'git merge --signoff adds a sign-off line' '
1e2ae142
JS
44 git checkout main &&
45 test_commit main-branch-2 file2 2 &&
14d01b4f 46 git checkout other-branch &&
1e2ae142 47 git merge main --signoff --no-edit &&
14d01b4f
ŁG
48 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
49 test_cmp expected-signed actual
50'
51
52# Test without --signoff flag
53test_expect_success 'git merge does not add a sign-off line' '
1e2ae142
JS
54 git checkout main &&
55 test_commit main-branch-3 file3 3 &&
14d01b4f 56 git checkout other-branch &&
1e2ae142 57 git merge main --no-edit &&
14d01b4f
ŁG
58 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
59 test_cmp expected-unsigned actual
60'
61
62# Test for --no-signoff flag
63test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
1e2ae142
JS
64 git checkout main &&
65 test_commit main-branch-4 file4 4 &&
14d01b4f 66 git checkout other-branch &&
1e2ae142 67 git merge main --no-edit --signoff --no-signoff &&
14d01b4f
ŁG
68 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
69 test_cmp expected-unsigned actual
70'
71
72test_done