Merge branch 'master' of https://github.com/Softcatala/git-po
[git/debian.git] / t / t3428-rebase-signoff.sh
blobf6993b7e14d91617b337bfaefa717ec8591fb28f
1 #!/bin/sh
3 test_description='git rebase --signoff
5 This test runs git rebase --signoff and make sure that it works.
8 . ./test-lib.sh
10 # A simple file to commit
11 cat >file <<EOF
13 EOF
15 # Expected commit message for initial commit after rebase --signoff
16 cat >expected-initial-signed <<EOF
17 Initial empty commit
19 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
20 EOF
22 # Expected commit message after rebase --signoff
23 cat >expected-signed <<EOF
24 first
26 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
27 EOF
29 # Expected commit message after rebase without --signoff (or with --no-signoff)
30 cat >expected-unsigned <<EOF
31 first
32 EOF
35 # We configure an alias to do the rebase --signoff so that
36 # on the next subtest we can show that --no-signoff overrides the alias
37 test_expect_success 'rebase --signoff adds a sign-off line' '
38 git commit --allow-empty -m "Initial empty commit" &&
39 git add file && git commit -m first &&
40 git config alias.rbs "rebase --signoff" &&
41 git rbs HEAD^ &&
42 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
43 test_cmp expected-signed actual
46 test_expect_success 'rebase --no-signoff does not add a sign-off line' '
47 git commit --amend -m "first" &&
48 git rbs --no-signoff HEAD^ &&
49 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
50 test_cmp expected-unsigned actual
53 test_expect_success 'rebase --exec --signoff adds a sign-off line' '
54 test_when_finished "rm exec" &&
55 git commit --amend -m "first" &&
56 git rebase --exec "touch exec" --signoff HEAD^ &&
57 test_path_is_file exec &&
58 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
59 test_cmp expected-signed actual
62 test_expect_success 'rebase --root --signoff adds a sign-off line' '
63 git commit --amend -m "first" &&
64 git rebase --root --keep-empty --signoff &&
65 git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual &&
66 test_cmp expected-initial-signed actual &&
67 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
68 test_cmp expected-signed actual
71 test_expect_success 'rebase -i --signoff fails' '
72 git commit --amend -m "first" &&
73 git rebase -i --signoff HEAD^ &&
74 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
75 test_cmp expected-signed actual
78 test_expect_success 'rebase -m --signoff fails' '
79 git commit --amend -m "first" &&
80 git rebase -m --signoff HEAD^ &&
81 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
82 test_cmp expected-signed actual
84 test_done