@matheusbsbs / matheus-bagliano / commits / 3894439022
Fork 0

Teach "git remote" a mirror mode

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Sep 2, 2007 at 21:10 UTC 38944390220425cc3c4208dd31172397e7f18e8c
2 files changed +12 -2
Documentation/git-remote.txt
+5 -1
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git-remote'
13 -'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url>
13 +'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>
14 'git-remote' show <name>
15 'git-remote' prune <name>
16 'git-remote' update [group]
@@ -45,6 +45,10 @@ multiple branches without grabbing all branches.
45 With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
46 up to point at remote's `<master>` branch instead of whatever
47 branch the `HEAD` at the remote repository actually points at.
48 ++
49 +In mirror mode, enabled with `--mirror`, the refs will not be stored
50 +in the 'refs/remotes/' namespace, but in 'refs/heads/'. This option
51 +only makes sense in bare repositories.
52
53 'show'::
54
git-remote.perl
+7 -1
@@ -278,7 +278,9 @@ sub add_remote {
278
279 for (@$track) {
280 $git->command('config', '--add', "remote.$name.fetch",
281 - "+refs/heads/$_:refs/remotes/$name/$_");
281 + $opts->{'mirror'} ?
282 + "+refs/$_:refs/$_" :
283 + "+refs/heads/$_:refs/remotes/$name/$_");
284 }
285 if ($opts->{'fetch'}) {
286 $git->command('fetch', $name);
@@ -409,6 +411,10 @@ elsif ($ARGV[0] eq 'add') {
411 shift @ARGV;
412 next;
413 }
414 + if ($opt eq '--mirror') {
415 + $opts{'mirror'} = 1;
416 + next;
417 + }
418 add_usage();
419 }
420 if (@ARGV != 3) {