]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7614-merge-signoff.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[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
334afbc7
JS
8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
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 &&
17Merge branch 'master' into other-branch
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 &&
24Merge branch 'master' into other-branch
25EOF
26
27 # Initial commit and feature branch to merge master into it.
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' '
44 git checkout master &&
45 test_commit master-branch-2 file2 2 &&
46 git checkout other-branch &&
47 git merge master --signoff --no-edit &&
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' '
54 git checkout master &&
55 test_commit master-branch-3 file3 3 &&
56 git checkout other-branch &&
57 git merge master --no-edit &&
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' '
64 git checkout master &&
65 test_commit master-branch-4 file4 4 &&
66 git checkout other-branch &&
67 git merge master --no-edit --signoff --no-signoff &&
68 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
69 test_cmp expected-unsigned actual
70'
71
72test_done