summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-30 13:06:53 -0700
committerJunio C Hamano <gitster@pobox.com>2015-10-30 13:06:53 -0700
commit908700c0082487f9c859b951370148ff7e8acb97 (patch)
tree1dea0f29594b1d3d10c470947eb40912b272e29f /builtin
parent482456a414d69d8c44b92bbf73eb4ee53b5d8ab9 (diff)
parent0181681e921fa4e001a51886749ee0584233db51 (diff)
downloadgit-908700c0082487f9c859b951370148ff7e8acb97.tar.gz
Merge branch 'ar/clone-dissociate'
"git clone --dissociate" used to require that "--reference" was used at the same time, but you can create a new repository that borrows objects from another without using "--reference", namely with "clone --local" from a repository that borrows objects from other repositories. * ar/clone-dissociate: clone: allow "--dissociate" without reference
Diffstat (limited to 'builtin')
-rw-r--r--builtin/clone.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 9eaecd9a7c..caae43e7a3 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -801,11 +801,15 @@ static void write_refspec_config(const char *src_ref_prefix,
static void dissociate_from_references(void)
{
static const char* argv[] = { "repack", "-a", "-d", NULL };
+ char *alternates = git_pathdup("objects/info/alternates");
- if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN))
- die(_("cannot repack to clean up"));
- if (unlink(git_path("objects/info/alternates")) && errno != ENOENT)
- die_errno(_("cannot unlink temporary alternates file"));
+ if (!access(alternates, F_OK)) {
+ if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN))
+ die(_("cannot repack to clean up"));
+ if (unlink(alternates) && errno != ENOENT)
+ die_errno(_("cannot unlink temporary alternates file"));
+ }
+ free(alternates);
}
int cmd_clone(int argc, const char **argv, const char *prefix)
@@ -954,10 +958,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_reference.nr)
setup_reference();
- else if (option_dissociate) {
- warning(_("--dissociate given, but there is no --reference"));
- option_dissociate = 0;
- }
fetch_pattern = value.buf;
refspec = parse_fetch_refspec(1, &fetch_pattern);