4e168333a8
Remove support for the magical "repo-abbrev" comment in .mailmap files. This was added to .mailmap parsing in [1], as a generalized feature of the git-shortlog Perl script added earlier in [2]. There was no documentation or tests for this feature, and I don't think it's used in practice anymore. What it did was to allow you to specify a single string to be search-replaced with "/.../" in the .mailmap file. E.g. for linux.git's current .mailmap: git archive --remote=git@gitlab.com:linux-kernel/linux.git \ HEAD -- .mailmap | grep -a repo-abbrev # repo-abbrev: /pub/scm/linux/kernel/git/ Then when running e.g.: git shortlog --merges --author=Linus -1 v5.10-rc7..v5.10 | grep Merge We'd emit (the [...] is mine): Merge tag [...]git://git.kernel.org/.../tip/tip But will now emit: Merge tag [...]git.kernel.org/pub/scm/linux/kernel/git/tip/tip I think at this point this is just a historical artifact we can get rid of. It was initially meant for Linus's own use when we integrated the Perl script[2], but since then it seems he's stopped using it. Digging through Linus's release announcements on the LKML[3] the last release I can find that made use of this output is Linux 2.6.25-rc6 back in March 2008[4]. Later on Linus started using --no-merges[5], and nowadays seems to prefer some custom not-quite-shortlog format of merges from lieutenants[6]. You will still see it on linux.git if you run "git shortlog" manually yourself with --merges, with this removed you can still get the same output with: git log --pretty=fuller v5.10-rc7..v5.10 | sed 's!/pub/scm/linux/kernel/git/!/.../!g' | git shortlog Arguably we should do the same for the search-replacing of "[PATCH]" at the beginning with "". That seems to be another relic of a bygone era when linux.git patches would have their E-Mail subject lines applied as-is by "git am" or whatever. But we documented that feature in "git-shortlog(1)", and it seems more widely applicable than something purely kernel-specific. 1.7595e2ee6e
(git-shortlog: make common repository prefix configurable with .mailmap, 2006-11-25) 2.fa375c7f1b
(Add git-shortlog perl script, 2005-06-04) 3. https://lore.kernel.org/lkml/ 4. https://lore.kernel.org/lkml/alpine.LFD.1.00.0803161651350.3020@woody.linux-foundation.org/ 5. https://lore.kernel.org/lkml/BANLkTinrbh7Xi27an3uY7pDWrNKhJRYmEA@mail.gmail.com/ 6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/ Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
#include "builtin.h"
|
|
#include "config.h"
|
|
#include "mailmap.h"
|
|
#include "parse-options.h"
|
|
#include "string-list.h"
|
|
|
|
static int use_stdin;
|
|
static const char * const check_mailmap_usage[] = {
|
|
N_("git check-mailmap [<options>] <contact>..."),
|
|
NULL
|
|
};
|
|
|
|
static const struct option check_mailmap_options[] = {
|
|
OPT_BOOL(0, "stdin", &use_stdin, N_("also read contacts from stdin")),
|
|
OPT_END()
|
|
};
|
|
|
|
static void check_mailmap(struct string_list *mailmap, const char *contact)
|
|
{
|
|
const char *name, *mail;
|
|
size_t namelen, maillen;
|
|
struct ident_split ident;
|
|
|
|
if (split_ident_line(&ident, contact, strlen(contact)))
|
|
die(_("unable to parse contact: %s"), contact);
|
|
|
|
name = ident.name_begin;
|
|
namelen = ident.name_end - ident.name_begin;
|
|
mail = ident.mail_begin;
|
|
maillen = ident.mail_end - ident.mail_begin;
|
|
|
|
map_user(mailmap, &mail, &maillen, &name, &namelen);
|
|
|
|
if (namelen)
|
|
printf("%.*s ", (int)namelen, name);
|
|
printf("<%.*s>\n", (int)maillen, mail);
|
|
}
|
|
|
|
int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
|
|
{
|
|
int i;
|
|
struct string_list mailmap = STRING_LIST_INIT_NODUP;
|
|
|
|
git_config(git_default_config, NULL);
|
|
argc = parse_options(argc, argv, prefix, check_mailmap_options,
|
|
check_mailmap_usage, 0);
|
|
if (argc == 0 && !use_stdin)
|
|
die(_("no contacts specified"));
|
|
|
|
read_mailmap(&mailmap);
|
|
|
|
for (i = 0; i < argc; ++i)
|
|
check_mailmap(&mailmap, argv[i]);
|
|
maybe_flush_or_die(stdout, "stdout");
|
|
|
|
if (use_stdin) {
|
|
struct strbuf buf = STRBUF_INIT;
|
|
while (strbuf_getline_lf(&buf, stdin) != EOF) {
|
|
check_mailmap(&mailmap, buf.buf);
|
|
maybe_flush_or_die(stdout, "stdout");
|
|
}
|
|
strbuf_release(&buf);
|
|
}
|
|
|
|
clear_mailmap(&mailmap);
|
|
return 0;
|
|
}
|