revision: avoid out-of-bounds read/write on empty pathspec
[git.git] / t / t7614-merge-signoff.sh
blobc1b8446f491dcec38671901c508f2471a9c59d3f
1 #!/bin/sh
3 test_description='git merge --signoff
5 This test runs git merge --signoff and makes sure that it works.
8 . ./test-lib.sh
10 # Setup test files
11 test_setup() {
12 # Expected commit message after merge --signoff
13 cat >expected-signed <<EOF &&
14 Merge branch 'master' into other-branch
16 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
17 EOF
19 # Expected commit message after merge without --signoff (or with --no-signoff)
20 cat >expected-unsigned <<EOF &&
21 Merge branch 'master' into other-branch
22 EOF
24 # Initial commit and feature branch to merge master into it.
25 git commit --allow-empty -m "Initial empty commit" &&
26 git checkout -b other-branch &&
27 test_commit other-branch file1 1
30 # Setup repository, files & feature branch
31 # This step must be run if You want to test 2,3 or 4
32 # Order of 2,3,4 is not important, but 1 must be run before
33 # For example `-r 1,4` or `-r 1,4,2 -v` etc
34 # But not `-r 2` or `-r 4,3,2,1`
35 test_expect_success 'setup' '
36 test_setup
39 # Test with --signoff flag
40 test_expect_success 'git merge --signoff adds a sign-off line' '
41 git checkout master &&
42 test_commit master-branch-2 file2 2 &&
43 git checkout other-branch &&
44 git merge master --signoff --no-edit &&
45 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
46 test_cmp expected-signed actual
49 # Test without --signoff flag
50 test_expect_success 'git merge does not add a sign-off line' '
51 git checkout master &&
52 test_commit master-branch-3 file3 3 &&
53 git checkout other-branch &&
54 git merge master --no-edit &&
55 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
56 test_cmp expected-unsigned actual
59 # Test for --no-signoff flag
60 test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
61 git checkout master &&
62 test_commit master-branch-4 file4 4 &&
63 git checkout other-branch &&
64 git merge master --no-edit --signoff --no-signoff &&
65 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
66 test_cmp expected-unsigned actual
69 test_done