mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
4d5c295696
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>
39 lines
1 KiB
Bash
Executable file
39 lines
1 KiB
Bash
Executable file
#!/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
|