48
static int option_progress = -1;
49
static struct string_list option_config;
50
static struct string_list option_reference;
51
+static int option_dissociate;
52
53
static int opt_parse_reference(const struct option *opt, const char *arg, int unset)
54
{
94
N_("create a shallow clone of that depth")),
95
OPT_BOOL(0, "single-branch", &option_single_branch,
96
N_("clone only one branch, HEAD or --branch")),
97
+ OPT_BOOL(0, "dissociate", &option_dissociate,
98
+ N_("use --reference only while cloning")),
99
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
100
N_("separate git dir from working tree")),
101
OPT_STRING_LIST('c', "config", &option_config, N_("key=value"),
739
strbuf_release(&value);
740
}
741
742
+static void dissociate_from_references(void)
743
+{
744
+ static const char* argv[] = { "repack", "-a", "-d", NULL };
745
+
746
+ if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN))
747
+ die(_("cannot repack to clean up"));
748
+ if (unlink(git_path("objects/info/alternates")) && errno != ENOENT)
749
+ die_errno(_("cannot unlink temporary alternates file"));
750
+}
751
+
752
int cmd_clone(int argc, const char **argv, const char *prefix)
753
{
754
int is_bundle = 0, is_local;
896
897
if (option_reference.nr)
898
setup_reference();
899
+ else if (option_dissociate) {
900
+ warning(_("--dissociate given, but there is no --reference"));
901
+ option_dissociate = 0;
902
+ }
903
904
fetch_pattern = value.buf;
905
refspec = parse_fetch_refspec(1, &fetch_pattern);
1013
transport_unlock_pack(transport);
1014
transport_disconnect(transport);
1015
1016
+ if (option_dissociate)
1017
+ dissociate_from_references();
1018
+
1019
junk_mode = JUNK_LEAVE_REPO;
1020
err = checkout();
1021