git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Teach "git remote add" a mirror mode
@ 2007-09-02 11:45 Johannes Schindelin
  2007-09-02 19:52 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2007-09-02 11:45 UTC (permalink / raw)
  To: gitster, git


When using the "--mirror" option to "git remote add", the refs will not
be stored in the refs/remotes/ namespace, but in refs/heads/.

This option probably only makes sense in a bare repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/git-remote.txt |    6 +++++-
 git-remote.perl              |   10 +++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 61a6022..94b9f17 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git-remote'
-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>
+'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>
 'git-remote' show <name>
 'git-remote' prune <name>
 'git-remote' update [group]
@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.
 With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
 up to point at remote's `<master>` branch instead of whatever
 branch the `HEAD` at the remote repository actually points at.
++
+In mirror mode, enabled with `--mirror`, the refs will not be stored
+in the 'refs/remotes/' namespace, but in 'refs/heads/'.  This option
+only makes sense in bare repositories.
 
 'show'::
 
diff --git a/git-remote.perl b/git-remote.perl
index 01cf480..e00b340 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -276,9 +276,13 @@ sub add_remote {
 	$git->command('config', "remote.$name.url", $url);
 	my $track = $opts->{'track'} || ["*"];
 
+	my $prefix = "refs/remotes/$name/";
+	if ($opts->{'mirror'}) {
+		$prefix = "refs/heads/";
+	}
 	for (@$track) {
 		$git->command('config', '--add', "remote.$name.fetch",
-			      "+refs/heads/$_:refs/remotes/$name/$_");
+			      "+refs/heads/$_:$prefix/$_");
 	}
 	if ($opts->{'fetch'}) {
 		$git->command('fetch', $name);
@@ -409,6 +413,10 @@ elsif ($ARGV[0] eq 'add') {
 			shift @ARGV;
 			next;
 		}
+		if ($opt eq '--mirror') {
+			$opts{'mirror'} = 1;
+			next;
+		}
 		add_usage();
 	}
 	if (@ARGV != 3) {
-- 
1.5.3.2.g46909

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Teach "git remote add" a mirror mode
  2007-09-02 11:45 [PATCH] Teach "git remote add" a mirror mode Johannes Schindelin
@ 2007-09-02 19:52 ` Junio C Hamano
  2007-09-02 20:10   ` [PATCH] Teach "git remote" " Johannes Schindelin
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2007-09-02 19:52 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> When using the "--mirror" option to "git remote add", the refs will not
> be stored in the refs/remotes/ namespace, but in refs/heads/.

I suspect people'd prefer "+refs/*:refs/*" for a repo truly
mirroring another.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Teach "git remote" a mirror mode
  2007-09-02 19:52 ` Junio C Hamano
@ 2007-09-02 20:10   ` Johannes Schindelin
  2007-09-03  8:13     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2007-09-02 20:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


When using the "--mirror" option to "git remote add", the refs will not
be stored in the refs/remotes/ namespace, but in the same location as
on the remote side.

This option probably only makes sense in a bare repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Sun, 2 Sep 2007, Junio C Hamano wrote:

	> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
	> 
	> > When using the "--mirror" option to "git remote add", the refs 
	> > will not be stored in the refs/remotes/ namespace, but in 
	> > refs/heads/.
	> 
	> I suspect people'd prefer "+refs/*:refs/*" for a repo truly
	> mirroring another.

	Yes, you're right.

 Documentation/git-remote.txt |    6 +++++-
 git-remote.perl              |    8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 61a6022..94b9f17 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git-remote'
-'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>
+'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>
 'git-remote' show <name>
 'git-remote' prune <name>
 'git-remote' update [group]
@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.
 With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
 up to point at remote's `<master>` branch instead of whatever
 branch the `HEAD` at the remote repository actually points at.
++
+In mirror mode, enabled with `--mirror`, the refs will not be stored
+in the 'refs/remotes/' namespace, but in 'refs/heads/'.  This option
+only makes sense in bare repositories.
 
 'show'::
 
diff --git a/git-remote.perl b/git-remote.perl
index 01cf480..f6f283e 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -278,7 +278,9 @@ sub add_remote {
 
 	for (@$track) {
 		$git->command('config', '--add', "remote.$name.fetch",
-			      "+refs/heads/$_:refs/remotes/$name/$_");
+				$opts->{'mirror'} ?
+				"+refs/$_:refs/$_" :
+				"+refs/heads/$_:refs/remotes/$name/$_");
 	}
 	if ($opts->{'fetch'}) {
 		$git->command('fetch', $name);
@@ -409,6 +411,10 @@ elsif ($ARGV[0] eq 'add') {
 			shift @ARGV;
 			next;
 		}
+		if ($opt eq '--mirror') {
+			$opts{'mirror'} = 1;
+			next;
+		}
 		add_usage();
 	}
 	if (@ARGV != 3) {
-- 
1.5.3.2.g46909

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Teach "git remote" a mirror mode
  2007-09-02 20:10   ` [PATCH] Teach "git remote" " Johannes Schindelin
@ 2007-09-03  8:13     ` Junio C Hamano
  2007-09-03 11:50       ` Johannes Schindelin
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2007-09-03  8:13 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> When using the "--mirror" option to "git remote add", the refs will not
> be stored in the refs/remotes/ namespace, but in the same location as
> on the remote side.

Thanks.  With this and the "git remote rm" I think we would be
in much better shape.  Another thing that would be needed
further before we can rewriting git-clone would be the "guessing
where HEAD points at" and we would be in a very good shape.

I notice you did not add any tests, though...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Teach "git remote" a mirror mode
  2007-09-03  8:13     ` Junio C Hamano
@ 2007-09-03 11:50       ` Johannes Schindelin
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2007-09-03 11:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Mon, 3 Sep 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > When using the "--mirror" option to "git remote add", the refs will 
> > not be stored in the refs/remotes/ namespace, but in the same location 
> > as on the remote side.
> 
> Thanks.  With this and the "git remote rm" I think we would be in much 
> better shape.  Another thing that would be needed further before we can 
> rewriting git-clone would be the "guessing where HEAD points at" and we 
> would be in a very good shape.

Okay, that should be fixable.

> I notice you did not add any tests, though...

You noticed.  Darn.  ;-)

I briefly considered it, but decided I did not have the energy to cut a 
test suite for "git remote"...  Will do so today.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-09-03 11:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-02 11:45 [PATCH] Teach "git remote add" a mirror mode Johannes Schindelin
2007-09-02 19:52 ` Junio C Hamano
2007-09-02 20:10   ` [PATCH] Teach "git remote" " Johannes Schindelin
2007-09-03  8:13     ` Junio C Hamano
2007-09-03 11:50       ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).