]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7614-merge-signoff.sh
l10n: fr v2.23.0 round 2
[thirdparty/git.git] / t / t7614-merge-signoff.sh
1 #!/bin/sh
2
3 test_description='git merge --signoff
4
5 This test runs git merge --signoff and makes sure that it works.
6 '
7
8 . ./test-lib.sh
9
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
15
16 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
17 EOF
18
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
23
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
28 }
29
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
37 '
38
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
47 '
48
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
57 '
58
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
67 '
68
69 test_done