Merge branch 'dt/fsck-verify-pack-error'
[gitweb.git] / builtin / clone.c
index cc896e22d16bab5fc46e02c7f164e1e512aeca62..caae43e7a390d8666cda259e995c14079103d20d 100644 (file)
@@ -294,9 +294,14 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
                char *ref_git_git = mkpathdup("%s/.git", ref_git);
                free(ref_git);
                ref_git = ref_git_git;
-       } else if (!is_directory(mkpath("%s/objects", ref_git)))
+       } else if (!is_directory(mkpath("%s/objects", ref_git))) {
+               struct strbuf sb = STRBUF_INIT;
+               if (get_common_dir(&sb, ref_git))
+                       die(_("reference repository '%s' as a linked checkout is not supported yet."),
+                           item->string);
                die(_("reference repository '%s' is not a local repository."),
                    item->string);
+       }
 
        if (!access(mkpath("%s/shallow", ref_git), F_OK))
                die(_("reference repository '%s' is shallow"), item->string);
@@ -424,8 +429,10 @@ static void clone_local(const char *src_repo, const char *dest_repo)
        } else {
                struct strbuf src = STRBUF_INIT;
                struct strbuf dest = STRBUF_INIT;
-               strbuf_addf(&src, "%s/objects", src_repo);
-               strbuf_addf(&dest, "%s/objects", dest_repo);
+               get_common_dir(&src, src_repo);
+               get_common_dir(&dest, dest_repo);
+               strbuf_addstr(&src, "/objects");
+               strbuf_addstr(&dest, "/objects");
                copy_or_link_directory(&src, &dest, src_repo, src.len);
                strbuf_release(&src);
                strbuf_release(&dest);
@@ -794,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)
@@ -947,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);