Skip to content

Commit 4e16833

Browse files
avargitster
authored andcommitted
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 [email protected]: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. 7595e2e (git-shortlog: make common repository prefix configurable with .mailmap, 2006-11-25) 2. fa375c7 (Add git-shortlog perl script, 2005-06-04) 3. https://lore.kernel.org/lkml/ 4. https://lore.kernel.org/lkml/[email protected]/ 5. https://lore.kernel.org/lkml/[email protected]/ 6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/ Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 238803c commit 4e16833

File tree

9 files changed

+21
-56
lines changed

9 files changed

+21
-56
lines changed

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
11511151
sb.xdl_opts = xdl_opts;
11521152
sb.no_whole_file_rename = no_whole_file_rename;
11531153

1154-
read_mailmap(&mailmap, NULL);
1154+
read_mailmap(&mailmap);
11551155

11561156
sb.found_guilty_entry = &found_guilty_entry;
11571157
sb.found_guilty_entry_data = &pi;

builtin/check-mailmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
4747
if (argc == 0 && !use_stdin)
4848
die(_("no contacts specified"));
4949

50-
read_mailmap(&mailmap, NULL);
50+
read_mailmap(&mailmap);
5151

5252
for (i = 0; i < argc; ++i)
5353
check_mailmap(&mailmap, argv[i]);

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ static const char *find_author_by_nickname(const char *name)
10391039
av[++ac] = NULL;
10401040
setup_revisions(ac, av, &revs, NULL);
10411041
revs.mailmap = &mailmap;
1042-
read_mailmap(revs.mailmap, NULL);
1042+
read_mailmap(revs.mailmap);
10431043

10441044
if (prepare_revision_walk(&revs))
10451045
die(_("revision walk setup failed"));

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
230230

231231
if (mailmap) {
232232
rev->mailmap = xcalloc(1, sizeof(struct string_list));
233-
read_mailmap(rev->mailmap, NULL);
233+
read_mailmap(rev->mailmap);
234234
}
235235

