From 81b50f3ce40bfdd66e5d967bf82be001039a9a98 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 22 Feb 2010 08:42:18 -0800 Subject: Move 'builtin-*' into a 'builtin/' subdirectory This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin/clone.c | 671 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 671 insertions(+) create mode 100644 builtin/clone.c (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c new file mode 100644 index 000000000..58bacbd55 --- /dev/null +++ b/builtin/clone.c @@ -0,0 +1,671 @@ +/* + * Builtin "git clone" + * + * Copyright (c) 2007 Kristian Høgsberg , + * 2008 Daniel Barkalow + * Based on git-commit.sh by Junio C Hamano and Linus Torvalds + * + * Clone a repository into a different directory that does not yet exist. + */ + +#include "cache.h" +#include "parse-options.h" +#include "fetch-pack.h" +#include "refs.h" +#include "tree.h" +#include "tree-walk.h" +#include "unpack-trees.h" +#include "transport.h" +#include "strbuf.h" +#include "dir.h" +#include "pack-refs.h" +#include "sigchain.h" +#include "branch.h" +#include "remote.h" +#include "run-command.h" + +/* + * Overall FIXMEs: + * - respect DB_ENVIRONMENT for .git/objects. + * + * Implementation notes: + * - dropping use-separate-remote and no-separate-remote compatibility + * + */ +static const char * const builtin_clone_usage[] = { + "git clone [options] [--] []", + NULL +}; + +static int option_quiet, option_no_checkout, option_bare, option_mirror; +static int option_local, option_no_hardlinks, option_shared, option_recursive; +static char *option_template, *option_reference, *option_depth; +static char *option_origin = NULL; +static char *option_branch = NULL; +static char *option_upload_pack = "git-upload-pack"; +static int option_verbose; +static int option_progress; + +static struct option builtin_clone_options[] = { + OPT__QUIET(&option_quiet), + OPT__VERBOSE(&option_verbose), + OPT_BOOLEAN(0, "progress", &option_progress, + "force progress reporting"), + OPT_BOOLEAN('n', "no-checkout", &option_no_checkout, + "don't create a checkout"), + OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"), + { OPTION_BOOLEAN, 0, "naked", &option_bare, NULL, + "create a bare repository", + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, + OPT_BOOLEAN(0, "mirror", &option_mirror, + "create a mirror repository (implies bare)"), + OPT_BOOLEAN('l', "local", &option_local, + "to clone from a local repository"), + OPT_BOOLEAN(0, "no-hardlinks", &option_no_hardlinks, + "don't use local hardlinks, always copy"), + OPT_BOOLEAN('s', "shared", &option_shared, + "setup as shared repository"), + OPT_BOOLEAN(0, "recursive", &option_recursive, + "initialize submodules in the clone"), + OPT_STRING(0, "template", &option_template, "path", + "path the template repository"), + OPT_STRING(0, "reference", &option_reference, "repo", + "reference repository"), + OPT_STRING('o', "origin", &option_origin, "branch", + "use instead of 'origin' to track upstream"), + OPT_STRING('b', "branch", &option_branch, "branch", + "checkout instead of the remote's HEAD"), + OPT_STRING('u', "upload-pack", &option_upload_pack, "path", + "path to git-upload-pack on the remote"), + OPT_STRING(0, "depth", &option_depth, "depth", + "create a shallow clone of that depth"), + + OPT_END() +}; + +static const char *argv_submodule[] = { + "submodule", "update", "--init", "--recursive", NULL +}; + +static char *get_repo_path(const char *repo, int *is_bundle) +{ + static char *suffix[] = { "/.git", ".git", "" }; + static char *bundle_suffix[] = { ".bundle", "" }; + struct stat st; + int i; + + for (i = 0; i < ARRAY_SIZE(suffix); i++) { + const char *path; + path = mkpath("%s%s", repo, suffix[i]); + if (is_directory(path)) { + *is_bundle = 0; + return xstrdup(make_nonrelative_path(path)); + } + } + + for (i = 0; i < ARRAY_SIZE(bundle_suffix); i++) { + const char *path; + path = mkpath("%s%s", repo, bundle_suffix[i]); + if (!stat(path, &st) && S_ISREG(st.st_mode)) { + *is_bundle = 1; + return xstrdup(make_nonrelative_path(path)); + } + } + + return NULL; +} + +static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) +{ + const char *end = repo + strlen(repo), *start; + char *dir; + + /* + * Strip trailing spaces, slashes and /.git + */ + while (repo < end && (is_dir_sep(end[-1]) || isspace(end[-1]))) + end--; + if (end - repo > 5 && is_dir_sep(end[-5]) && + !strncmp(end - 4, ".git", 4)) { + end -= 5; + while (repo < end && is_dir_sep(end[-1])) + end--; + } + + /* + * Find last component, but be prepared that repo could have + * the form "remote.example.com:foo.git", i.e. no slash + * in the directory part. + */ + start = end; + while (repo < start && !is_dir_sep(start[-1]) && start[-1] != ':') + start--; + + /* + * Strip .{bundle,git}. + */ + if (is_bundle) { + if (end - start > 7 && !strncmp(end - 7, ".bundle", 7)) + end -= 7; + } else { + if (end - start > 4 && !strncmp(end - 4, ".git", 4)) + end -= 4; + } + + if (is_bare) { + struct strbuf result = STRBUF_INIT; + strbuf_addf(&result, "%.*s.git", (int)(end - start), start); + dir = strbuf_detach(&result, NULL); + } else + dir = xstrndup(start, end - start); + /* + * Replace sequences of 'control' characters and whitespace + * with one ascii space, remove leading and trailing spaces. + */ + if (*dir) { + char *out = dir; + int prev_space = 1 /* strip leading whitespace */; + for (end = dir; *end; ++end) { + char ch = *end; + if ((unsigned char)ch < '\x20') + ch = '\x20'; + if (isspace(ch)) { + if (prev_space) + continue; + prev_space = 1; + } else + prev_space = 0; + *out++ = ch; + } + *out = '\0'; + if (out > dir && prev_space) + out[-1] = '\0'; + } + return dir; +} + +static void strip_trailing_slashes(char *dir) +{ + char *end = dir + strlen(dir); + + while (dir < end - 1 && is_dir_sep(end[-1])) + end--; + *end = '\0'; +} + +static void setup_reference(const char *repo) +{ + const char *ref_git; + char *ref_git_copy; + + struct remote *remote; + struct transport *transport; + const struct ref *extra; + + ref_git = make_absolute_path(option_reference); + + if (is_directory(mkpath("%s/.git/objects", ref_git))) + ref_git = mkpath("%s/.git", ref_git); + else if (!is_directory(mkpath("%s/objects", ref_git))) + die("reference repository '%s' is not a local directory.", + option_reference); + + ref_git_copy = xstrdup(ref_git); + + add_to_alternates_file(ref_git_copy); + + remote = remote_get(ref_git_copy); + transport = transport_get(remote, ref_git_copy); + for (extra = transport_get_remote_refs(transport); extra; + extra = extra->next) + add_extra_ref(extra->name, extra->old_sha1, 0); + + transport_disconnect(transport); + + free(ref_git_copy); +} + +static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest) +{ + struct dirent *de; + struct stat buf; + int src_len, dest_len; + DIR *dir; + + dir = opendir(src->buf); + if (!dir) + die_errno("failed to open '%s'", src->buf); + + if (mkdir(dest->buf, 0777)) { + if (errno != EEXIST) + die_errno("failed to create directory '%s'", dest->buf); + else if (stat(dest->buf, &buf)) + die_errno("failed to stat '%s'", dest->buf); + else if (!S_ISDIR(buf.st_mode)) + die("%s exists and is not a directory", dest->buf); + } + + strbuf_addch(src, '/'); + src_len = src->len; + strbuf_addch(dest, '/'); + dest_len = dest->len; + + while ((de = readdir(dir)) != NULL) { + strbuf_setlen(src, src_len); + strbuf_addstr(src, de->d_name); + strbuf_setlen(dest, dest_len); + strbuf_addstr(dest, de->d_name); + if (stat(src->buf, &buf)) { + warning ("failed to stat %s\n", src->buf); + continue; + } + if (S_ISDIR(buf.st_mode)) { + if (de->d_name[0] != '.') + copy_or_link_directory(src, dest); + continue; + } + + if (unlink(dest->buf) && errno != ENOENT) + die_errno("failed to unlink '%s'", dest->buf); + if (!option_no_hardlinks) { + if (!link(src->buf, dest->buf)) + continue; + if (option_local) + die_errno("failed to create link '%s'", dest->buf); + option_no_hardlinks = 1; + } + if (copy_file_with_time(dest->buf, src->buf, 0666)) + die_errno("failed to copy file to '%s'", dest->buf); + } + closedir(dir); +} + +static const struct ref *clone_local(const char *src_repo, + const char *dest_repo) +{ + const struct ref *ret; + struct strbuf src = STRBUF_INIT; + struct strbuf dest = STRBUF_INIT; + struct remote *remote; + struct transport *transport; + + if (option_shared) + add_to_alternates_file(src_repo); + else { + strbuf_addf(&src, "%s/objects", src_repo); + strbuf_addf(&dest, "%s/objects", dest_repo); + copy_or_link_directory(&src, &dest); + strbuf_release(&src); + strbuf_release(&dest); + } + + remote = remote_get(src_repo); + transport = transport_get(remote, src_repo); + ret = transport_get_remote_refs(transport); + transport_disconnect(transport); + return ret; +} + +static const char *junk_work_tree; +static const char *junk_git_dir; +static pid_t junk_pid; + +static void remove_junk(void) +{ + struct strbuf sb = STRBUF_INIT; + if (getpid() != junk_pid) + return; + if (junk_git_dir) { + strbuf_addstr(&sb, junk_git_dir); + remove_dir_recursively(&sb, 0); + strbuf_reset(&sb); + } + if (junk_work_tree) { + strbuf_addstr(&sb, junk_work_tree); + remove_dir_recursively(&sb, 0); + strbuf_reset(&sb); + } +} + +static void remove_junk_on_signal(int signo) +{ + remove_junk(); + sigchain_pop(signo); + raise(signo); +} + +static struct ref *wanted_peer_refs(const struct ref *refs, + struct refspec *refspec) +{ + struct ref *local_refs = NULL; + struct ref **tail = &local_refs; + + get_fetch_map(refs, refspec, &tail, 0); + if (!option_mirror) + get_fetch_map(refs, tag_refspec, &tail, 0); + + return local_refs; +} + +static void write_remote_refs(const struct ref *local_refs) +{ + const struct ref *r; + + for (r = local_refs; r; r = r->next) + add_extra_ref(r->peer_ref->name, r->old_sha1, 0); + + pack_refs(PACK_REFS_ALL); + clear_extra_refs(); +} + +int cmd_clone(int argc, const char **argv, const char *prefix) +{ + int is_bundle = 0; + struct stat buf; + const char *repo_name, *repo, *work_tree, *git_dir; + char *path, *dir; + int dest_exists; + const struct ref *refs, *remote_head; + const struct ref *remote_head_points_at; + const struct ref *our_head_points_at; + struct ref *mapped_refs; + struct strbuf key = STRBUF_INIT, value = STRBUF_INIT; + struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT; + struct transport *transport = NULL; + char *src_ref_prefix = "refs/heads/"; + int err = 0; + + struct refspec *refspec; + const char *fetch_pattern; + + junk_pid = getpid(); + + argc = parse_options(argc, argv, prefix, builtin_clone_options, + builtin_clone_usage, 0); + + if (argc > 2) + usage_msg_opt("Too many arguments.", + builtin_clone_usage, builtin_clone_options); + + if (argc == 0) + usage_msg_opt("You must specify a repository to clone.", + builtin_clone_usage, builtin_clone_options); + + if (option_mirror) + option_bare = 1; + + if (option_bare) { + if (option_origin) + die("--bare and --origin %s options are incompatible.", + option_origin); + option_no_checkout = 1; + } + + if (!option_origin) + option_origin = "origin"; + + repo_name = argv[0]; + + path = get_repo_path(repo_name, &is_bundle); + if (path) + repo = xstrdup(make_nonrelative_path(repo_name)); + else if (!strchr(repo_name, ':')) + repo = xstrdup(make_absolute_path(repo_name)); + else + repo = repo_name; + + if (argc == 2) + dir = xstrdup(argv[1]); + else + dir = guess_dir_name(repo_name, is_bundle, option_bare); + strip_trailing_slashes(dir); + + dest_exists = !stat(dir, &buf); + if (dest_exists && !is_empty_dir(dir)) + die("destination path '%s' already exists and is not " + "an empty directory.", dir); + + strbuf_addf(&reflog_msg, "clone: from %s", repo); + + if (option_bare) + work_tree = NULL; + else { + work_tree = getenv("GIT_WORK_TREE"); + if (work_tree && !stat(work_tree, &buf)) + die("working tree '%s' already exists.", work_tree); + } + + if (option_bare || work_tree) + git_dir = xstrdup(dir); + else { + work_tree = dir; + git_dir = xstrdup(mkpath("%s/.git", dir)); + } + + if (!option_bare) { + junk_work_tree = work_tree; + if (safe_create_leading_directories_const(work_tree) < 0) + die_errno("could not create leading directories of '%s'", + work_tree); + if (!dest_exists && mkdir(work_tree, 0755)) + die_errno("could not create work tree dir '%s'.", + work_tree); + set_git_work_tree(work_tree); + } + junk_git_dir = git_dir; + atexit(remove_junk); + sigchain_push_common(remove_junk_on_signal); + + setenv(CONFIG_ENVIRONMENT, 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)); + + 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, NULL); + + if (option_bare) { + if (option_mirror) + src_ref_prefix = "refs/"; + strbuf_addstr(&branch_top, src_ref_prefix); + + git_config_set("core.bare", "true"); + } else { + strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin); + } + + strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf); + + if (option_mirror || !option_bare) { + /* Configure the remote */ + strbuf_addf(&key, "remote.%s.fetch", option_origin); + git_config_set_multivar(key.buf, value.buf, "^$", 0); + strbuf_reset(&key); + + if (option_mirror) { + strbuf_addf(&key, "remote.%s.mirror", option_origin); + git_config_set(key.buf, "true"); + strbuf_reset(&key); + } + + strbuf_addf(&key, "remote.%s.url", option_origin); + git_config_set(key.buf, repo); + strbuf_reset(&key); + } + + fetch_pattern = value.buf; + refspec = parse_fetch_refspec(1, &fetch_pattern); + + strbuf_reset(&value); + + if (path && !is_bundle) { + refs = clone_local(path, git_dir); + mapped_refs = wanted_peer_refs(refs, refspec); + } else { + struct remote *remote = remote_get(argv[0]); + 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"); + + if (option_depth) + transport_set_option(transport, TRANS_OPT_DEPTH, + option_depth); + + if (option_quiet) + transport->verbose = -1; + else if (option_verbose) + transport->verbose = 1; + + if (option_progress) + transport->progress = 1; + + if (option_upload_pack) + transport_set_option(transport, TRANS_OPT_UPLOADPACK, + option_upload_pack); + + refs = transport_get_remote_refs(transport); + if (refs) { + mapped_refs = wanted_peer_refs(refs, refspec); + transport_fetch_refs(transport, mapped_refs); + } + } + + if (refs) { + clear_extra_refs(); + + write_remote_refs(mapped_refs); + + remote_head = find_ref_by_name(refs, "HEAD"); + remote_head_points_at = + guess_remote_head(remote_head, mapped_refs, 0); + + if (option_branch) { + struct strbuf head = STRBUF_INIT; + strbuf_addstr(&head, src_ref_prefix); + strbuf_addstr(&head, option_branch); + our_head_points_at = + find_ref_by_name(mapped_refs, head.buf); + strbuf_release(&head); + + if (!our_head_points_at) { + warning("Remote branch %s not found in " + "upstream %s, using HEAD instead", + option_branch, option_origin); + our_head_points_at = remote_head_points_at; + } + } + else + our_head_points_at = remote_head_points_at; + } + else { + warning("You appear to have cloned an empty repository."); + our_head_points_at = NULL; + remote_head_points_at = NULL; + remote_head = NULL; + option_no_checkout = 1; + if (!option_bare) + install_branch_config(0, "master", option_origin, + "refs/heads/master"); + } + + if (remote_head_points_at && !option_bare) { + struct strbuf head_ref = STRBUF_INIT; + strbuf_addstr(&head_ref, branch_top.buf); + strbuf_addstr(&head_ref, "HEAD"); + create_symref(head_ref.buf, + remote_head_points_at->peer_ref->name, + reflog_msg.buf); + } + + if (our_head_points_at) { + /* Local default branch link */ + create_symref("HEAD", our_head_points_at->name, NULL); + if (!option_bare) { + const char *head = skip_prefix(our_head_points_at->name, + "refs/heads/"); + update_ref(reflog_msg.buf, "HEAD", + our_head_points_at->old_sha1, + NULL, 0, DIE_ON_ERR); + install_branch_config(0, head, option_origin, + our_head_points_at->name); + } + } else if (remote_head) { + /* Source had detached HEAD pointing somewhere. */ + if (!option_bare) { + update_ref(reflog_msg.buf, "HEAD", + remote_head->old_sha1, + NULL, REF_NODEREF, DIE_ON_ERR); + our_head_points_at = remote_head; + } + } else { + /* Nothing to checkout out */ + if (!option_no_checkout) + warning("remote HEAD refers to nonexistent ref, " + "unable to checkout.\n"); + option_no_checkout = 1; + } + + if (transport) { + transport_unlock_pack(transport); + transport_disconnect(transport); + } + + if (!option_no_checkout) { + struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file)); + struct unpack_trees_options opts; + struct tree *tree; + struct tree_desc t; + int fd; + + /* We need to be in the new work tree for the checkout */ + setup_work_tree(); + + fd = hold_locked_index(lock_file, 1); + + memset(&opts, 0, sizeof opts); + opts.update = 1; + opts.merge = 1; + opts.fn = oneway_merge; + opts.verbose_update = !option_quiet; + opts.src_index = &the_index; + opts.dst_index = &the_index; + + tree = parse_tree_indirect(our_head_points_at->old_sha1); + parse_tree(tree); + init_tree_desc(&t, tree->buffer, tree->size); + unpack_trees(1, &t, &opts); + + if (write_cache(fd, active_cache, active_nr) || + commit_locked_index(lock_file)) + die("unable to write new index file"); + + err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1), + sha1_to_hex(our_head_points_at->old_sha1), "1", + NULL); + + if (!err && option_recursive) + err = run_command_v_opt(argv_submodule, RUN_GIT_CMD); + } + + strbuf_release(&reflog_msg); + strbuf_release(&branch_top); + strbuf_release(&key); + strbuf_release(&value); + junk_pid = 0; + return err; +} -- cgit v1.2.1 From 766ac6a6ba26b0d58c75234bb3553178eafa80b0 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Mon, 29 Mar 2010 11:48:23 -0500 Subject: clone: pass the remote name to remote_get Currently when using a remote helper to clone a repository, the remote helper will be passed the url of the target repository as first argument (which represents the name of the remote). This name is extracted from transport->remote->name, which is set by builtin/clone.c when it calls remote_get with argv[0] as argument. Fix this by passing the name remote will be set up as instead. However, setup_reference calls remote_get before the remote is added to the config file. This will result in an improperly configured remote (in memory) if later on remote_get is called with an argument that is not equal to the initial remote_get call in setup_reference. Fix this by delaying the remote_get call until after the remote has been added to the config file. Signed-off-by: Junio C Hamano --- builtin/clone.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 05f8fb477..068d61fd3 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -470,9 +470,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) */ unsetenv(CONFIG_ENVIRONMENT); - if (option_reference) - setup_reference(git_dir); - git_config(git_default_config, NULL); if (option_bare) { @@ -504,6 +501,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) strbuf_reset(&key); } + if (option_reference) + setup_reference(git_dir); + fetch_pattern = value.buf; refspec = parse_fetch_refspec(1, &fetch_pattern); @@ -513,7 +513,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) refs = clone_local(path, git_dir); mapped_refs = wanted_peer_refs(refs, refspec); } else { - struct remote *remote = remote_get(argv[0]); + struct remote *remote = remote_get(option_origin); transport = transport_get(remote, remote->url[0]); if (!transport->get_refs_list || !transport->fetch) -- cgit v1.2.1 From df61c8897950759bfe93c2b9d828487bcc7fbb6b Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Mon, 29 Mar 2010 11:48:24 -0500 Subject: clone: also configure url for bare clones Without this the 'origin' remote would not be configured, so when calling remote_get with 'origin' as argument we would get an unconfigured remote. Signed-off-by: Junio C Hamano --- builtin/clone.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 068d61fd3..05be999bd 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -495,12 +495,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix) git_config_set(key.buf, "true"); strbuf_reset(&key); } - - strbuf_addf(&key, "remote.%s.url", option_origin); - git_config_set(key.buf, repo); - strbuf_reset(&key); } + strbuf_addf(&key, "remote.%s.url", option_origin); + git_config_set(key.buf, repo); + strbuf_reset(&key); + if (option_reference) setup_reference(git_dir); -- cgit v1.2.1 From 28ba96ab27d0471af101b4796534ad4085019db1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Apr 2010 14:37:22 +0200 Subject: clone: quell the progress report from init and report on clone Currently, a local git clone reports only initializing an empty git dir, which is potentially confusing. Instead, report that cloning is in progress and when it is done (unless -q) is given, and suppress the init report. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- builtin/clone.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 05f8fb477..0bedde41f 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -302,6 +302,8 @@ static const struct ref *clone_local(const char *src_repo, transport = transport_get(remote, src_repo); ret = transport_get_remote_refs(transport); transport_disconnect(transport); + if (0 <= option_verbosity) + printf("done.\n"); return ret; } @@ -461,7 +463,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) die("could not create leading directories of '%s'", git_dir); set_git_dir(make_absolute_path(git_dir)); - init_db(option_template, (option_verbosity < 0) ? INIT_DB_QUIET : 0); + if (0 <= option_verbosity) + printf("Cloning into %s...\n", get_git_dir()); + init_db(option_template, INIT_DB_QUIET); /* * At this point, the config exists, so we do not need the -- cgit v1.2.1 From 921eabde9d0b9b43b293b37ac701bdfd10a64f54 Mon Sep 17 00:00:00 2001 From: Pete Harlan Date: Sun, 9 May 2010 13:10:17 -0700 Subject: clone: reword messages to match the end-user perception When cloning into a non-bare repository, e.g. "git clone $URL mine", we used to report that we are cloning into "mine/.git". Reword the report to say "Cloning into mine" instead, as that matches what the end-user asked for closer. Make the message for "git clone --bare $URL mine" to say "Cloning into bare repository mine" do make the distinction between this case and the above stand out a bit more prominently. Suggested-by: Jeff King Signed-off-by: Pete Harlan Signed-off-by: Junio C Hamano --- builtin/clone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 0bedde41f..3a3625b2a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -464,7 +464,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) set_git_dir(make_absolute_path(git_dir)); if (0 <= option_verbosity) - printf("Cloning into %s...\n", get_git_dir()); + printf("Cloning into %s%s...\n", + option_bare ? "bare repository " : "", dir); init_db(option_template, INIT_DB_QUIET); /* -- cgit v1.2.1 From 24c61c44e65f672ffcd032e43519824719d249c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 23 Aug 2010 22:08:22 +1000 Subject: clone: warn users --depth is ignored in local clones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/clone.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index efb1e6faa..19ed64041 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -361,7 +361,7 @@ static void write_remote_refs(const struct ref *local_refs) int cmd_clone(int argc, const char **argv, const char *prefix) { - int is_bundle = 0; + int is_bundle = 0, is_local; struct stat buf; const char *repo_name, *repo, *work_tree, *git_dir; char *path, *dir; @@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) repo = xstrdup(make_absolute_path(repo_name)); else repo = repo_name; + is_local = path && !is_bundle; + if (is_local && option_depth) + warning("--depth is ignored in local clones; use file:// instead."); if (argc == 2) dir = xstrdup(argv[1]); @@ -514,7 +517,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) strbuf_reset(&value); - if (path && !is_bundle) { + if (is_local) { refs = clone_local(path, git_dir); mapped_refs = wanted_peer_refs(refs, refspec); } else { -- cgit v1.2.1 From ccdd3da6527ca7d8d731e691b9ff0f9b8657298e Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Thu, 4 Nov 2010 21:27:12 +0100 Subject: clone: Add the --recurse-submodules option as alias for --recursive Since 1.6.5 "git clone" honors the --recursive option to recursively check out submodules too. As this option can easily be misinterpreted when it is added to other commands like "git grep", add the new --recurse-submodules option as an alias for --recursive so the same option can be used for all commands recursing into submodules. Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 19ed64041..61e0989b5 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -66,6 +66,8 @@ static struct option builtin_clone_options[] = { "setup as shared repository"), OPT_BOOLEAN(0, "recursive", &option_recursive, "initialize submodules in the clone"), + OPT_BOOLEAN(0, "recurse_submodules", &option_recursive, + "initialize submodules in the clone"), OPT_STRING(0, "template", &option_template, "path", "path the template repository"), OPT_STRING(0, "reference", &option_reference, "repo", -- cgit v1.2.1 From 3446a54c9afe3f78ca27fc51f618884ba49493de Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Fri, 11 Feb 2011 11:59:31 +1300 Subject: clone: fixup recurse_submodules option The recurse_submodules option was added in ccdd3da6 to bring 'git clone' into line with 'git fetch' and future commands. The correct option should have been "recurse-submodules". Signed-off-by: Chris Packham Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 61e0989b5..82a693862 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -66,7 +66,7 @@ static struct option builtin_clone_options[] = { "setup as shared repository"), OPT_BOOLEAN(0, "recursive", &option_recursive, "initialize submodules in the clone"), - OPT_BOOLEAN(0, "recurse_submodules", &option_recursive, + OPT_BOOLEAN(0, "recurse-submodules", &option_recursive, "initialize submodules in the clone"), OPT_STRING(0, "template", &option_template, "path", "path the template repository"), -- cgit v1.2.1 From 5027fa864dafd5a054aab2de6b4bae089f344fc6 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Tue, 15 Feb 2011 14:09:06 +0100 Subject: clone,init: describe --template using the same wording This also corrects a wrong description for clone. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- builtin/clone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 82a693862..60d9a6428 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -68,8 +68,8 @@ static struct option builtin_clone_options[] = { "initialize submodules in the clone"), OPT_BOOLEAN(0, "recurse-submodules", &option_recursive, "initialize submodules in the clone"), - OPT_STRING(0, "template", &option_template, "path", - "path the template repository"), + OPT_STRING(0, "template", &option_template, "template-directory", + "directory from which templates will be used"), OPT_STRING(0, "reference", &option_reference, "repo", "reference repository"), OPT_STRING('o', "origin", &option_origin, "branch", -- cgit v1.2.1 From a9026187923643235d4f9b876ff5f4c0ebe5c9ae Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 17 Feb 2011 23:01:52 -0500 Subject: clone: die when trying to clone missing local path Since 86ac751 (Allow cloning an empty repository, 2009-01-23), doing: git clone does-not-exist has created does-not-exist as an empty repository. This was an unintentional side effect of 86ac751. Even weirder, doing: git clone does-not-exist new-dir _does_ fail, making this "feature" (if you want to consider it such) broken. Let's detect this situation and explicitly die. It's almost certainly not what the user intended. This patch also adds two tests. One for the missing path case, and one to confirm that a similar case, cloning a non-repository directory, fails. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 61e0989b5..6fcd69994 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (path) repo = xstrdup(make_nonrelative_path(repo_name)); else if (!strchr(repo_name, ':')) - repo = xstrdup(make_absolute_path(repo_name)); + die("repository '%s' does not exist", repo_name); else repo = repo_name; is_local = path && !is_bundle; -- cgit v1.2.1 From bbc30f996380eacd71ca061675d5d0c5f21c45d2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Feb 2011 09:30:19 -0500 Subject: add packet tracing debug code This shows a trace of all packets coming in or out of a given program. This can help with debugging object negotiation or other protocol issues. To keep the code changes simple, we operate at the lowest level, meaning we don't necessarily understand what's in the packets. The one exception is a packet starting with "PACK", which causes us to skip that packet and turn off tracing (since the gigantic pack data will not be interesting to read, at least not in the trace format). We show both written and read packets. In the local case, this may mean you will see packets twice (written by the sender and read by the receiver). However, for cases where the other end is remote, this allows you to see the full conversation. Packet tracing can be enabled with GIT_TRACE_PACKET=, where takes the same arguments as GIT_TRACE. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/clone.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 60d9a6428..38b4b71cd 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -383,6 +383,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) junk_pid = getpid(); + packet_trace_identity("clone"); argc = parse_options(argc, argv, prefix, builtin_clone_options, builtin_clone_usage, 0); -- cgit v1.2.1 From e84d7b74c6e59fac20209c4759791f39afc0e25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 22 Feb 2011 23:41:26 +0000 Subject: i18n: git-clone basic messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/clone.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 60d9a6428..f46d09bf5 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -208,7 +208,7 @@ static void setup_reference(const char *repo) if (is_directory(mkpath("%s/.git/objects", ref_git))) ref_git = mkpath("%s/.git", 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); 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); if (!dir) - die_errno("failed to open '%s'", src->buf); + die_errno(_("failed to open '%s'"), src->buf); if (mkdir(dest->buf, 0777)) { 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)) - die_errno("failed to stat '%s'", dest->buf); + die_errno(_("failed to stat '%s'"), dest->buf); 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, '/'); @@ -257,7 +257,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest) strbuf_setlen(dest, dest_len); strbuf_addstr(dest, de->d_name); if (stat(src->buf, &buf)) { - warning ("failed to stat %s\n", src->buf); + warning (_("failed to stat %s\n"), src->buf); continue; } 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) - die_errno("failed to unlink '%s'", dest->buf); + die_errno(_("failed to unlink '%s'"), dest->buf); if (!option_no_hardlinks) { if (!link(src->buf, dest->buf)) continue; 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; } 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); } @@ -305,7 +305,7 @@ static const struct ref *clone_local(const char *src_repo, ret = transport_get_remote_refs(transport); transport_disconnect(transport); if (0 <= option_verbosity) - printf("done.\n"); + printf(_("done.\n")); return ret; } @@ -387,11 +387,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix) builtin_clone_usage, 0); if (argc > 2) - usage_msg_opt("Too many arguments.", + usage_msg_opt(_("Too many arguments."), builtin_clone_usage, builtin_clone_options); 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); if (option_mirror) @@ -399,7 +399,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (option_bare) { if (option_origin) - die("--bare and --origin %s options are incompatible.", + die(_("--bare and --origin %s options are incompatible."), option_origin); option_no_checkout = 1; } @@ -418,7 +418,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) repo = repo_name; is_local = path && !is_bundle; 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) dir = xstrdup(argv[1]); @@ -428,8 +428,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) dest_exists = !stat(dir, &buf); if (dest_exists && !is_empty_dir(dir)) - die("destination path '%s' already exists and is not " - "an empty directory.", dir); + die(_("destination path '%s' already exists and is not " + "an empty directory."), dir); strbuf_addf(&reflog_msg, "clone: from %s", repo); @@ -438,7 +438,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) else { work_tree = getenv("GIT_WORK_TREE"); 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) @@ -451,10 +451,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (!option_bare) { junk_work_tree = work_tree; 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); 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); 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); 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)); 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]); 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"); @@ -566,8 +566,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) strbuf_release(&head); if (!our_head_points_at) { - warning("Remote branch %s not found in " - "upstream %s, using HEAD instead", + warning(_("Remote branch %s not found in " + "upstream %s, using HEAD instead"), option_branch, option_origin); 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; } else { - warning("You appear to have cloned an empty repository."); + warning(_("You appear to have cloned an empty repository.")); our_head_points_at = NULL; remote_head_points_at = NULL; remote_head = NULL; @@ -618,8 +618,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) } else { /* Nothing to checkout out */ if (!option_no_checkout) - warning("remote HEAD refers to nonexistent ref, " - "unable to checkout.\n"); + warning(_("remote HEAD refers to nonexistent ref, " + "unable to checkout.\n")); 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) || 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), sha1_to_hex(our_head_points_at->old_sha1), "1", -- cgit v1.2.1 From 3781fcce05c16dcb0714c817ecfabbe8e1ffe62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 22 Feb 2011 23:41:27 +0000 Subject: i18n: git-clone "Cloning into" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Separate the "Cloning into %s" and "Cloning into bare repository %s" messages to make them easier to translate. No noticeable change intended. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/clone.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index f46d09bf5..db0240d18 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -468,9 +468,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix) die(_("could not create leading directories of '%s'"), git_dir); set_git_dir(make_absolute_path(git_dir)); - if (0 <= option_verbosity) - printf("Cloning into %s%s...\n", - option_bare ? "bare repository " : "", dir); + if (0 <= option_verbosity) { + if (option_bare) + printf("Cloning into bare repository %s...\n", dir); + else + printf("Cloning into %s...\n", dir); + } init_db(option_template, INIT_DB_QUIET); /* -- cgit v1.2.1 From 5cde59895f6c12fa479154ab111644de40f6a05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 22 Feb 2011 23:41:28 +0000 Subject: i18n: git-clone "Cloning into" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/clone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index db0240d18..b9394c415 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -470,9 +470,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (0 <= option_verbosity) { if (option_bare) - printf("Cloning into bare repository %s...\n", dir); + printf(_("Cloning into bare repository %s...\n"), dir); else - printf("Cloning into %s...\n", dir); + printf(_("Cloning into %s...\n"), dir); } init_db(option_template, INIT_DB_QUIET); -- cgit v1.2.1 From e2a57aac8a8a2b786739a5a93ea9dcfd2f0fd0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 17 Mar 2011 12:26:46 +0100 Subject: Name make_*_path functions more accurately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the make_*_path functions so it's clearer what they do, in particlar make clear what the differnce between make_absolute_path and make_nonrelative_path is by renaming them real_path and absolute_path respectively. make_relative_path has an understandable name and is renamed to relative_path to maintain the name convention. The function calls have been replaced 1-to-1 in their usage. Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano --- builtin/clone.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 2ee1fa984..404f58968 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -100,7 +100,7 @@ static char *get_repo_path(const char *repo, int *is_bundle) path = mkpath("%s%s", repo, suffix[i]); if (is_directory(path)) { *is_bundle = 0; - return xstrdup(make_nonrelative_path(path)); + return xstrdup(absolute_path(path)); } } @@ -109,7 +109,7 @@ static char *get_repo_path(const char *repo, int *is_bundle) path = mkpath("%s%s", repo, bundle_suffix[i]); if (!stat(path, &st) && S_ISREG(st.st_mode)) { *is_bundle = 1; - return xstrdup(make_nonrelative_path(path)); + return xstrdup(absolute_path(path)); } } @@ -203,7 +203,7 @@ static void setup_reference(const char *repo) struct transport *transport; const struct ref *extra; - ref_git = make_absolute_path(option_reference); + ref_git = real_path(option_reference); if (is_directory(mkpath("%s/.git/objects", ref_git))) ref_git = mkpath("%s/.git", ref_git); @@ -411,7 +411,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) path = get_repo_path(repo_name, &is_bundle); if (path) - repo = xstrdup(make_nonrelative_path(repo_name)); + repo = xstrdup(absolute_path(repo_name)); else if (!strchr(repo_name, ':')) die("repository '%s' does not exist", repo_name); else @@ -466,7 +466,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) 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)); + set_git_dir(real_path(git_dir)); if (0 <= option_verbosity) printf("Cloning into %s%s...\n", -- cgit v1.2.1 From b57fb80a7d7d19102b31ab94a28ed43ea1ee07bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 19 Mar 2011 22:16:56 +0700 Subject: init, clone: support --separate-git-dir for .git file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --separate-git-dir tells git to create git dir at the specified location, instead of where it is supposed to be. A .git file that points to that location will be put in place so that it appears normal to repo discovery process. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/clone.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 404f58968..097beca3a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -42,6 +42,7 @@ static int option_local, option_no_hardlinks, option_shared, option_recursive; static char *option_template, *option_reference, *option_depth; static char *option_origin = NULL; static char *option_branch = NULL; +static const char *real_git_dir; static char *option_upload_pack = "git-upload-pack"; static int option_verbosity; static int option_progress; @@ -80,6 +81,8 @@ static struct option builtin_clone_options[] = { "path to git-upload-pack on the remote"), OPT_STRING(0, "depth", &option_depth, "depth", "create a shallow clone of that depth"), + OPT_STRING('L', "separate-git-dir", &real_git_dir, "gitdir", + "separate git dir from working tree"), OPT_END() }; @@ -466,7 +469,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (safe_create_leading_directories_const(git_dir) < 0) die("could not create leading directories of '%s'", git_dir); - set_git_dir(real_path(git_dir)); + + set_git_dir_init(git_dir, real_git_dir, 0); + if (real_git_dir) + git_dir = real_git_dir; if (0 <= option_verbosity) printf("Cloning into %s%s...\n", -- cgit v1.2.1 From c2e86addb86689306b992065328ec52aa2479658 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 22 Mar 2011 00:51:05 -0700 Subject: Fix sparse warnings Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 02547adba..c6e10bb9e 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -8,7 +8,7 @@ * Clone a repository into a different directory that does not yet exist. */ -#include "cache.h" +#include "builtin.h" #include "parse-options.h" #include "fetch-pack.h" #include "refs.h" -- cgit v1.2.1 From d3e1ddfd390da8ed6fd275821802eec64c2f74ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 10 Apr 2011 19:34:06 +0000 Subject: i18n: mark clone nonexistent repository message for translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark the "repository '%s' does not exist" message added in v1.7.4.2~21^2 (clone: die when trying to clone missing local path) by Jeff King for translation. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 4144bcf5c..49c838fd3 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -417,7 +417,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (path) repo = xstrdup(absolute_path(repo_name)); else if (!strchr(repo_name, ':')) - die("repository '%s' does not exist", repo_name); + die(_("repository '%s' does not exist"), repo_name); else repo = repo_name; is_local = path && !is_bundle; -- cgit v1.2.1 From 09ffc706e48f93ed622a9a61704b2f767666b30d Mon Sep 17 00:00:00 2001 From: Nguyen Thai Ngoc Duy Date: Tue, 24 May 2011 23:40:32 +0700 Subject: init/clone: remove short option -L and document --separate-git-dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index 4144bcf5c..8560cf857 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -81,7 +81,7 @@ static struct option builtin_clone_options[] = { "path to git-upload-pack on the remote"), OPT_STRING(0, "depth", &option_depth, "depth", "create a shallow clone of that depth"), - OPT_STRING('L', "separate-git-dir", &real_git_dir, "gitdir", + OPT_STRING(0, "separate-git-dir", &real_git_dir, "gitdir", "separate git dir from working tree"), OPT_END() -- cgit v1.2.1