Merge branch 'jk/guess-repo-name-regression-fix'
[gitweb.git] / builtin / clone.c
index a72ff7e0098da9c89f6000e724ea097e3403601f..bf451995a3c7bc3d8bd322c1a3355d8dc3dd80fa 100644 (file)
@@ -174,7 +174,8 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
        /*
         * 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);
@@ -484,16 +485,26 @@ static void write_remote_refs(const struct ref *local_refs)
 {
        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)