From: Junio C Hamano Date: Wed, 19 Aug 2015 21:48:54 +0000 (-0700) Subject: Merge branch 'jk/guess-repo-name-regression-fix' X-Git-Tag: v2.6.0-rc0~60 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8259da5ea3d993aa8b783a5039f5a78d86312c65?ds=inline;hp=-c Merge branch 'jk/guess-repo-name-regression-fix' "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 --- 8259da5ea3d993aa8b783a5039f5a78d86312c65 diff --combined builtin/clone.c index 303a3a7eb6,ed484cb6f4..bf451995a3 --- 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); @@@ -484,26 -484,16 +485,26 @@@ static void write_remote_refs(const str { const struct ref *r; - lock_packed_refs(LOCK_DIE_ON_ERROR); + struct ref_transaction *t; + struct strbuf err = STRBUF_INIT; + + t = ref_transaction_begin(&err); + if (!t) + die("%s", err.buf); for (r = local_refs; r; r = r->next) { if (!r->peer_ref) continue; - add_packed_ref(r->peer_ref->name, r->old_sha1); + if (ref_transaction_create(t, r->peer_ref->name, r->old_sha1, + 0, NULL, &err)) + die("%s", err.buf); } - if (commit_packed_refs()) - die_errno("unable to overwrite old ref-pack file"); + if (initial_ref_transaction_commit(t, &err)) + die("%s", err.buf); + + strbuf_release(&err); + ref_transaction_free(t); } static void write_followtags(const struct ref *refs, const char *msg)