|
|
@ -208,7 +208,7 @@ static void setup_reference(const char *repo) |
|
|
|
if (is_directory(mkpath("%s/.git/objects", ref_git))) |
|
|
|
if (is_directory(mkpath("%s/.git/objects", ref_git))) |
|
|
|
ref_git = mkpath("%s/.git", ref_git); |
|
|
|
ref_git = mkpath("%s/.git", ref_git); |
|
|
|
else if (!is_directory(mkpath("%s/objects", ref_git))) |
|
|
|
else if (!is_directory(mkpath("%s/objects", ref_git))) |
|
|
|
die("reference repository '%s' is not a local directory.", |
|
|
|
die(_("reference repository '%s' is not a local directory."), |
|
|
|
option_reference); |
|
|
|
option_reference); |
|
|
|
|
|
|
|
|
|
|
|
ref_git_copy = xstrdup(ref_git); |
|
|
|
ref_git_copy = xstrdup(ref_git); |
|
|
@ -235,15 +235,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest) |
|
|
|
|
|
|
|
|
|
|
|
dir = opendir(src->buf); |
|
|
|
dir = opendir(src->buf); |
|
|
|
if (!dir) |
|
|
|
if (!dir) |
|
|
|
die_errno("failed to open '%s'", src->buf); |
|
|
|
die_errno(_("failed to open '%s'"), src->buf); |
|
|
|
|
|
|
|
|
|
|
|
if (mkdir(dest->buf, 0777)) { |
|
|
|
if (mkdir(dest->buf, 0777)) { |
|
|
|
if (errno != EEXIST) |
|
|
|
if (errno != EEXIST) |
|
|
|
die_errno("failed to create directory '%s'", dest->buf); |
|
|
|
die_errno(_("failed to create directory '%s'"), dest->buf); |
|
|
|
else if (stat(dest->buf, &buf)) |
|
|
|
else if (stat(dest->buf, &buf)) |
|
|
|
die_errno("failed to stat '%s'", dest->buf); |
|
|
|
die_errno(_("failed to stat '%s'"), dest->buf); |
|
|
|
else if (!S_ISDIR(buf.st_mode)) |
|
|
|
else if (!S_ISDIR(buf.st_mode)) |
|
|
|
die("%s exists and is not a directory", dest->buf); |
|
|
|
die(_("%s exists and is not a directory"), dest->buf); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
strbuf_addch(src, '/'); |
|
|
|
strbuf_addch(src, '/'); |
|
|
@ -257,7 +257,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest) |
|
|
|
strbuf_setlen(dest, dest_len); |
|
|
|
strbuf_setlen(dest, dest_len); |
|
|
|
strbuf_addstr(dest, de->d_name); |
|
|
|
strbuf_addstr(dest, de->d_name); |
|
|
|
if (stat(src->buf, &buf)) { |
|
|
|
if (stat(src->buf, &buf)) { |
|
|
|
warning ("failed to stat %s\n", src->buf); |
|
|
|
warning (_("failed to stat %s\n"), src->buf); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (S_ISDIR(buf.st_mode)) { |
|
|
|
if (S_ISDIR(buf.st_mode)) { |
|
|
@ -267,16 +267,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (unlink(dest->buf) && errno != ENOENT) |
|
|
|
if (unlink(dest->buf) && errno != ENOENT) |
|
|
|
die_errno("failed to unlink '%s'", dest->buf); |
|
|
|
die_errno(_("failed to unlink '%s'"), dest->buf); |
|
|
|
if (!option_no_hardlinks) { |
|
|
|
if (!option_no_hardlinks) { |
|
|
|
if (!link(src->buf, dest->buf)) |
|
|
|
if (!link(src->buf, dest->buf)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (option_local) |
|
|
|
if (option_local) |
|
|
|
die_errno("failed to create link '%s'", dest->buf); |
|
|
|
die_errno(_("failed to create link '%s'"), dest->buf); |
|
|
|
option_no_hardlinks = 1; |
|
|
|
option_no_hardlinks = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (copy_file_with_time(dest->buf, src->buf, 0666)) |
|
|
|
if (copy_file_with_time(dest->buf, src->buf, 0666)) |
|
|
|
die_errno("failed to copy file to '%s'", dest->buf); |
|
|
|
die_errno(_("failed to copy file to '%s'"), dest->buf); |
|
|
|
} |
|
|
|
} |
|
|
|
closedir(dir); |
|
|
|
closedir(dir); |
|
|
|
} |
|
|
|
} |
|
|
@ -305,7 +305,7 @@ static const struct ref *clone_local(const char *src_repo, |
|
|
|
ret = transport_get_remote_refs(transport); |
|
|
|
ret = transport_get_remote_refs(transport); |
|
|
|
transport_disconnect(transport); |
|
|
|
transport_disconnect(transport); |
|
|
|
if (0 <= option_verbosity) |
|
|
|
if (0 <= option_verbosity) |
|
|
|
printf("done.\n"); |
|
|
|
printf(_("done.\n")); |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -387,11 +387,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
builtin_clone_usage, 0); |
|
|
|
builtin_clone_usage, 0); |
|
|
|
|
|
|
|
|
|
|
|
if (argc > 2) |
|
|
|
if (argc > 2) |
|
|
|
usage_msg_opt("Too many arguments.", |
|
|
|
usage_msg_opt(_("Too many arguments."), |
|
|
|
builtin_clone_usage, builtin_clone_options); |
|
|
|
builtin_clone_usage, builtin_clone_options); |
|
|
|
|
|
|
|
|
|
|
|
if (argc == 0) |
|
|
|
if (argc == 0) |
|
|
|
usage_msg_opt("You must specify a repository to clone.", |
|
|
|
usage_msg_opt(_("You must specify a repository to clone."), |
|
|
|
builtin_clone_usage, builtin_clone_options); |
|
|
|
builtin_clone_usage, builtin_clone_options); |
|
|
|
|
|
|
|
|
|
|
|
if (option_mirror) |
|
|
|
if (option_mirror) |
|
|
@ -399,7 +399,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
|
|
|
|
|
|
|
|
if (option_bare) { |
|
|
|
if (option_bare) { |
|
|
|
if (option_origin) |
|
|
|
if (option_origin) |
|
|
|
die("--bare and --origin %s options are incompatible.", |
|
|
|
die(_("--bare and --origin %s options are incompatible."), |
|
|
|
option_origin); |
|
|
|
option_origin); |
|
|
|
option_no_checkout = 1; |
|
|
|
option_no_checkout = 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -418,7 +418,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
repo = repo_name; |
|
|
|
repo = repo_name; |
|
|
|
is_local = path && !is_bundle; |
|
|
|
is_local = path && !is_bundle; |
|
|
|
if (is_local && option_depth) |
|
|
|
if (is_local && option_depth) |
|
|
|
warning("--depth is ignored in local clones; use file:// instead."); |
|
|
|
warning(_("--depth is ignored in local clones; use file:// instead.")); |
|
|
|
|
|
|
|
|
|
|
|
if (argc == 2) |
|
|
|
if (argc == 2) |
|
|
|
dir = xstrdup(argv[1]); |
|
|
|
dir = xstrdup(argv[1]); |
|
|
@ -428,8 +428,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
|
|
|
|
|
|
|
|
dest_exists = !stat(dir, &buf); |
|
|
|
dest_exists = !stat(dir, &buf); |
|
|
|
if (dest_exists && !is_empty_dir(dir)) |
|
|
|
if (dest_exists && !is_empty_dir(dir)) |
|
|
|
die("destination path '%s' already exists and is not " |
|
|
|
die(_("destination path '%s' already exists and is not " |
|
|
|
"an empty directory.", dir); |
|
|
|
"an empty directory."), dir); |
|
|
|
|
|
|
|
|
|
|
|
strbuf_addf(&reflog_msg, "clone: from %s", repo); |
|
|
|
strbuf_addf(&reflog_msg, "clone: from %s", repo); |
|
|
|
|
|
|
|
|
|
|
@ -438,7 +438,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
else { |
|
|
|
else { |
|
|
|
work_tree = getenv("GIT_WORK_TREE"); |
|
|
|
work_tree = getenv("GIT_WORK_TREE"); |
|
|
|
if (work_tree && !stat(work_tree, &buf)) |
|
|
|
if (work_tree && !stat(work_tree, &buf)) |
|
|
|
die("working tree '%s' already exists.", work_tree); |
|
|
|
die(_("working tree '%s' already exists."), work_tree); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (option_bare || work_tree) |
|
|
|
if (option_bare || work_tree) |
|
|
@ -451,10 +451,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
if (!option_bare) { |
|
|
|
if (!option_bare) { |
|
|
|
junk_work_tree = work_tree; |
|
|
|
junk_work_tree = work_tree; |
|
|
|
if (safe_create_leading_directories_const(work_tree) < 0) |
|
|
|
if (safe_create_leading_directories_const(work_tree) < 0) |
|
|
|
die_errno("could not create leading directories of '%s'", |
|
|
|
die_errno(_("could not create leading directories of '%s'"), |
|
|
|
work_tree); |
|
|
|
work_tree); |
|
|
|
if (!dest_exists && mkdir(work_tree, 0755)) |
|
|
|
if (!dest_exists && mkdir(work_tree, 0755)) |
|
|
|
die_errno("could not create work tree dir '%s'.", |
|
|
|
die_errno(_("could not create work tree dir '%s'."), |
|
|
|
work_tree); |
|
|
|
work_tree); |
|
|
|
set_git_work_tree(work_tree); |
|
|
|
set_git_work_tree(work_tree); |
|
|
|
} |
|
|
|
} |
|
|
@ -465,7 +465,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1); |
|
|
|
setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1); |
|
|
|
|
|
|
|
|
|
|
|
if (safe_create_leading_directories_const(git_dir) < 0) |
|
|
|
if (safe_create_leading_directories_const(git_dir) < 0) |
|
|
|
die("could not create leading directories of '%s'", git_dir); |
|
|
|
die(_("could not create leading directories of '%s'"), git_dir); |
|
|
|
set_git_dir(make_absolute_path(git_dir)); |
|
|
|
set_git_dir(make_absolute_path(git_dir)); |
|
|
|
|
|
|
|
|
|
|
|
if (0 <= option_verbosity) |
|
|
|
if (0 <= option_verbosity) |
|
|
@ -527,7 +527,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
transport = transport_get(remote, remote->url[0]); |
|
|
|
transport = transport_get(remote, remote->url[0]); |
|
|
|
|
|
|
|
|
|
|
|
if (!transport->get_refs_list || !transport->fetch) |
|
|
|
if (!transport->get_refs_list || !transport->fetch) |
|
|
|
die("Don't know how to clone %s", transport->url); |
|
|
|
die(_("Don't know how to clone %s"), transport->url); |
|
|
|
|
|
|
|
|
|
|
|
transport_set_option(transport, TRANS_OPT_KEEP, "yes"); |
|
|
|
transport_set_option(transport, TRANS_OPT_KEEP, "yes"); |
|
|
|
|
|
|
|
|
|
|
@ -566,8 +566,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
strbuf_release(&head); |
|
|
|
strbuf_release(&head); |
|
|
|
|
|
|
|
|
|
|
|
if (!our_head_points_at) { |
|
|
|
if (!our_head_points_at) { |
|
|
|
warning("Remote branch %s not found in " |
|
|
|
warning(_("Remote branch %s not found in " |
|
|
|
"upstream %s, using HEAD instead", |
|
|
|
"upstream %s, using HEAD instead"), |
|
|
|
option_branch, option_origin); |
|
|
|
option_branch, option_origin); |
|
|
|
our_head_points_at = remote_head_points_at; |
|
|
|
our_head_points_at = remote_head_points_at; |
|
|
|
} |
|
|
|
} |
|
|
@ -576,7 +576,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
our_head_points_at = remote_head_points_at; |
|
|
|
our_head_points_at = remote_head_points_at; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
warning("You appear to have cloned an empty repository."); |
|
|
|
warning(_("You appear to have cloned an empty repository.")); |
|
|
|
our_head_points_at = NULL; |
|
|
|
our_head_points_at = NULL; |
|
|
|
remote_head_points_at = NULL; |
|
|
|
remote_head_points_at = NULL; |
|
|
|
remote_head = NULL; |
|
|
|
remote_head = NULL; |
|
|
@ -618,8 +618,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* Nothing to checkout out */ |
|
|
|
/* Nothing to checkout out */ |
|
|
|
if (!option_no_checkout) |
|
|
|
if (!option_no_checkout) |
|
|
|
warning("remote HEAD refers to nonexistent ref, " |
|
|
|
warning(_("remote HEAD refers to nonexistent ref, " |
|
|
|
"unable to checkout.\n"); |
|
|
|
"unable to checkout.\n")); |
|
|
|
option_no_checkout = 1; |
|
|
|
option_no_checkout = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -655,7 +655,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) |
|
|
|
|
|
|
|
|
|
|
|
if (write_cache(fd, active_cache, active_nr) || |
|
|
|
if (write_cache(fd, active_cache, active_nr) || |
|
|
|
commit_locked_index(lock_file)) |
|
|
|
commit_locked_index(lock_file)) |
|
|
|
die("unable to write new index file"); |
|
|
|
die(_("unable to write new index file")); |
|
|
|
|
|
|
|
|
|
|
|
err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1), |
|
|
|
err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1), |
|
|
|
sha1_to_hex(our_head_points_at->old_sha1), "1", |
|
|
|
sha1_to_hex(our_head_points_at->old_sha1), "1", |
|
|
|