Skip to content

Commit 32716a2

Browse files
Miklos Vajnagitster
authored andcommitted
builtin-clone: use strbuf in guess_dir_name()
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6fc4a7e commit 32716a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin-clone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
134134
}
135135

136136
if (is_bare) {
137-
char *result = xmalloc(end - start + 5);
138-
sprintf(result, "%.*s.git", (int)(end - start), start);
139-
return result;
137+
struct strbuf result = STRBUF_INIT;
138+
strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
139+
return strbuf_detach(&result, 0);
140140
}
141141

142142
return xstrndup(start, end - start);

0 commit comments

Comments
 (0)