git-p4: add trap to kill p4d on test exit
[gitweb.git] / builtin / clone.c
index 9eaecd9a7cdb9ad6726626c96edd05d2d9305453..caae43e7a390d8666cda259e995c14079103d20d 100644 (file)
@@ -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);