Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7517-per-repo-email.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7517-per-repo-email.sh` 152 lines ยท 5419 bytes Raw Blame History 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 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 11 12 . ./test-lib.sh 13 14 test_expect_success 'setup a likely user.useConfigOnly use case' ' 15 # we want to make sure a reflog is written, since that needs 16 # a non-strict ident. So be sure we have an actual commit. 17 test_commit foo && 18 19 sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && 20 sane_unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL && 21 git config user.name "test" && 22 git config --global user.useConfigOnly true 23 ' 24 25 test_expect_success 'fails committing if clone email is not set' ' 26 test_must_fail git commit --allow-empty -m msg 27 ' 28 29 test_expect_success 'fails committing if clone email is not set, but EMAIL set' ' 30 test_must_fail env EMAIL=test@fail.com git commit --allow-empty -m msg 31 ' 32 33 test_expect_success 'succeeds committing if clone email is set' ' 34 test_config user.email "test@ok.com" && 35 git commit --allow-empty -m msg 36 ' 37 38 test_expect_success 'succeeds cloning if global email is not set' ' 39 git clone . clone 40 ' 41 42 test_expect_success 'set up rebase scenarios' ' 43 # temporarily enable an actual ident for this setup 44 test_config user.email foo@example.com && 45 test_commit new && 46 git branch side-without-commit HEAD^ && 47 git checkout -b side-with-commit HEAD^ && 48 test_commit side 49 ' 50 51 test_expect_success 'fast-forward rebase does not care about ident' ' 52 git checkout -B tmp side-without-commit && 53 git rebase main 54 ' 55 56 test_expect_success 'non-fast-forward rebase refuses to write commits' ' 57 test_when_finished "git rebase --abort || true" && 58 git checkout -B tmp side-with-commit && 59 test_must_fail git rebase main 60 ' 61 62 test_expect_success 'fast-forward rebase does not care about ident (interactive)' ' 63 git checkout -B tmp side-without-commit && 64 git rebase -i main 65 ' 66 67 test_expect_success 'non-fast-forward rebase refuses to write commits (interactive)' ' 68 test_when_finished "git rebase --abort || true" && 69 git checkout -B tmp side-with-commit && 70 test_must_fail git rebase -i main 71 ' 72 73 test_expect_success 'noop interactive rebase does not care about ident' ' 74 git checkout -B tmp side-with-commit && 75 git rebase -i HEAD^ 76 ' 77 78 test_expect_success 'author.name overrides user.name' ' 79 test_config user.name user && 80 test_config user.email user@example.com && 81 test_config author.name author && 82 test_commit author-name-override-user && 83 echo author user@example.com > expected-author && 84 echo user user@example.com > expected-committer && 85 git log --format="%an %ae" -1 > actual-author && 86 git log --format="%cn %ce" -1 > actual-committer && 87 test_cmp expected-author actual-author && 88 test_cmp expected-committer actual-committer 89 ' 90 91 test_expect_success 'author.email overrides user.email' ' 92 test_config user.name user && 93 test_config user.email user@example.com && 94 test_config author.email author@example.com && 95 test_commit author-email-override-user && 96 echo user author@example.com > expected-author && 97 echo user user@example.com > expected-committer && 98 git log --format="%an %ae" -1 > actual-author && 99 git log --format="%cn %ce" -1 > actual-committer && 100 test_cmp expected-author actual-author && 101 test_cmp expected-committer actual-committer 102 ' 103 104 test_expect_success 'committer.name overrides user.name' ' 105 test_config user.name user && 106 test_config user.email user@example.com && 107 test_config committer.name committer && 108 test_commit committer-name-override-user && 109 echo user user@example.com > expected-author && 110 echo committer user@example.com > expected-committer && 111 git log --format="%an %ae" -1 > actual-author && 112 git log --format="%cn %ce" -1 > actual-committer && 113 test_cmp expected-author actual-author && 114 test_cmp expected-committer actual-committer 115 ' 116 117 test_expect_success 'committer.email overrides user.email' ' 118 test_config user.name user && 119 test_config user.email user@example.com && 120 test_config committer.email committer@example.com && 121 test_commit committer-email-override-user && 122 echo user user@example.com > expected-author && 123 echo user committer@example.com > expected-committer && 124 git log --format="%an %ae" -1 > actual-author && 125 git log --format="%cn %ce" -1 > actual-committer && 126 test_cmp expected-author actual-author && 127 test_cmp expected-committer actual-committer 128 ' 129 130 test_expect_success 'author and committer environment variables override config settings' ' 131 test_config user.name user && 132 test_config user.email user@example.com && 133 test_config author.name author && 134 test_config author.email author@example.com && 135 test_config committer.name committer && 136 test_config committer.email committer@example.com && 137 GIT_AUTHOR_NAME=env_author && export GIT_AUTHOR_NAME && 138 GIT_AUTHOR_EMAIL=env_author@example.com && export GIT_AUTHOR_EMAIL && 139 GIT_COMMITTER_NAME=env_commit && export GIT_COMMITTER_NAME && 140 GIT_COMMITTER_EMAIL=env_commit@example.com && export GIT_COMMITTER_EMAIL && 141 test_commit env-override-conf && 142 echo env_author env_author@example.com > expected-author && 143 echo env_commit env_commit@example.com > expected-committer && 144 git log --format="%an %ae" -1 > actual-author && 145 git log --format="%cn %ce" -1 > actual-committer && 146 sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && 147 sane_unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL && 148 test_cmp expected-author actual-author && 149 test_cmp expected-committer actual-committer 150 ' 151 152 test_done