mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
Merge branch 'ap/commit-author-mailmap' into maint
* ap/commit-author-mailmap: commit: search author pattern against mailmap
This commit is contained in:
commit
87b24a42ea
|
@ -30,6 +30,7 @@
|
||||||
#include "column.h"
|
#include "column.h"
|
||||||
#include "sequencer.h"
|
#include "sequencer.h"
|
||||||
#include "notes-utils.h"
|
#include "notes-utils.h"
|
||||||
|
#include "mailmap.h"
|
||||||
|
|
||||||
static const char * const builtin_commit_usage[] = {
|
static const char * const builtin_commit_usage[] = {
|
||||||
N_("git commit [options] [--] <pathspec>..."),
|
N_("git commit [options] [--] <pathspec>..."),
|
||||||
|
@ -935,6 +936,7 @@ static const char *find_author_by_nickname(const char *name)
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
struct string_list mailmap = STRING_LIST_INIT_NODUP;
|
||||||
const char *av[20];
|
const char *av[20];
|
||||||
int ac = 0;
|
int ac = 0;
|
||||||
|
|
||||||
|
@ -945,13 +947,17 @@ static const char *find_author_by_nickname(const char *name)
|
||||||
av[++ac] = buf.buf;
|
av[++ac] = buf.buf;
|
||||||
av[++ac] = NULL;
|
av[++ac] = NULL;
|
||||||
setup_revisions(ac, av, &revs, NULL);
|
setup_revisions(ac, av, &revs, NULL);
|
||||||
|
revs.mailmap = &mailmap;
|
||||||
|
read_mailmap(revs.mailmap, NULL);
|
||||||
|
|
||||||
prepare_revision_walk(&revs);
|
prepare_revision_walk(&revs);
|
||||||
commit = get_revision(&revs);
|
commit = get_revision(&revs);
|
||||||
if (commit) {
|
if (commit) {
|
||||||
struct pretty_print_context ctx = {0};
|
struct pretty_print_context ctx = {0};
|
||||||
ctx.date_mode = DATE_NORMAL;
|
ctx.date_mode = DATE_NORMAL;
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
format_commit_message(commit, "%an <%ae>", &buf, &ctx);
|
format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
|
||||||
|
clear_mailmap(&mailmap);
|
||||||
return strbuf_detach(&buf, NULL);
|
return strbuf_detach(&buf, NULL);
|
||||||
}
|
}
|
||||||
die(_("No existing author found with '%s'"), name);
|
die(_("No existing author found with '%s'"), name);
|
||||||
|
|
|
@ -484,4 +484,15 @@ test_expect_success 'Blame output (complex mapping)' '
|
||||||
test_cmp expect actual.fuzz
|
test_cmp expect actual.fuzz
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >expect <<\EOF
|
||||||
|
Some Dude <some@dude.xx>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'commit --author honors mailmap' '
|
||||||
|
test_must_fail git commit --author "nick" --allow-empty -meight &&
|
||||||
|
git commit --author "Some Dude" --allow-empty -meight &&
|
||||||
|
git show --pretty=format:"%an <%ae>%n" >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue