diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-09-09 14:50:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-09 14:50:41 -0700 |
commit | af226bf01e99043f5f3d8bc09ad302d17e0de757 (patch) | |
tree | f04089cfa49837b0e8dd86b5cc560bda262d08a0 | |
parent | Merge branch 'sp/clip-read-write-to-8mb' (diff) | |
parent | mailmap: handle mailmap blobs without trailing newlines (diff) | |
download | tgif-af226bf01e99043f5f3d8bc09ad302d17e0de757.tar.xz |
Merge branch 'jk/mailmap-incomplete-line'
* jk/mailmap-incomplete-line:
mailmap: handle mailmap blobs without trailing newlines
-rw-r--r-- | mailmap.c | 21 | ||||
-rwxr-xr-x | t/t4203-mailmap.sh | 16 |
2 files changed, 24 insertions, 13 deletions
@@ -193,20 +193,17 @@ static int read_mailmap_file(struct string_list *map, const char *filename, return 0; } -static void read_mailmap_buf(struct string_list *map, - const char *buf, unsigned long len, - char **repo_abbrev) +static void read_mailmap_string(struct string_list *map, char *buf, + char **repo_abbrev) { - while (len) { - const char *end = strchrnul(buf, '\n'); - unsigned long linelen = end - buf + 1; - char *line = xmemdupz(buf, linelen); + while (*buf) { + char *end = strchrnul(buf, '\n'); - read_mailmap_line(map, line, repo_abbrev); + if (*end) + *end++ = '\0'; - free(line); - buf += linelen; - len -= linelen; + read_mailmap_line(map, buf, repo_abbrev); + buf = end; } } @@ -230,7 +227,7 @@ static int read_mailmap_blob(struct string_list *map, if (type != OBJ_BLOB) 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); return 0; diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index baa4685dcc..ce3eace065 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -202,7 +202,8 @@ test_expect_success 'setup mailmap blob tests' ' Blob Guy <author@example.com> Blob Guy <bugs@company.xx> 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" && echo "Repo Guy <author@example.com>" >.mailmap && 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' ' rm -f .mailmap ' |