зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/mailmap-incomplete-line' into maint
* jk/mailmap-incomplete-line: mailmap: handle mailmap blobs without trailing newlines
This commit is contained in:
Коммит
19230ab8a8
21
mailmap.c
21
mailmap.c
|
@ -193,20 +193,17 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_mailmap_buf(struct string_list *map,
|
static void read_mailmap_string(struct string_list *map, char *buf,
|
||||||
const char *buf, unsigned long len,
|
char **repo_abbrev)
|
||||||
char **repo_abbrev)
|
|
||||||
{
|
{
|
||||||
while (len) {
|
while (*buf) {
|
||||||
const char *end = strchrnul(buf, '\n');
|
char *end = strchrnul(buf, '\n');
|
||||||
unsigned long linelen = end - buf + 1;
|
|
||||||
char *line = xmemdupz(buf, linelen);
|
|
||||||
|
|
||||||
read_mailmap_line(map, line, repo_abbrev);
|
if (*end)
|
||||||
|
*end++ = '\0';
|
||||||
|
|
||||||
free(line);
|
read_mailmap_line(map, buf, repo_abbrev);
|
||||||
buf += linelen;
|
buf = end;
|
||||||
len -= linelen;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +227,7 @@ static int read_mailmap_blob(struct string_list *map,
|
||||||
if (type != OBJ_BLOB)
|
if (type != OBJ_BLOB)
|
||||||
return error("mailmap is not a blob: %s", name);
|
return error("mailmap is not a blob: %s", name);
|
||||||
|
|
||||||
read_mailmap_buf(map, buf, size, repo_abbrev);
|
read_mailmap_string(map, buf, repo_abbrev);
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -202,7 +202,8 @@ test_expect_success 'setup mailmap blob tests' '
|
||||||
Blob Guy <author@example.com>
|
Blob Guy <author@example.com>
|
||||||
Blob Guy <bugs@company.xx>
|
Blob Guy <bugs@company.xx>
|
||||||
EOF
|
EOF
|
||||||
git add just-bugs both &&
|
printf "Tricky Guy <author@example.com>" >no-newline &&
|
||||||
|
git add just-bugs both no-newline &&
|
||||||
git commit -m "my mailmaps" &&
|
git commit -m "my mailmaps" &&
|
||||||
echo "Repo Guy <author@example.com>" >.mailmap &&
|
echo "Repo Guy <author@example.com>" >.mailmap &&
|
||||||
echo "Internal Guy <author@example.com>" >internal.map
|
echo "Internal Guy <author@example.com>" >internal.map
|
||||||
|
@ -286,6 +287,19 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'mailmap.blob can handle blobs without trailing newline' '
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
Tricky Guy (1):
|
||||||
|
initial
|
||||||
|
|
||||||
|
nick1 (1):
|
||||||
|
second
|
||||||
|
|
||||||
|
EOF
|
||||||
|
git -c mailmap.blob=map:no-newline shortlog HEAD >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'cleanup after mailmap.blob tests' '
|
test_expect_success 'cleanup after mailmap.blob tests' '
|
||||||
rm -f .mailmap
|
rm -f .mailmap
|
||||||
'
|
'
|
||||||
|
|
Загрузка…
Ссылка в новой задаче