Code

unpack-trees: fix path search bug in verify_absent
[git.git] / builtin-clone.c
index ecdcefa2a6901a8c8eb0902845e40fea216d7249..c0e3086437ced05d1b81d4098e3a4c7c3031b0ee 100644 (file)
@@ -95,7 +95,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)
        return NULL;
 }
 
-static char *guess_dir_name(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;
 
@@ -131,6 +131,12 @@ static char *guess_dir_name(const char *repo, int is_bundle)
                        end -= 4;
        }
 
+       if (is_bare) {
+               char *result = xmalloc(end - start + 5);
+               sprintf(result, "%.*s.git", (int)(end - start), start);
+               return result;
+       }
+
        return xstrndup(start, end - start);
 }
 
@@ -324,7 +330,8 @@ static struct ref *write_remote_refs(const struct ref *refs,
        struct ref *r;
 
        get_fetch_map(refs, refspec, &tail, 0);
-       get_fetch_map(refs, tag_refspec, &tail, 0);
+       if (!option_mirror)
+               get_fetch_map(refs, tag_refspec, &tail, 0);
 
        for (r = local_refs; r; r = r->next)
                add_extra_ref(r->peer_ref->name, r->old_sha1, 0);
@@ -389,7 +396,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (argc == 2)
                dir = xstrdup(argv[1]);
        else
-               dir = guess_dir_name(repo_name, is_bundle);
+               dir = guess_dir_name(repo_name, is_bundle, option_bare);
 
        if (!stat(dir, &buf))
                die("destination directory '%s' already exists.", dir);