Subject: [PATCH] Allow "clone --dissociate" to dissociate from alternates

From: Alexander Riesen <[email-masked]>
Date: Thu, 15 Oct 2015 16:38:00 +0200

The option requiring the explicit reference repositories is a bit of overkill:
the alternates in the original repository *are* reference repositories and
would be dissociated from should one pass any reference repository (even an
unrelated one).

Signed-off-by: Alex Riesen <[email-masked]>
---

On 10/15/2015 04:11 PM, Johannes Schindelin wrote:
> On Thu, 15 Oct 2015, Alexander  Riesen wrote:
 >
 >> The "--dissociate" option required reference repositories, which sometimes
 >> demanded a look into the objects/info/alternates by the user. As this
 >> is something which can be figured out automatically, do it in the
 >> clone unless there is no other reference repositories.
 >
 > Would it not make sense to reuse the copy_alternates() function to simply
 > copy the alternates and let `--dissociate` run its course with the copied
 > .objects/info/alternate file? That would make for less new code...

IIUC, I should validate the alternates in the source repository...
But, the only thing the user looses if it is not validated, is the nice
warning regarding no reference repositories to dissociate from, right?

So maybe we can just remove the reset of option_dissociate and be done with
it? I would actually suggest removing the warning as well: the alternates are
something to dissociate from. And I see no harm otherwise.

How about this instead?

  builtin/clone.c | 4 ----
  1 file changed, 4 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 578da85..b33d6f9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -947,10 +947,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);
-- 
2.6.1.151.g74e8091