From: Junio C Hamano Date: Thu, 11 Jun 2015 16:29:52 +0000 (-0700) Subject: Merge branch 'jk/clone-dissociate' X-Git-Tag: v2.5.0-rc0~49 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/82b416e063d9b1497eac78a8deaad340d251f1dc?ds=inline;hp=-c Merge branch 'jk/clone-dissociate' Code clean-up. * jk/clone-dissociate: clone: reorder --dissociate and --reference options clone: use OPT_STRING_LIST for --reference --- 82b416e063d9b1497eac78a8deaad340d251f1dc diff --combined builtin/clone.c index b878252bc2,0006763074..00535d0178 --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -34,7 -34,7 +34,7 @@@ * */ static const char * const builtin_clone_usage[] = { - N_("git clone [options] [--] []"), + N_("git clone [] [--] []"), NULL }; @@@ -51,15 -51,6 +51,6 @@@ static struct string_list option_config static struct string_list option_reference; static int option_dissociate; - static int opt_parse_reference(const struct option *opt, const char *arg, int unset) - { - struct string_list *option_reference = opt->value; - if (!arg) - return -1; - string_list_append(option_reference, arg); - return 0; - } - static struct option builtin_clone_options[] = { OPT__VERBOSITY(&option_verbosity), OPT_BOOL(0, "progress", &option_progress, @@@ -83,8 -74,10 +74,10 @@@ N_("initialize submodules in the clone")), OPT_STRING(0, "template", &option_template, N_("template-directory"), N_("directory from which templates will be used")), - OPT_CALLBACK(0 , "reference", &option_reference, N_("repo"), - N_("reference repository"), &opt_parse_reference), + OPT_STRING_LIST(0, "reference", &option_reference, N_("repo"), + N_("reference repository")), + OPT_BOOL(0, "dissociate", &option_dissociate, + N_("use --reference only while cloning")), OPT_STRING('o', "origin", &option_origin, N_("name"), N_("use instead of 'origin' to track upstream")), OPT_STRING('b', "branch", &option_branch, N_("branch"), @@@ -95,8 -88,6 +88,6 @@@ N_("create a shallow clone of that depth")), OPT_BOOL(0, "single-branch", &option_single_branch, N_("clone only one branch, HEAD or --branch")), - OPT_BOOL(0, "dissociate", &option_dissociate, - N_("use --reference only while cloning")), OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"), N_("separate git dir from working tree")), OPT_STRING_LIST('c', "config", &option_config, N_("key=value"), @@@ -293,17 -284,16 +284,17 @@@ static void copy_alternates(struct strb struct strbuf line = STRBUF_INIT; while (strbuf_getline(&line, in, '\n') != EOF) { - char *abs_path, abs_buf[PATH_MAX]; + char *abs_path; if (!line.len || line.buf[0] == '#') continue; if (is_absolute_path(line.buf)) { add_to_alternates_file(line.buf); continue; } - abs_path = mkpath("%s/objects/%s", src_repo, line.buf); - normalize_path_copy(abs_buf, abs_path); - add_to_alternates_file(abs_buf); + abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf); + normalize_path_copy(abs_path, abs_path); + add_to_alternates_file(abs_path); + free(abs_path); } strbuf_release(&line); fclose(in); @@@ -907,8 -897,6 +898,8 @@@ int cmd_clone(int argc, const char **ar remote = remote_get(option_origin); transport = transport_get(remote, remote->url[0]); + transport_set_verbosity(transport, option_verbosity, option_progress); + path = get_repo_path(remote->url[0], &is_bundle); is_local = option_local != 0 && path && !is_bundle; if (is_local) { @@@ -935,6 -923,8 +926,6 @@@ if (option_single_branch) transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1"); - transport_set_verbosity(transport, option_verbosity, option_progress); - if (option_upload_pack) transport_set_option(transport, TRANS_OPT_UPLOADPACK, option_upload_pack);