]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3428-rebase-signoff.sh
Merge branch 'jk/fsck-indices-in-worktrees'
[thirdparty/git.git] / t / t3428-rebase-signoff.sh
CommitLineData
9f79524a
GB
1#!/bin/sh
2
3test_description='git rebase --signoff
4
5This test runs git rebase --signoff and make sure that it works.
6'
7
b6046abc 8TEST_PASSES_SANITIZE_LEAK=true
9f79524a
GB
9. ./test-lib.sh
10
11# A simple file to commit
12cat >file <<EOF
13a
14EOF
15
a852ec7f
PW
16# Expected commit message for initial commit after rebase --signoff
17cat >expected-initial-signed <<EOF
18Initial empty commit
19
20Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
21EOF
22
9f79524a
GB
23# Expected commit message after rebase --signoff
24cat >expected-signed <<EOF
25first
26
27Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
28EOF
29
30# Expected commit message after rebase without --signoff (or with --no-signoff)
31cat >expected-unsigned <<EOF
32first
33EOF
34
35
36# We configure an alias to do the rebase --signoff so that
37# on the next subtest we can show that --no-signoff overrides the alias
38test_expect_success 'rebase --signoff adds a sign-off line' '
39 git commit --allow-empty -m "Initial empty commit" &&
40 git add file && git commit -m first &&
41 git config alias.rbs "rebase --signoff" &&
42 git rbs HEAD^ &&
43 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
44 test_cmp expected-signed actual
45'
46
47test_expect_success 'rebase --no-signoff does not add a sign-off line' '
48 git commit --amend -m "first" &&
49 git rbs --no-signoff HEAD^ &&
50 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
51 test_cmp expected-unsigned actual
52'
53
a852ec7f
PW
54test_expect_success 'rebase --exec --signoff adds a sign-off line' '
55 test_when_finished "rm exec" &&
56 git commit --amend -m "first" &&
57 git rebase --exec "touch exec" --signoff HEAD^ &&
58 test_path_is_file exec &&
59 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
60 test_cmp expected-signed actual
61'
62
63test_expect_success 'rebase --root --signoff adds a sign-off line' '
64 git commit --amend -m "first" &&
65 git rebase --root --keep-empty --signoff &&
66 git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual &&
67 test_cmp expected-initial-signed actual &&
68 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
69 test_cmp expected-signed actual
70'
71
72test_expect_success 'rebase -i --signoff fails' '
73 git commit --amend -m "first" &&
74 git rebase -i --signoff HEAD^ &&
75 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
76 test_cmp expected-signed actual
77'
78
79test_expect_success 'rebase -m --signoff fails' '
80 git commit --amend -m "first" &&
81 git rebase -m --signoff HEAD^ &&
82 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
83 test_cmp expected-signed actual
84'
9f79524a 85test_done