]>
Commit | Line | Data |
---|---|---|
4d5c2956 DA |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2016 Dan Aloni | |
4 | # Copyright (c) 2016 Jeff King | |
5 | # | |
6 | ||
7 | test_description='per-repo forced setting of email address' | |
8 | ||
9 | . ./test-lib.sh | |
10 | ||
11 | test_expect_success 'setup a likely user.useConfigOnly use case' ' | |
12 | # we want to make sure a reflog is written, since that needs | |
13 | # a non-strict ident. So be sure we have an actual commit. | |
14 | test_commit foo && | |
15 | ||
16 | sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && | |
17 | sane_unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL && | |
18 | git config user.name "test" && | |
19 | git config --global user.useConfigOnly true | |
20 | ' | |
21 | ||
22 | test_expect_success 'fails committing if clone email is not set' ' | |
23 | test_must_fail git commit --allow-empty -m msg | |
24 | ' | |
25 | ||
26 | test_expect_success 'fails committing if clone email is not set, but EMAIL set' ' | |
27 | test_must_fail env EMAIL=test@fail.com git commit --allow-empty -m msg | |
28 | ' | |
29 | ||
30 | test_expect_success 'succeeds committing if clone email is set' ' | |
31 | test_config user.email "test@ok.com" && | |
32 | git commit --allow-empty -m msg | |
33 | ' | |
34 | ||
35 | test_expect_success 'succeeds cloning if global email is not set' ' | |
36 | git clone . clone | |
37 | ' | |
38 | ||
1e461c4f JK |
39 | test_expect_success 'set up rebase scenarios' ' |
40 | # temporarily enable an actual ident for this setup | |
41 | test_config user.email foo@example.com && | |
42 | test_commit new && | |
43 | git branch side-without-commit HEAD^ && | |
44 | git checkout -b side-with-commit HEAD^ && | |
45 | test_commit side | |
46 | ' | |
47 | ||
48 | test_expect_success 'fast-forward rebase does not care about ident' ' | |
49 | git checkout -B tmp side-without-commit && | |
50 | git rebase master | |
51 | ' | |
52 | ||
53 | test_expect_success 'non-fast-forward rebase refuses to write commits' ' | |
54 | test_when_finished "git rebase --abort || true" && | |
55 | git checkout -B tmp side-with-commit && | |
56 | test_must_fail git rebase master | |
57 | ' | |
58 | ||
59 | test_expect_success 'fast-forward rebase does not care about ident (interactive)' ' | |
60 | git checkout -B tmp side-without-commit && | |
61 | git rebase -i master | |
62 | ' | |
63 | ||
64 | test_expect_success 'non-fast-forward rebase refuses to write commits (interactive)' ' | |
65 | test_when_finished "git rebase --abort || true" && | |
66 | git checkout -B tmp side-with-commit && | |
67 | test_must_fail git rebase -i master | |
68 | ' | |
69 | ||
70 | test_expect_success 'noop interactive rebase does not care about ident' ' | |
71 | git checkout -B tmp side-with-commit && | |
72 | git rebase -i HEAD^ | |
73 | ' | |
74 | ||
75 | test_expect_success 'fast-forward rebase does not care about ident (preserve)' ' | |
76 | git checkout -B tmp side-without-commit && | |
77 | git rebase -p master | |
78 | ' | |
79 | ||
80 | test_expect_success 'non-fast-forward rebase refuses to write commits (preserve)' ' | |
81 | test_when_finished "git rebase --abort || true" && | |
82 | git checkout -B tmp side-with-commit && | |
83 | test_must_fail git rebase -p master | |
84 | ' | |
85 | ||
4d5c2956 | 86 | test_done |