Skip to content

Commit c95044d

Browse files
author
Junio C Hamano
committed
git-shortlog: fix common repository prefix abbreviation.
The code to abbreviate the common repository prefix was totally borked. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent ac60c94 commit c95044d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

builtin-shortlog.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,17 @@ static void insert_author_oneline(struct path_list *list,
130130
memcpy(buffer, oneline, onelinelen);
131131
buffer[onelinelen] = '\0';
132132

133-
while ((p = strstr(buffer, dot3)) != NULL) {
134-
memcpy(p, "...", 3);
135-
strcpy(p + 2, p + sizeof(dot3) - 1);
133+
if (dot3) {
134+
int dot3len = strlen(dot3);
135+
if (dot3len > 5) {
136+
while ((p = strstr(buffer, dot3)) != NULL) {
137+
int taillen = strlen(p) - dot3len;
138+
memcpy(p, "/.../", 5);
139+
memmove(p + 5, p + dot3len, taillen + 1);
140+
}
141+
}
136142
}
137143

138-
139144
onelines = item->util;
140145
if (onelines->nr >= onelines->alloc) {
141146
onelines->alloc = alloc_nr(onelines->nr);

0 commit comments

Comments
 (0)