{"thread":{"id":"14792","subject":"[PATCH 1/2] clone: Add an option to set up a mirror","startedAt":"2008-08-01T14:00:45Z","lastAt":"2008-08-02T20:46:26Z","messageCount":9,"participants":["Johannes Schindelin","Marcus Griep","Miklos Vajna","Bert Wesarg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"85899","messageId":"alpine.DEB.1.00.0808011600170.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14792","inReplyTo":null,"subject":"[PATCH 1/2] clone: Add an option to set up a mirror","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-01T14:00:45Z","receivedAt":"2008-08-01T14:00:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThe command line\n\n\t$ git clone --mirror $URL\n\nis now a short-hand for\n\n\t$ git clone --bare $URL\n\t$ (cd $(basename $URL) && git remote add --mirror origin $URL)\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Documentation/git-clone.txt |    5 ++++-\n builtin-clone.c             |    9 ++++++++-\n t/t5601-clone.sh            |   10 ++++++++++\n 3 files changed, 22 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 26fd1b1..0e14e73 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git clone' [--template=<template_directory>]\n-\t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]\n+\t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n \t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n \t  [--depth <depth>] [--] <repository> [<directory>]\n \n@@ -106,6 +106,9 @@ then the cloned repository will become corrupt.\n \tused, neither remote-tracking branches nor the related\n \tconfiguration variables are created.\n \n+--mirror::\n+\tSet up a mirror of the remote repository.  This implies --bare.\n+\n --origin <name>::\n -o <name>::\n \tInstead of using the remote name 'origin' to keep track\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex e086a40..a45179c 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -33,7 +33,7 @@ static const char * const builtin_clone_usage[] = {\n \tNULL\n };\n \n-static int option_quiet, option_no_checkout, option_bare;\n+static int option_quiet, option_no_checkout, option_bare, option_mirror;\n static int option_local, option_no_hardlinks, option_shared;\n static char *option_template, *option_reference, *option_depth;\n static char *option_origin = NULL;\n@@ -45,6 +45,8 @@ static struct option builtin_clone_options[] = {\n \t\t    \"don't create a checkout\"),\n \tOPT_BOOLEAN(0, \"bare\", &option_bare, \"create a bare repository\"),\n \tOPT_BOOLEAN(0, \"naked\", &option_bare, \"create a bare repository\"),\n+\tOPT_BOOLEAN(0, \"mirror\", &option_mirror,\n+\t\t    \"create a mirror repository (implies bare)\"),\n \tOPT_BOOLEAN('l', \"local\", &option_local,\n \t\t    \"to clone from a local repository\"),\n \tOPT_BOOLEAN(0, \"no-hardlinks\", &option_no_hardlinks,\n@@ -359,6 +361,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tif (option_no_hardlinks)\n \t\tuse_local_hardlinks = 0;\n \n+\tif (option_mirror)\n+\t\toption_bare = 1;\n+\n \tif (option_bare) {\n \t\tif (option_origin)\n \t\t\tdie(\"--bare and --origin %s options are incompatible.\",\n@@ -446,7 +451,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t} else {\n \t\tsnprintf(branch_top, sizeof(branch_top),\n \t\t\t \"refs/remotes/%s/\", option_origin);\n+\t}\n \n+\tif (option_mirror || !option_bare) {\n \t\t/* Configure the remote */\n \t\tsnprintf(key, sizeof(key), \"remote.%s.url\", option_origin);\n \t\tgit_config_set(key, repo);\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex d785b3d..4b2533f 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -70,4 +70,14 @@ test_expect_success 'clone creates intermediate directories for bare repo' '\n \n '\n \n+test_expect_success 'clone --mirror' '\n+\n+\tgit clone --mirror src mirror &&\n+\ttest -f mirror/HEAD &&\n+\ttest ! -f mirror/file &&\n+\tFETCH=\"$(cd mirror && git config remote.origin.fetch)\" &&\n+\ttest \"+refs/heads/*:refs/heads/*\" = \"$FETCH\"\n+\n+'\n+\n test_done\n-- \n1.6.0.rc1.46.g279e5\n"},{"id":"85901","messageId":"4893172C.1060203@griep.us","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808011601200.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH 2/2] clone --bare: Add \".git\" suffix to the directory name to clone into","fromName":"Marcus Griep","fromEmail":"marcus@griep.us","sentAt":"2008-08-01T14:01:16Z","receivedAt":"2008-08-01T14:01:16Z","isPatch":true,"sender":{"key":"marcus@griep.us","avatar":"https://gravatar.com/avatar/0a841f2aad3f9a38c9bcf87a567c2a1751cb08924bae1bc46ee171395bcf9794?d=mp&s=160"},"body":"Does this patch forgo adding a \".git\" suffix if one is already present?\n\nMarcus\n\nJohannes Schindelin wrote:\n> We have a tradition that bare repositories live in directories ending\n> in \".git\".  To make this more a convention than just a tradition, teach\n> \"git clone --bare\" to add a \".git\" suffix to the directory name.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> \n> \tThis patch is only conceptionally dependent on patch 1/2.\n> \n>  builtin-clone.c  |   10 ++++++++--\n>  t/t5601-clone.sh |    7 +++++++\n>  2 files changed, 15 insertions(+), 2 deletions(-)\n> \n> diff --git a/builtin-clone.c b/builtin-clone.c\n> index a45179c..82f5b67 100644\n> --- a/builtin-clone.c\n> +++ b/builtin-clone.c\n> @@ -95,7 +95,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)\n>  \treturn NULL;\n>  }\n>  \n> -static char *guess_dir_name(const char *repo, int is_bundle)\n> +static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)\n>  {\n>  \tconst char *end = repo + strlen(repo), *start;\n>  \n> @@ -131,6 +131,12 @@ static char *guess_dir_name(const char *repo, int is_bundle)\n>  \t\t\tend -= 4;\n>  \t}\n>  \n> +\tif (is_bare) {\n> +\t\tchar *result = xmalloc(end - start + 5);\n> +\t\tsprintf(result, \"%.*s.git\", (int)(end - start), start);\n> +\t\treturn result;\n> +\t}\n> +\n>  \treturn xstrndup(start, end - start);\n>  }\n>  \n> @@ -388,7 +394,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n>  \tif (argc == 2)\n>  \t\tdir = xstrdup(argv[1]);\n>  \telse\n> -\t\tdir = guess_dir_name(repo_name, is_bundle);\n> +\t\tdir = guess_dir_name(repo_name, is_bundle, option_bare);\n>  \n>  \tif (!stat(dir, &buf))\n>  \t\tdie(\"destination directory '%s' already exists.\", dir);\n> diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\n> index 4b2533f..e0a68ab 100755\n> --- a/t/t5601-clone.sh\n> +++ b/t/t5601-clone.sh\n> @@ -80,4 +80,11 @@ test_expect_success 'clone --mirror' '\n>  \n>  '\n>  \n> +test_expect_success 'clone --bare names the local repository <name>.git' '\n> +\n> +\tgit clone --bare src &&\n> +\ttest -d src.git\n> +\n> +'\n> +\n>  test_done\n\n-- \nMarcus Griep\nGPG Key ID: 0x5E968152\n——\nhttp://www.boohaunt.net\nאת.ψο´\n\n"},{"id":"85900","messageId":"alpine.DEB.1.00.0808011601200.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808011600170.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"[PATCH 2/2] clone --bare: Add \".git\" suffix to the directory name to clone into","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-01T14:01:36Z","receivedAt":"2008-08-01T14:01:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWe have a tradition that bare repositories live in directories ending\nin \".git\".  To make this more a convention than just a tradition, teach\n\"git clone --bare\" to add a \".git\" suffix to the directory name.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tThis patch is only conceptionally dependent on patch 1/2.\n\n builtin-clone.c  |   10 ++++++++--\n t/t5601-clone.sh |    7 +++++++\n 2 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex a45179c..82f5b67 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -95,7 +95,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)\n \treturn NULL;\n }\n \n-static char *guess_dir_name(const char *repo, int is_bundle)\n+static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)\n {\n \tconst char *end = repo + strlen(repo), *start;\n \n@@ -131,6 +131,12 @@ static char *guess_dir_name(const char *repo, int is_bundle)\n \t\t\tend -= 4;\n \t}\n \n+\tif (is_bare) {\n+\t\tchar *result = xmalloc(end - start + 5);\n+\t\tsprintf(result, \"%.*s.git\", (int)(end - start), start);\n+\t\treturn result;\n+\t}\n+\n \treturn xstrndup(start, end - start);\n }\n \n@@ -388,7 +394,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tif (argc == 2)\n \t\tdir = xstrdup(argv[1]);\n \telse\n-\t\tdir = guess_dir_name(repo_name, is_bundle);\n+\t\tdir = guess_dir_name(repo_name, is_bundle, option_bare);\n \n \tif (!stat(dir, &buf))\n \t\tdie(\"destination directory '%s' already exists.\", dir);\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 4b2533f..e0a68ab 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -80,4 +80,11 @@ test_expect_success 'clone --mirror' '\n \n '\n \n+test_expect_success 'clone --bare names the local repository <name>.git' '\n+\n+\tgit clone --bare src &&\n+\ttest -d src.git\n+\n+'\n+\n test_done\n-- \n1.6.0.rc1.46.g279e5\n"},{"id":"85902","messageId":"20080801142732.GS32057@genesis.frugalware.org","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808011600170.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH 1/2] clone: Add an option to set up a mirror","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-08-01T14:27:32Z","receivedAt":"2008-08-01T14:27:32Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Fri, Aug 01, 2008 at 04:00:45PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> \n> The command line\n> \n> \t$ git clone --mirror $URL\n> \n> is now a short-hand for\n> \n> \t$ git clone --bare $URL\n> \t$ (cd $(basename $URL) && git remote add --mirror origin $URL)\n\nFunny, someone asked exactly this on #git yesterday (IIRC), but we ended\nup using clone & remote, since I didn't find clone --mirror in the man.\n;-)\n\nThanks!\n"},{"id":"85906","messageId":"36ca99e90808010834q6bb2f0a7i52a7aafb8dbafb70@mail.gmail.com","threadId":"14792","inReplyTo":"4893172C.1060203@griep.us","subject":"Re: [PATCH 2/2] clone --bare: Add \".git\" suffix to the directory name to clone into","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2008-08-01T15:34:47Z","receivedAt":"2008-08-01T15:34:47Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Fri, Aug 1, 2008 at 16:01, Marcus Griep <marcus@griep.us> wrote:\n> Does this patch forgo adding a \".git\" suffix if one is already present?\n\nNo, the purpose of the guess_dir_name() function is exactly to remove\nany present \".git\", and more.\n\nBert\n>\n> Marcus\n>\n"},{"id":"86001","messageId":"7vr697l01j.fsf@gitster.siamese.dyndns.org","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808011600170.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH 1/2] clone: Add an option to set up a mirror","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-02T18:55:04Z","receivedAt":"2008-08-02T18:55:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> The command line\n>\n> \t$ git clone --mirror $URL\n>\n> is now a short-hand for\n>\n> \t$ git clone --bare $URL\n> \t$ (cd $(basename $URL) && git remote add --mirror origin $URL)\n\nI think this would be a useful behaviour and I am very tempted to violate\nthe general policy of not taking any new options nor features after -rc1.\n\nI however notice that there are differences bewteen the above sequence and\nwhat your code actually does:\n\n - The \"remote add --mirror\" sequence tells it to mirror everything, but\n   the patch still mirrors only heads;\n\n - You are not setting up \"remote.*.mirror = yes\" in the configuration;\n"},{"id":"86005","messageId":"alpine.DEB.1.00.0808022126270.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14792","inReplyTo":"7vr697l01j.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2] clone: Add an option to set up a mirror","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-02T19:38:56Z","receivedAt":"2008-08-02T19:38:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThe command line\n\n\t$ git clone --mirror $URL\n\nis now a short-hand for\n\n\t$ git clone --bare $URL\n\t$ (cd $(basename $URL) && git remote add --mirror origin $URL)\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tInterdiff to follow.\n\n Documentation/git-clone.txt |    5 ++++-\n builtin-clone.c             |   24 ++++++++++++++++++++----\n t/t5601-clone.sh            |   10 ++++++++++\n 3 files changed, 34 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 26fd1b1..0e14e73 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git clone' [--template=<template_directory>]\n-\t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]\n+\t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n \t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n \t  [--depth <depth>] [--] <repository> [<directory>]\n \n@@ -106,6 +106,9 @@ then the cloned repository will become corrupt.\n \tused, neither remote-tracking branches nor the related\n \tconfiguration variables are created.\n \n+--mirror::\n+\tSet up a mirror of the remote repository.  This implies --bare.\n+\n --origin <name>::\n -o <name>::\n \tInstead of using the remote name 'origin' to keep track\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex e086a40..ecdcefa 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -33,7 +33,7 @@ static const char * const builtin_clone_usage[] = {\n \tNULL\n };\n \n-static int option_quiet, option_no_checkout, option_bare;\n+static int option_quiet, option_no_checkout, option_bare, option_mirror;\n static int option_local, option_no_hardlinks, option_shared;\n static char *option_template, *option_reference, *option_depth;\n static char *option_origin = NULL;\n@@ -45,6 +45,8 @@ static struct option builtin_clone_options[] = {\n \t\t    \"don't create a checkout\"),\n \tOPT_BOOLEAN(0, \"bare\", &option_bare, \"create a bare repository\"),\n \tOPT_BOOLEAN(0, \"naked\", &option_bare, \"create a bare repository\"),\n+\tOPT_BOOLEAN(0, \"mirror\", &option_mirror,\n+\t\t    \"create a mirror repository (implies bare)\"),\n \tOPT_BOOLEAN('l', \"local\", &option_local,\n \t\t    \"to clone from a local repository\"),\n \tOPT_BOOLEAN(0, \"no-hardlinks\", &option_no_hardlinks,\n@@ -345,6 +347,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tchar branch_top[256], key[256], value[256];\n \tstruct strbuf reflog_msg;\n \tstruct transport *transport = NULL;\n+\tchar *src_ref_prefix = \"refs/heads/\";\n \n \tstruct refspec refspec;\n \n@@ -359,6 +362,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tif (option_no_hardlinks)\n \t\tuse_local_hardlinks = 0;\n \n+\tif (option_mirror)\n+\t\toption_bare = 1;\n+\n \tif (option_bare) {\n \t\tif (option_origin)\n \t\t\tdie(\"--bare and --origin %s options are incompatible.\",\n@@ -440,26 +446,36 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tgit_config(git_default_config, NULL);\n \n \tif (option_bare) {\n-\t\tstrcpy(branch_top, \"refs/heads/\");\n+\t\tif (option_mirror)\n+\t\t\tsrc_ref_prefix = \"refs/\";\n+\t\tstrcpy(branch_top, src_ref_prefix);\n \n \t\tgit_config_set(\"core.bare\", \"true\");\n \t} else {\n \t\tsnprintf(branch_top, sizeof(branch_top),\n \t\t\t \"refs/remotes/%s/\", option_origin);\n+\t}\n \n+\tif (option_mirror || !option_bare) {\n \t\t/* Configure the remote */\n+\t\tif (option_mirror) {\n+\t\t\tsnprintf(key, sizeof(key),\n+\t\t\t\t\t\"remote.%s.mirror\", option_origin);\n+\t\t\tgit_config_set(key, \"true\");\n+\t\t}\n+\n \t\tsnprintf(key, sizeof(key), \"remote.%s.url\", option_origin);\n \t\tgit_config_set(key, repo);\n \n \t\tsnprintf(key, sizeof(key), \"remote.%s.fetch\", option_origin);\n \t\tsnprintf(value, sizeof(value),\n-\t\t\t\t\"+refs/heads/*:%s*\", branch_top);\n+\t\t\t\t\"+%s*:%s*\", src_ref_prefix, branch_top);\n \t\tgit_config_set_multivar(key, value, \"^$\", 0);\n \t}\n \n \trefspec.force = 0;\n \trefspec.pattern = 1;\n-\trefspec.src = \"refs/heads/\";\n+\trefspec.src = src_ref_prefix;\n \trefspec.dst = branch_top;\n \n \tif (path && !is_bundle)\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex d785b3d..9cd5ef4 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -70,4 +70,14 @@ test_expect_success 'clone creates intermediate directories for bare repo' '\n \n '\n \n+test_expect_success 'clone --mirror' '\n+\n+\tgit clone --mirror src mirror &&\n+\ttest -f mirror/HEAD &&\n+\ttest ! -f mirror/file &&\n+\tFETCH=\"$(cd mirror && git config remote.origin.fetch)\" &&\n+\ttest \"+refs/*:refs/*\" = \"$FETCH\"\n+\n+'\n+\n test_done\n-- \n1.6.0.rc1.70.g91e1d\n"},{"id":"86004","messageId":"alpine.DEB.1.00.0808022139150.9611@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808022126270.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] clone: Add an option to set up a mirror","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-02T19:39:28Z","receivedAt":"2008-08-02T19:39:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"The interdiff:\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex a45179c..ecdcefa 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -347,6 +347,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tchar branch_top[256], key[256], value[256];\n \tstruct strbuf reflog_msg;\n \tstruct transport *transport = NULL;\n+\tchar *src_ref_prefix = \"refs/heads/\";\n \n \tstruct refspec refspec;\n \n@@ -445,7 +446,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tgit_config(git_default_config, NULL);\n \n \tif (option_bare) {\n-\t\tstrcpy(branch_top, \"refs/heads/\");\n+\t\tif (option_mirror)\n+\t\t\tsrc_ref_prefix = \"refs/\";\n+\t\tstrcpy(branch_top, src_ref_prefix);\n \n \t\tgit_config_set(\"core.bare\", \"true\");\n \t} else {\n@@ -455,18 +458,24 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \tif (option_mirror || !option_bare) {\n \t\t/* Configure the remote */\n+\t\tif (option_mirror) {\n+\t\t\tsnprintf(key, sizeof(key),\n+\t\t\t\t\t\"remote.%s.mirror\", option_origin);\n+\t\t\tgit_config_set(key, \"true\");\n+\t\t}\n+\n \t\tsnprintf(key, sizeof(key), \"remote.%s.url\", option_origin);\n \t\tgit_config_set(key, repo);\n \n \t\tsnprintf(key, sizeof(key), \"remote.%s.fetch\", option_origin);\n \t\tsnprintf(value, sizeof(value),\n-\t\t\t\t\"+refs/heads/*:%s*\", branch_top);\n+\t\t\t\t\"+%s*:%s*\", src_ref_prefix, branch_top);\n \t\tgit_config_set_multivar(key, value, \"^$\", 0);\n \t}\n \n \trefspec.force = 0;\n \trefspec.pattern = 1;\n-\trefspec.src = \"refs/heads/\";\n+\trefspec.src = src_ref_prefix;\n \trefspec.dst = branch_top;\n \n \tif (path && !is_bundle)\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 4b2533f..9cd5ef4 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -76,7 +76,7 @@ test_expect_success 'clone --mirror' '\n \ttest -f mirror/HEAD &&\n \ttest ! -f mirror/file &&\n \tFETCH=\"$(cd mirror && git config remote.origin.fetch)\" &&\n-\ttest \"+refs/heads/*:refs/heads/*\" = \"$FETCH\"\n+\ttest \"+refs/*:refs/*\" = \"$FETCH\"\n \n '\n \n"},{"id":"86008","messageId":"7vd4krdu1p.fsf@gitster.siamese.dyndns.org","threadId":"14792","inReplyTo":"alpine.DEB.1.00.0808022126270.9611@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] clone: Add an option to set up a mirror","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-02T20:46:26Z","receivedAt":"2008-08-02T20:46:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for a quick turnaround.\n"}]}