File: t7614-merge-signoff.sh

package info (click to toggle)
git 1:2.20.1-2+deb10u3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,676 kB
  • sloc: ansic: 210,769; sh: 180,432; perl: 29,102; tcl: 21,663; python: 6,143; makefile: 3,700; sed: 189; php: 120; asm: 98; csh: 45; ruby: 24; lisp: 12
file content (69 lines) | stat: -rwxr-xr-x 1,974 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

test_description='git merge --signoff

This test runs git merge --signoff and makes sure that it works.
'

. ./test-lib.sh

# Setup test files
test_setup() {
	# Expected commit message after merge --signoff
	cat >expected-signed <<EOF &&
Merge branch 'master' into other-branch

Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
EOF

	# Expected commit message after merge without --signoff (or with --no-signoff)
	cat >expected-unsigned <<EOF &&
Merge branch 'master' into other-branch
EOF

	# Initial commit and feature branch to merge master into it.
	git commit --allow-empty -m "Initial empty commit" &&
	git checkout -b other-branch &&
	test_commit other-branch file1 1
}

# Setup repository, files & feature branch
# This step must be run if You want to test 2,3 or 4
# Order of 2,3,4 is not important, but 1 must be run before
# For example `-r 1,4` or `-r 1,4,2 -v` etc
# But not `-r 2` or `-r 4,3,2,1`
test_expect_success 'setup' '
	test_setup
'

# Test with --signoff flag
test_expect_success 'git merge --signoff adds a sign-off line' '
	git checkout master &&
	test_commit master-branch-2 file2 2 &&
	git checkout other-branch &&
	git merge master --signoff --no-edit &&
	git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
	test_cmp expected-signed actual
'

# Test without --signoff flag
test_expect_success 'git merge does not add a sign-off line' '
	git checkout master &&
	test_commit master-branch-3 file3 3 &&
	git checkout other-branch &&
	git merge master --no-edit &&
	git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
	test_cmp expected-unsigned actual
'

# Test for --no-signoff flag
test_expect_success 'git merge --no-signoff flag cancels --signoff flag' '
	git checkout master &&
	test_commit master-branch-4 file4 4 &&
	git checkout other-branch &&
	git merge master --no-edit --signoff --no-signoff &&
	git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
	test_cmp expected-unsigned actual
'

test_done