From: Junio C Hamano Date: Tue, 25 Aug 2015 23:09:17 +0000 (-0700) Subject: Merge branch 'jk/guess-repo-name-regression-fix' into maint X-Git-Tag: v2.5.1~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/52f6893d356fd04ba350e5b7dd468b2181844521?ds=inline;hp=-c Merge branch 'jk/guess-repo-name-regression-fix' into maint "git clone $URL" in recent releases of Git contains a regression in the code that invents a new repository name incorrectly based on the $URL. This has been corrected. * jk/guess-repo-name-regression-fix: clone: use computed length in guess_dir_name clone: add tests for output directory --- 52f6893d356fd04ba350e5b7dd468b2181844521 diff --combined builtin/clone.c index a72ff7e009,ed484cb6f4..53cf545c5e --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -174,7 -174,8 +174,8 @@@ static char *guess_dir_name(const char /* * Strip .{bundle,git}. */ - strip_suffix(start, is_bundle ? ".bundle" : ".git" , &len); + len = end - start; + strip_suffix_mem(start, &len, is_bundle ? ".bundle" : ".git"); if (is_bare) dir = xstrfmt("%.*s.git", (int)len, start); @@@ -277,17 -278,16 +278,17 @@@ static void copy_alternates(struct strb struct strbuf line = STRBUF_INIT; while (strbuf_getline(&line, in, '\n') != EOF) { - char *abs_path, abs_buf[PATH_MAX]; + char *abs_path; if (!line.len || line.buf[0] == '#') continue; if (is_absolute_path(line.buf)) { add_to_alternates_file(line.buf); continue; } - abs_path = mkpath("%s/objects/%s", src_repo, line.buf); - normalize_path_copy(abs_buf, abs_path); - add_to_alternates_file(abs_buf); + abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf); + normalize_path_copy(abs_path, abs_path); + add_to_alternates_file(abs_path); + free(abs_path); } strbuf_release(&line); fclose(in);