add-patch: plug a leak handling the '/' command
[alt-git.git] / t / t7614-merge-signoff.sh
blobcf96a35e8e7b20975628cce6a5882c18c32fbeaa
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_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
14 # Setup test files
15 test_setup() {
16 # Expected commit message after merge --signoff
17 cat >expected-signed <<EOF &&
18 Merge branch 'main' into other-branch
20 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
21 EOF
23 # Expected commit message after merge without --signoff (or with --no-signoff)
24 cat >expected-unsigned <<EOF &&
25 Merge branch 'main' into other-branch
26 EOF
28 # Initial commit and feature branch to merge main into it.
29 git commit --allow-empty -m "Initial empty commit" &&
30 git checkout -b other-branch &&
31 test_commit other-branch file1 1
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`
39 test_expect_success 'setup' '
40 test_setup
43 # Test with --signoff flag
44 test_expect_success 'git merge --signoff adds a sign-off line' '
45 git checkout main &&
46 test_commit main-branch-2 file2 2 &&
47 git checkout other-branch &&
48 git merge main --signoff --no-edit &&
49 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
50 test_cmp expected-signed actual
53 # Test without --signoff flag
54 test_expect_success 'git merge does not add a sign-off line' '
55 git checkout main &&
56 test_commit main-branch-3 file3 3 &&
57 git checkout other-branch &&
58 git merge main --no-edit &&
59 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
60 test_cmp expected-unsigned actual
63 # Test for --no-signoff flag
64 test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
65 git checkout main &&
66 test_commit main-branch-4 file4 4 &&
67 git checkout other-branch &&
68 git merge main --no-edit --signoff --no-signoff &&
69 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
70 test_cmp expected-unsigned actual
73 test_done