Merge branch 'mj/log-show-signature-conf'
"git log" learns log.showSignature configuration variable, and a command line option "--no-show-signature" to countermand it. * mj/log-show-signature-conf: log: add log.showSignature configuration variable log: add "--no-show-signature" command line option t4202: refactor test
This commit is contained in:
commit
369dc4081c
@ -198,6 +198,10 @@ log.showRoot::
|
||||
`git log -p` output would be shown without a diff attached.
|
||||
The default is `true`.
|
||||
|
||||
log.showSignature::
|
||||
If `true`, `git log` and related commands will act as if the
|
||||
`--show-signature` option was passed to them.
|
||||
|
||||
mailmap.*::
|
||||
See linkgit:git-shortlog[1].
|
||||
|
||||
|
@ -33,6 +33,7 @@ static const char *default_date_mode = NULL;
|
||||
static int default_abbrev_commit;
|
||||
static int default_show_root = 1;
|
||||
static int default_follow;
|
||||
static int default_show_signature;
|
||||
static int decoration_style;
|
||||
static int decoration_given;
|
||||
static int use_mailmap_config;
|
||||
@ -119,6 +120,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
|
||||
rev->abbrev_commit = default_abbrev_commit;
|
||||
rev->show_root_diff = default_show_root;
|
||||
rev->subject_prefix = fmt_patch_subject_prefix;
|
||||
rev->show_signature = default_show_signature;
|
||||
DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
|
||||
|
||||
if (default_date_mode)
|
||||
@ -409,6 +411,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
|
||||
use_mailmap_config = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "log.showsignature")) {
|
||||
default_show_signature = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grep_config(var, value, cb) < 0)
|
||||
return -1;
|
||||
|
@ -1871,6 +1871,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
|
||||
revs->notes_opt.use_default_notes = 1;
|
||||
} else if (!strcmp(arg, "--show-signature")) {
|
||||
revs->show_signature = 1;
|
||||
} else if (!strcmp(arg, "--no-show-signature")) {
|
||||
revs->show_signature = 0;
|
||||
} else if (!strcmp(arg, "--show-linear-break") ||
|
||||
starts_with(arg, "--show-linear-break=")) {
|
||||
if (starts_with(arg, "--show-linear-break="))
|
||||
|
@ -860,12 +860,15 @@ test_expect_success 'dotdot is a parent directory' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success GPG 'log --graph --show-signature' '
|
||||
test_expect_success GPG 'setup signed branch' '
|
||||
test_when_finished "git reset --hard && git checkout master" &&
|
||||
git checkout -b signed master &&
|
||||
echo foo >foo &&
|
||||
git add foo &&
|
||||
git commit -S -m signed_commit &&
|
||||
git commit -S -m signed_commit
|
||||
'
|
||||
|
||||
test_expect_success GPG 'log --graph --show-signature' '
|
||||
git log --graph --show-signature -n1 signed >actual &&
|
||||
grep "^| gpg: Signature made" actual &&
|
||||
grep "^| gpg: Good signature" actual
|
||||
@ -890,6 +893,31 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
|
||||
grep "^| | gpg: Good signature" actual
|
||||
'
|
||||
|
||||
test_expect_success GPG '--no-show-signature overrides --show-signature' '
|
||||
git log -1 --show-signature --no-show-signature signed >actual &&
|
||||
! grep "^gpg:" actual
|
||||
'
|
||||
|
||||
test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
|
||||
test_config log.showsignature true &&
|
||||
git log -1 signed >actual &&
|
||||
grep "gpg: Signature made" actual &&
|
||||
grep "gpg: Good signature" actual
|
||||
'
|
||||
|
||||
test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
|
||||
test_config log.showsignature true &&
|
||||
git log -1 --no-show-signature signed >actual &&
|
||||
! grep "^gpg:" actual
|
||||
'
|
||||
|
||||
test_expect_success GPG '--show-signature overrides log.showsignature=false' '
|
||||
test_config log.showsignature false &&
|
||||
git log -1 --show-signature signed >actual &&
|
||||
grep "gpg: Signature made" actual &&
|
||||
grep "gpg: Good signature" actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --graph --no-walk is forbidden' '
|
||||
test_must_fail git log --graph --no-walk
|
||||
'
|
||||
|
@ -210,4 +210,11 @@ test_expect_success GPG 'show lack of signature with custom format' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success GPG 'log.showsignature behaves like --show-signature' '
|
||||
test_config log.showsignature true &&
|
||||
git show initial >actual &&
|
||||
grep "gpg: Signature made" actual &&
|
||||
grep "gpg: Good signature" actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user