summaryrefslogtreecommitdiff
path: root/mailmap.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-01-12 20:18:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-12 22:04:42 (GMT)
commit4e168333a8716d902aed10c74ae5e408e683f902 (patch)
tree483cda75b58639cefccf9aebf8fc5d17cd6677bc /mailmap.c
parent238803cb409930a9cbbe911917b28817d182330e (diff)
downloadgit-4e168333a8716d902aed10c74ae5e408e683f902.zip
git-4e168333a8716d902aed10c74ae5e408e683f902.tar.gz
git-4e168333a8716d902aed10c74ae5e408e683f902.tar.bz2
shortlog: remove unused(?) "repo-abbrev" feature
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. 7595e2ee6ef (git-shortlog: make common repository prefix configurable with .mailmap, 2006-11-25) 2. fa375c7f1b6 (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>
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/mailmap.c b/mailmap.c
index 962fd86..eb77c6e 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -143,31 +143,13 @@ static char *parse_name_and_email(char *buffer, char **name,
return (*right == '\0' ? NULL : right);
}
-static void read_mailmap_line(struct string_list *map, char *buffer,
- char **repo_abbrev)
+static void read_mailmap_line(struct string_list *map, char *buffer)
{
char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
- if (buffer[0] == '#') {
- static const char abbrev[] = "# repo-abbrev:";
- int abblen = sizeof(abbrev) - 1;
- int len = strlen(buffer);
- if (!repo_abbrev)
- return;
-
- if (len && buffer[len - 1] == '\n')
- buffer[--len] = 0;
- if (!strncmp(buffer, abbrev, abblen)) {
- char *cp;
-
- free(*repo_abbrev);
-
- for (cp = buffer + abblen; isspace(*cp); cp++)
- ; /* nothing */
- *repo_abbrev = xstrdup(cp);
- }
+ if (buffer[0] == '#')
return;
- }
+
if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
parse_name_and_email(name2, &name2, &email2, 1);
@@ -175,8 +157,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer,
add_mapping(map, name1, email1, name2, email2);
}
-static int read_mailmap_file(struct string_list *map, const char *filename,
- char **repo_abbrev)
+static int read_mailmap_file(struct string_list *map, const char *filename)
{
char buffer[1024];
FILE *f;
@@ -192,13 +173,12 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
}
while (fgets(buffer, sizeof(buffer), f) != NULL)
- read_mailmap_line(map, buffer, repo_abbrev);
+ read_mailmap_line(map, buffer);
fclose(f);
return 0;
}
-static void read_mailmap_string(struct string_list *map, char *buf,
- char **repo_abbrev)
+static void read_mailmap_string(struct string_list *map, char *buf)
{
while (*buf) {
char *end = strchrnul(buf, '\n');
@@ -206,14 +186,12 @@ static void read_mailmap_string(struct string_list *map, char *buf,
if (*end)
*end++ = '\0';
- read_mailmap_line(map, buf, repo_abbrev);
+ read_mailmap_line(map, buf);
buf = end;
}
}
-static int read_mailmap_blob(struct string_list *map,
- const char *name,
- char **repo_abbrev)
+static int read_mailmap_blob(struct string_list *map, const char *name)
{
struct object_id oid;
char *buf;
@@ -231,13 +209,13 @@ static int read_mailmap_blob(struct string_list *map,
if (type != OBJ_BLOB)
return error("mailmap is not a blob: %s", name);
- read_mailmap_string(map, buf, repo_abbrev);
+ read_mailmap_string(map, buf);
free(buf);
return 0;
}
-int read_mailmap(struct string_list *map, char **repo_abbrev)
+int read_mailmap(struct string_list *map)
{
int err = 0;
@@ -247,10 +225,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
if (!git_mailmap_blob && is_bare_repository())
git_mailmap_blob = "HEAD:.mailmap";
- err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
+ err |= read_mailmap_file(map, ".mailmap");
if (startup_info->have_repository)
- err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
- err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
+ err |= read_mailmap_blob(map, git_mailmap_blob);
+ err |= read_mailmap_file(map, git_mailmap_file);
return err;
}