]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7614-merge-signoff.sh
Sync with Git 2.45.1
[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
03267e86 11TEST_PASSES_SANITIZE_LEAK=true
14d01b4f
ŁG
12. ./test-lib.sh
13
14# Setup test files
15test_setup() {
16 # Expected commit message after merge --signoff
17 cat >expected-signed <<EOF &&
1e2ae142 18Merge branch 'main' into other-branch
14d01b4f
ŁG
19
20Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
21EOF
22
23 # Expected commit message after merge without --signoff (or with --no-signoff)
24 cat >expected-unsigned <<EOF &&
1e2ae142 25Merge branch 'main' into other-branch
14d01b4f
ŁG
26EOF
27
1e2ae142 28 # Initial commit and feature branch to merge main into it.
14d01b4f
ŁG
29 git commit --allow-empty -m "Initial empty commit" &&
30 git checkout -b other-branch &&
31 test_commit other-branch file1 1
32}
33
34# Setup repository, files & feature branch
35# This step must be run if You want to test 2,3 or 4
36# Order of 2,3,4 is not important, but 1 must be run before
37# For example `-r 1,4` or `-r 1,4,2 -v` etc
38# But not `-r 2` or `-r 4,3,2,1`
39test_expect_success 'setup' '
40 test_setup
41'
42
43# Test with --signoff flag
44test_expect_success 'git merge --signoff adds a sign-off line' '
1e2ae142
JS
45 git checkout main &&
46 test_commit main-branch-2 file2 2 &&
14d01b4f 47 git checkout other-branch &&
1e2ae142 48 git merge main --signoff --no-edit &&
14d01b4f
ŁG
49 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
50 test_cmp expected-signed actual
51'
52
53# Test without --signoff flag
54test_expect_success 'git merge does not add a sign-off line' '
1e2ae142
JS
55 git checkout main &&
56 test_commit main-branch-3 file3 3 &&
14d01b4f 57 git checkout other-branch &&
1e2ae142 58 git merge main --no-edit &&
14d01b4f
ŁG
59 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
60 test_cmp expected-unsigned actual
61'
62
63# Test for --no-signoff flag
64test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
1e2ae142
JS
65 git checkout main &&
66 test_commit main-branch-4 file4 4 &&
14d01b4f 67 git checkout other-branch &&
1e2ae142 68 git merge main --no-edit --signoff --no-signoff &&
14d01b4f
ŁG
69 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
70 test_cmp expected-unsigned actual
71'
72
73test_done