Signed-off-by: Sebastian Schuberth <sschuberth@xxxxxxxxx> --- builtin/clone.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index 00535d0..d35b2b9 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -147,6 +147,7 @@ static char *get_repo_path(const char *repo, int *is_bundle) static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) { const char *end = repo + strlen(repo), *start; + size_t len; char *dir; /* @@ -174,19 +175,17 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) * Strip .{bundle,git}. */ if (is_bundle) { - if (end - start > 7 && !strncmp(end - 7, ".bundle", 7)) - end -= 7; + strip_suffix(start, ".bundle", &len); } else { - if (end - start > 4 && !strncmp(end - 4, ".git", 4)) - end -= 4; + strip_suffix(start, ".git", &len); } if (is_bare) { struct strbuf result = STRBUF_INIT; - strbuf_addf(&result, "%.*s.git", (int)(end - start), start); + strbuf_addf(&result, "%.*s.git", len, start); dir = strbuf_detach(&result, NULL); } else - dir = xstrndup(start, end - start); + dir = xstrndup(start, len); /* * Replace sequences of 'control' characters and whitespace * with one ascii space, remove leading and trailing spaces. --- https://github.com/git/git/pull/160