summaryrefslogtreecommitdiff
path: root/t/t7517-per-repo-email.sh
diff options
context:
space:
mode:
authorDan Aloni <alonid@gmail.com>2016-02-06 06:23:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-08 19:06:28 (GMT)
commit4d5c2956969a6690db2bbb2f3ff40459c09d7646 (patch)
tree947e1240cdd91641779bd739abd626954c11f4fa /t/t7517-per-repo-email.sh
parent59f929596b611d88270ac0fd3ea132b32d66d460 (diff)
downloadgit-4d5c2956969a6690db2bbb2f3ff40459c09d7646.zip
git-4d5c2956969a6690db2bbb2f3ff40459c09d7646.tar.gz
git-4d5c2956969a6690db2bbb2f3ff40459c09d7646.tar.bz2
ident: add user.useConfigOnly boolean for when ident shouldn't be guessed
It used to be that: git config --global user.email "(none)" was a viable way for people to force themselves to set user.email in each repository. This was helpful for people with more than one email address, targeting different email addresses for different clones, as it barred git from creating a commit unless the user.email config was set in the per-repo config to the correct email address. A recent change, 19ce497c (ident: keep a flag for bogus default_email, 2015-12-10), however, declared that an explicitly configured user.email is not bogus, no matter what its value is, so this hack no longer works. Provide the same functionality by adding a new configuration variable user.useConfigOnly; when this variable is set, the user must explicitly set user.email configuration. Signed-off-by: Junio C Hamano <gitster@pobox.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Dan Aloni <alonid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7517-per-repo-email.sh')
-rwxr-xr-xt/t7517-per-repo-email.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/t7517-per-repo-email.sh b/t/t7517-per-repo-email.sh
new file mode 100755
index 0000000..337e6e3
--- /dev/null
+++ b/t/t7517-per-repo-email.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Copyright (c) 2016 Dan Aloni
+# Copyright (c) 2016 Jeff King
+#
+
+test_description='per-repo forced setting of email address'
+
+. ./test-lib.sh
+
+test_expect_success 'setup a likely user.useConfigOnly use case' '
+ # we want to make sure a reflog is written, since that needs
+ # a non-strict ident. So be sure we have an actual commit.
+ test_commit foo &&
+
+ sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
+ sane_unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL &&
+ git config user.name "test" &&
+ git config --global user.useConfigOnly true
+'
+
+test_expect_success 'fails committing if clone email is not set' '
+ test_must_fail git commit --allow-empty -m msg
+'
+
+test_expect_success 'fails committing if clone email is not set, but EMAIL set' '
+ test_must_fail env EMAIL=test@fail.com git commit --allow-empty -m msg
+'
+
+test_expect_success 'succeeds committing if clone email is set' '
+ test_config user.email "test@ok.com" &&
+ git commit --allow-empty -m msg
+'
+
+test_expect_success 'succeeds cloning if global email is not set' '
+ git clone . clone
+'
+
+test_done