{"thread":{"id":"9743","subject":"[PATCH] Teach \"git remote add\" a mirror mode","startedAt":"2007-09-02T11:45:22Z","lastAt":"2007-09-03T11:50:03Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"52189","messageId":"Pine.LNX.4.64.0709021245040.28586@racer.site","threadId":"9743","inReplyTo":null,"subject":"[PATCH] Teach \"git remote add\" a mirror mode","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-02T11:45:22Z","receivedAt":"2007-09-02T11:45:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen using the \"--mirror\" option to \"git remote add\", the refs will not\nbe stored in the refs/remotes/ namespace, but in refs/heads/.\n\nThis option probably only makes sense in a bare repository.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Documentation/git-remote.txt |    6 +++++-\n git-remote.perl              |   10 +++++++++-\n 2 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 61a6022..94b9f17 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-remote'\n-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>\n+'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>\n 'git-remote' show <name>\n 'git-remote' prune <name>\n 'git-remote' update [group]\n@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.\n With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set\n up to point at remote's `<master>` branch instead of whatever\n branch the `HEAD` at the remote repository actually points at.\n++\n+In mirror mode, enabled with `--mirror`, the refs will not be stored\n+in the 'refs/remotes/' namespace, but in 'refs/heads/'.  This option\n+only makes sense in bare repositories.\n \n 'show'::\n \ndiff --git a/git-remote.perl b/git-remote.perl\nindex 01cf480..e00b340 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -276,9 +276,13 @@ sub add_remote {\n \t$git->command('config', \"remote.$name.url\", $url);\n \tmy $track = $opts->{'track'} || [\"*\"];\n \n+\tmy $prefix = \"refs/remotes/$name/\";\n+\tif ($opts->{'mirror'}) {\n+\t\t$prefix = \"refs/heads/\";\n+\t}\n \tfor (@$track) {\n \t\t$git->command('config', '--add', \"remote.$name.fetch\",\n-\t\t\t      \"+refs/heads/$_:refs/remotes/$name/$_\");\n+\t\t\t      \"+refs/heads/$_:$prefix/$_\");\n \t}\n \tif ($opts->{'fetch'}) {\n \t\t$git->command('fetch', $name);\n@@ -409,6 +413,10 @@ elsif ($ARGV[0] eq 'add') {\n \t\t\tshift @ARGV;\n \t\t\tnext;\n \t\t}\n+\t\tif ($opt eq '--mirror') {\n+\t\t\t$opts{'mirror'} = 1;\n+\t\t\tnext;\n+\t\t}\n \t\tadd_usage();\n \t}\n \tif (@ARGV != 3) {\n-- \n1.5.3.2.g46909\n"},{"id":"52252","messageId":"7vk5r8q1yz.fsf@gitster.siamese.dyndns.org","threadId":"9743","inReplyTo":"Pine.LNX.4.64.0709021245040.28586@racer.site","subject":"Re: [PATCH] Teach \"git remote add\" a mirror mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-02T19:52:36Z","receivedAt":"2007-09-02T19:52:36Z","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> When using the \"--mirror\" option to \"git remote add\", the refs will not\n> be stored in the refs/remotes/ namespace, but in refs/heads/.\n\nI suspect people'd prefer \"+refs/*:refs/*\" for a repo truly\nmirroring another.\n"},{"id":"52255","messageId":"Pine.LNX.4.64.0709022101290.28586@racer.site","threadId":"9743","inReplyTo":"7vk5r8q1yz.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Teach \"git remote\" a mirror mode","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-02T20:10:14Z","receivedAt":"2007-09-02T20:10:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen using the \"--mirror\" option to \"git remote add\", the refs will not\nbe stored in the refs/remotes/ namespace, but in the same location as\non the remote side.\n\nThis option probably only makes sense in a bare repository.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Sun, 2 Sep 2007, Junio C Hamano wrote:\n\n\t> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\t> \n\t> > When using the \"--mirror\" option to \"git remote add\", the refs \n\t> > will not be stored in the refs/remotes/ namespace, but in \n\t> > refs/heads/.\n\t> \n\t> I suspect people'd prefer \"+refs/*:refs/*\" for a repo truly\n\t> mirroring another.\n\n\tYes, you're right.\n\n Documentation/git-remote.txt |    6 +++++-\n git-remote.perl              |    8 +++++++-\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 61a6022..94b9f17 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-remote'\n-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>\n+'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>\n 'git-remote' show <name>\n 'git-remote' prune <name>\n 'git-remote' update [group]\n@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.\n With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set\n up to point at remote's `<master>` branch instead of whatever\n branch the `HEAD` at the remote repository actually points at.\n++\n+In mirror mode, enabled with `--mirror`, the refs will not be stored\n+in the 'refs/remotes/' namespace, but in 'refs/heads/'.  This option\n+only makes sense in bare repositories.\n \n 'show'::\n \ndiff --git a/git-remote.perl b/git-remote.perl\nindex 01cf480..f6f283e 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -278,7 +278,9 @@ sub add_remote {\n \n \tfor (@$track) {\n \t\t$git->command('config', '--add', \"remote.$name.fetch\",\n-\t\t\t      \"+refs/heads/$_:refs/remotes/$name/$_\");\n+\t\t\t\t$opts->{'mirror'} ?\n+\t\t\t\t\"+refs/$_:refs/$_\" :\n+\t\t\t\t\"+refs/heads/$_:refs/remotes/$name/$_\");\n \t}\n \tif ($opts->{'fetch'}) {\n \t\t$git->command('fetch', $name);\n@@ -409,6 +411,10 @@ elsif ($ARGV[0] eq 'add') {\n \t\t\tshift @ARGV;\n \t\t\tnext;\n \t\t}\n+\t\tif ($opt eq '--mirror') {\n+\t\t\t$opts{'mirror'} = 1;\n+\t\t\tnext;\n+\t\t}\n \t\tadd_usage();\n \t}\n \tif (@ARGV != 3) {\n-- \n1.5.3.2.g46909\n"},{"id":"52313","messageId":"7vmyw4majd.fsf@gitster.siamese.dyndns.org","threadId":"9743","inReplyTo":"Pine.LNX.4.64.0709022101290.28586@racer.site","subject":"Re: [PATCH] Teach \"git remote\" a mirror mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-03T08:13:26Z","receivedAt":"2007-09-03T08:13:26Z","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> When using the \"--mirror\" option to \"git remote add\", the refs will not\n> be stored in the refs/remotes/ namespace, but in the same location as\n> on the remote side.\n\nThanks.  With this and the \"git remote rm\" I think we would be\nin much better shape.  Another thing that would be needed\nfurther before we can rewriting git-clone would be the \"guessing\nwhere HEAD points at\" and we would be in a very good shape.\n\nI notice you did not add any tests, though...\n"},{"id":"52343","messageId":"Pine.LNX.4.64.0709031249080.28586@racer.site","threadId":"9743","inReplyTo":"7vmyw4majd.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Teach \"git remote\" a mirror mode","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-03T11:50:03Z","receivedAt":"2007-09-03T11:50:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 3 Sep 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > When using the \"--mirror\" option to \"git remote add\", the refs will \n> > not be stored in the refs/remotes/ namespace, but in the same location \n> > as on the remote side.\n> \n> Thanks.  With this and the \"git remote rm\" I think we would be in much \n> better shape.  Another thing that would be needed further before we can \n> rewriting git-clone would be the \"guessing where HEAD points at\" and we \n> would be in a very good shape.\n\nOkay, that should be fixable.\n\n> I notice you did not add any tests, though...\n\nYou noticed.  Darn.  ;-)\n\nI briefly considered it, but decided I did not have the energy to cut a \ntest suite for \"git remote\"...  Will do so today.\n\nCiao,\nDscho\n"}]}