diff --git a/builtin-clone.c b/builtin-clone.c
index 8713128e72da5681104434f944defb7f373db7e8..4a0f1ab8ac427e91f4efa1fa43c95a30ca256f11 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
#include "transport.h"
#include "strbuf.h"
#include "dir.h"
+#include "pack-refs.h"
/*
* Overall FIXMEs:
path = mkpath("%s%s", repo, suffix[i]);
if (!stat(path, &st) && S_ISDIR(st.st_mode)) {
*is_bundle = 0;
- return xstrdup(make_absolute_path(path));
+ return xstrdup(make_nonrelative_path(path));
}
}
path = mkpath("%s%s", repo, bundle_suffix[i]);
if (!stat(path, &st) && S_ISREG(st.st_mode)) {
*is_bundle = 1;
- return xstrdup(make_absolute_path(path));
+ return xstrdup(make_nonrelative_path(path));
}
}
if (unlink(dest) && errno != ENOENT)
die("failed to unlink %s\n", dest);
- if (option_no_hardlinks) {
- if (copy_file(dest, src, 0666))
- die("failed to copy file to %s\n", dest);
- } else {
- if (link(src, dest))
+ if (!option_no_hardlinks) {
+ if (!link(src, dest))
+ continue;
+ if (option_local)
die("failed to create link %s\n", dest);
+ option_no_hardlinks = 1;
}
+ if (copy_file(dest, src, 0666))
+ die("failed to copy file to %s\n", dest);
}
+ closedir(dir);
}
static const struct ref *clone_local(const char *src_repo,
get_fetch_map(refs, tag_refspec, &tail, 0);
for (r = local_refs; r; r = r->next)
- update_ref(reflog,
- r->peer_ref->name, r->old_sha1, NULL, 0, DIE_ON_ERR);
+ add_extra_ref(r->peer_ref->name, r->old_sha1, 0);
+
+ pack_refs(PACK_REFS_ALL);
+ clear_extra_refs();
+
return local_refs;
}
if (!option_bare) {
junk_work_tree = work_tree;
+ if (safe_create_leading_directories_const(work_tree) < 0)
+ die("could not create leading directories of '%s'",
+ work_tree);
if (mkdir(work_tree, 0755))
die("could not create work tree dir '%s'.", work_tree);
set_git_work_tree(work_tree);
setenv(CONFIG_ENVIRONMENT, xstrdup(mkpath("%s/config", git_dir)), 1);
+ if (safe_create_leading_directories_const(git_dir) < 0)
+ die("could not create leading directories of '%s'", git_dir);
set_git_dir(make_absolute_path(git_dir));
- fprintf(stderr, "Initialize %s\n", git_dir);
init_db(option_template, option_quiet ? INIT_DB_QUIET : 0);
+ /*
+ * At this point, the config exists, so we do not need the
+ * environment variable. We actually need to unset it, too, to
+ * re-enable parsing of the global configs.
+ */
+ unsetenv(CONFIG_ENVIRONMENT);
+
if (option_reference)
setup_reference(git_dir);
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
if (option_bare) {
strcpy(branch_top, "refs/heads/");
refs = clone_local(path, git_dir);
else {
struct remote *remote = remote_get(argv[0]);
- struct transport *transport = transport_get(remote, argv[0]);
+ struct transport *transport =
+ transport_get(remote, remote->url[0]);
+
+ if (!transport->get_refs_list || !transport->fetch)
+ die("Don't know how to clone %s", transport->url);
transport_set_option(transport, TRANS_OPT_KEEP, "yes");