236236
if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {

builtin/shortlog.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ static void insert_one_record(struct shortlog *log,
6161
if (log->summary)
6262
item->util = (void *)(UTIL_TO_INT(item) + 1);
6363
else {
64-
const char *dot3 = log->common_repo_prefix;
65-
char *buffer, *p;
64+
char *buffer;
6665
struct strbuf subject = STRBUF_INIT;
6766
const char *eol;
6867

@@ -82,17 +81,6 @@ static void insert_one_record(struct shortlog *log,
8281
format_subject(&subject, oneline, " ");
8382
buffer = strbuf_detach(&subject, NULL);
8483

85-
if (dot3) {
86-
int dot3len = strlen(dot3);
87-
if (dot3len > 5) {
88-
while ((p = strstr(buffer, dot3)) != NULL) {
89-
int taillen = strlen(p) - dot3len;
90-
memcpy(p, "/.../", 5);
91-
memmove(p + 5, p + dot3len, taillen + 1);
92-
}
93-
}
94-
}
95-
9684
if (item->util == NULL)
9785
item->util = xcalloc(1, sizeof(struct string_list));
9886
string_list_append(item->util, buffer);
@@ -342,7 +330,7 @@ void shortlog_init(struct shortlog *log)
342330
{
343331
memset(log, 0, sizeof(*log));
344332

345-
read_mailmap(&log->mailmap, &log->common_repo_prefix);
333+
read_mailmap(&log->mailmap);
346334

347335
log->list.strdup_strings = 1;
348336
log->wrap = DEFAULT_WRAPLEN;

mailmap.c

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -143,40 +143,21 @@ static char *parse_name_and_email(char *buffer, char **name,
143143
return (*right == '\0' ? NULL : right);
144144
}
145145

146-
static void read_mailmap_line(struct string_list *map, char *buffer,
147-
char **repo_abbrev)
146+
static void read_mailmap_line(struct string_list *map, char *buffer)
148147
{
149148
char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
150-
if (buffer[0] == '#') {
151-
static const char abbrev[] = "# repo-abbrev:";
152-
int abblen = sizeof(abbrev) - 1;
153-
int len = strlen(buffer);
154149

155-
if (!repo_abbrev)
156-
return;
157-
158-
if (len && buffer[len - 1] == '\n')
159-
buffer[--len] = 0;
160-
if (!strncmp(buffer, abbrev, abblen)) {
161-
char *cp;
162-
163-
free(*repo_abbrev);
164-
165-
for (cp = buffer + abblen; isspace(*cp); cp++)
166-
; /* nothing */
167-
*repo_abbrev = xstrdup(cp);
168-
}
150+
if (buffer[0] == '#')
169151
return;
170-
}
152+
171153
if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
172154
parse_name_and_email(name2, &name2, &email2, 1);
173155

174156
if (email1)
175157
add_mapping(map, name1, email1, name2, email2);
176158
}
177159

178-
static int read_mailmap_file(struct string_list *map, const char *filename,
179-
char **repo_abbrev)
160+
static int read_mailmap_file(struct string_list *map, const char *filename)
180161
{
181162
char buffer[1024];
182163
FILE *f;
@@ -192,28 +173,25 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
192173
}
193174

194175
while (fgets(buffer, sizeof(buffer), f) != NULL)
195-
read_mailmap_line(map, buffer, repo_abbrev);
176+
read_mailmap_line(map, buffer);
196177
fclose(f);
197178
return 0;
198179
}
199180

200-
static void read_mailmap_string(struct string_list *map, char *buf,
201-
char **repo_abbrev)
181+
static void read_mailmap_string(struct string_list *map, char *buf)
202182
{
203183
while (*buf) {
204184
char *end = strchrnul(buf, '\n');
205185

206186
if (*end)
207187
*end++ = '\0';
208188

209-
read_mailmap_line(map, buf, repo_abbrev);
189+
read_mailmap_line(map, buf);
210190
buf = end;
211191
}
212192
}
213193

214-
static int read_mailmap_blob(struct string_list *map,
215-
const char *name,
216-
char **repo_abbrev)
194+
static int read_mailmap_blob(struct string_list *map, const char *name)
217195
{
218196
struct object_id oid;
219197
char *buf;
@@ -231,13 +209,13 @@ static int read_mailmap_blob(struct string_list *map,
231209
if (type != OBJ_BLOB)
232210
return error("mailmap is not a blob: %s", name);
233211

234-
read_mailmap_string(map, buf, repo_abbrev);
212+
read_mailmap_string(map, buf);
235213

236214
free(buf);
237215
return 0;
238216
}
239217

240-
int read_mailmap(struct string_list *map, char **repo_abbrev)
218+
int read_mailmap(struct string_list *map)
241219
{
242220
int err = 0;
243221

@@ -247,10 +225,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
247225
if (!git_mailmap_blob && is_bare_repository())
248226
git_mailmap_blob = "HEAD:.mailmap";
249227

250-
err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
228+
err |= read_mailmap_file(map, ".mailmap");
251229
if (startup_info->have_repository)
252-
err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
253-
err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
230+
err |= read_mailmap_blob(map, git_mailmap_blob);
231+
err |= read_mailmap_file(map, git_mailmap_file);
254232
return err;
255233
}
256234

mailmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
struct string_list;
55

6-
int read_mailmap(struct string_list *map, char **repo_abbrev);
6+
int read_mailmap(struct string_list *map);
77
void clear_mailmap(struct string_list *map);
88

99
int map_user(struct string_list *map,

pretty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static int mailmap_name(const char **email, size_t *email_len,
679679
static struct string_list *mail_map;
680680
if (!mail_map) {
681681
mail_map = xcalloc(1, sizeof(*mail_map));
682-
read_mailmap(mail_map, NULL);
682+
read_mailmap(mail_map);
683683
}
684684
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
685685
}

shortlog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct shortlog {
2323
} groups;
2424
struct string_list trailers;
2525

26-
char *common_repo_prefix;
2726
int email;
2827
struct string_list mailmap;
2928
FILE *file;

0 commit comments

Comments
 (0)