summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2015-10-22 16:41:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-22 19:13:29 (GMT)
commit0181681e921fa4e001a51886749ee0584233db51 (patch)
treea57631f96bb7748d5f86a0602a93ddfc5ee4a8de /builtin/clone.c
parent74301d6edeb0e081a4ef864057952b6a7ff2b4be (diff)
downloadgit-0181681e921fa4e001a51886749ee0584233db51.zip
git-0181681e921fa4e001a51886749ee0584233db51.tar.gz
git-0181681e921fa4e001a51886749ee0584233db51.tar.bz2
clone: allow "--dissociate" without reference
The "--reference" option is not the only way to provide a repository to borrow objects from. A repository that borrows from another repository can be cloned with "clone --local" and the resulting repository will borrow from the same repository, which the user may want to "--dissociate" from. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 9eaecd9..caae43e 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);