{"thread":{"id":"6212","subject":"[RFC] git-remote","startedAt":"2007-01-03T21:40:56Z","lastAt":"2007-01-10T18:13:20Z","messageCount":16,"participants":["Junio C Hamano","Jakub Narebski","Shawn O. Pearce","Santi Béjar","Johannes Schindelin","Carl Worth","J. Bruce Fields","Andreas Ericsson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"30774","messageId":"7vfyarokk7.fsf@assigned-by-dhcp.cox.net","threadId":"6212","inReplyTo":null,"subject":"[RFC] git-remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-03T21:40:56Z","receivedAt":"2007-01-03T21:40:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It might be handy to have a single command that helps you manage\nyour configuration that relates to downloading from remote\nrepositories.  This currently does only about 20% of what I want\nit to do.\n\n\t$ git remote\n\nshows the list of 'remotes' you have defined somewhere, and\n\n\t$ git remote origin\n\nshows the details about the named remote (in this case\n\"origin\").  How the branches are tracked, if you have a \ntracking branch that is stale, etc.\n\n\t$ git add another git://git.kernel.org/pub/...\n\ndefines the default remote.another.url and remote.another.fetch\nentries just like a clone does; you can say \"git fetch another\"\nafterwards.\n\nFor it to be useful, I think it should be enhanced to:\n\n - check overlaps of tracking branches and warn;\n\n - offer to remove stale tracking branches in one go;\n\n - offer ways to remove or rename remote;\n\n - give different levels of verbosity in its 'show' command,\n   especially if ls-remote is run;\n\n - offer ways to update an existing remote, perhaps have an\n   interactive mode;\n\nOther enhancements might be also possible, but I do not think of\nanything that is absolutely necessary other than the above right\nnow.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Makefile        |    2 +-\n git-remote.perl |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 261 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fa1a022..ea07634 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -179,7 +179,7 @@ SCRIPT_SH = \\\n SCRIPT_PERL = \\\n \tgit-add--interactive.perl \\\n \tgit-archimport.perl git-cvsimport.perl git-relink.perl \\\n-\tgit-cvsserver.perl \\\n+\tgit-cvsserver.perl git-remote.perl \\\n \tgit-svnimport.perl git-cvsexportcommit.perl \\\n \tgit-send-email.perl git-svn.perl\n \ndiff --git a/git-remote.perl b/git-remote.perl\nnew file mode 100755\nindex 0000000..b0ec838\n--- /dev/null\n+++ b/git-remote.perl\n@@ -0,0 +1,260 @@\n+#!/usr/bin/perl -w\n+\n+use Git;\n+my $git = Git->repository();\n+\n+sub add_remote_config {\n+\tmy ($hash, $name, $what, $value) = @_;\n+\tif ($what eq 'url') {\n+\t\tif (exists $hash->{$name}{'URL'}) {\n+\t\t\tprint STDERR \"Warning: more than one remote.$name.url\\n\";\n+\t\t}\n+\t\t$hash->{$name}{'URL'} = $value;\n+\t}\n+\telsif ($what eq 'fetch') {\n+\t\t$hash->{$name}{'FETCH'} ||= [];\n+\t\tpush @{$hash->{$name}{'FETCH'}}, $value;\n+\t}\n+\tif (!exists $hash->{$name}{'SOURCE'}) {\n+\t\t$hash->{$name}{'SOURCE'} = 'config';\n+\t}\n+}\n+\n+sub add_remote_remotes {\n+\tmy ($hash, $file, $name) = @_;\n+\n+\tif (exists $hash->{$name}) {\n+\t\t$hash->{$name}{'WARNING'} = 'ignored due to config';\n+\t\treturn;\n+\t}\n+\n+\tmy $fh;\n+\tif (!open($fh, '<', $file)) {\n+\t\tprint STDERR \"Warning: cannot open $file\\n\";\n+\t\treturn;\n+\t}\n+\tmy $it = { 'SOURCE' => 'remotes' };\n+\t$hash->{$name} = $it;\n+\twhile (<$fh>) {\n+\t\tchomp;\n+\t\tif (/^URL:\\s*(.*)$/) {\n+\t\t\t# Having more than one is Ok -- it is used for push.\n+\t\t\tif (! exists $it->{'URL'}) {\n+\t\t\t\t$it->{'URL'} = $1;\n+\t\t\t}\n+\t\t}\n+\t\telsif (/^Push:\\s*(.*)$/) {\n+\t\t\t; # later\n+\t\t}\n+\t\telsif (/^Pull:\\s*(.*)$/) {\n+\t\t\t$it->{'FETCH'} ||= [];\n+\t\t\tpush @{$it->{'FETCH'}}, $1;\n+\t\t}\n+\t\telsif (/^\\#/) {\n+\t\t\t; # ignore\n+\t\t}\n+\t\telse {\n+\t\t\tprint STDERR \"Warning: funny line in $file: $_\\n\";\n+\t\t}\n+\t}\n+\tclose($fh);\n+}\n+\n+sub list_remote {\n+\tmy ($git) = @_;\n+\tmy %seen = ();\n+\n+\tfor ($git->command(qw(repo-config --get-regexp), '^remote\\.')) {\n+\t\tif (/^remote\\.([^.]*)\\.(\\S*)\\s+(.*)$/) {\n+\t\t\tadd_remote_config(\\%seen, $1, $2, $3);\n+\t\t}\n+\t}\n+\n+\tmy $dir = $git->repo_path() . \"/remotes\";\n+\tif (opendir(my $dh, $dir)) {\n+\t\tlocal $_;\n+\t\twhile ($_ = readdir($dh)) {\n+\t\t\tchomp;\n+\t\t\tnext if (! -f \"$dir/$_\" || ! -r _);\n+\t\t\tadd_remote_remotes(\\%seen, \"$dir/$_\", $_);\n+\t\t}\n+\t}\n+\n+\treturn \\%seen;\n+}\n+\n+sub add_branch_config {\n+\tmy ($hash, $name, $what, $value) = @_;\n+\tif ($what eq 'remote') {\n+\t\tif (exists $hash->{$name}{'REMOTE'}) {\n+\t\t\tprint STDERR \"Warning: more than one branch.$name.remote\\n\";\n+\t\t}\n+\t\t$hash->{$name}{'REMOTE'} = $value;\n+\t}\n+\telsif ($what eq 'merge') {\n+\t\t$hash->{$name}{'MERGE'} ||= [];\n+\t\tpush @{$hash->{$name}{'MERGE'}}, $value;\n+\t}\n+}\n+\n+sub list_branch {\n+\tmy ($git) = @_;\n+\tmy %seen = ();\n+\tfor ($git->command(qw(repo-config --get-regexp), '^branch\\.')) {\n+\t\tif (/^branch\\.([^.]*)\\.(\\S*)\\s+(.*)$/) {\n+\t\t\tadd_branch_config(\\%seen, $1, $2, $3);\n+\t\t}\n+\t}\n+\n+\treturn \\%seen;\n+}\n+\n+my $remote = list_remote($git);\n+my $branch = list_branch($git);\n+\n+sub update_ls_remote {\n+\tmy ($harder, $info) = @_;\n+\n+\treturn if (($harder == 0) ||\n+\t\t   (($harder == 1) && exists $info->{'LS_REMOTE'}));\n+\n+\tmy @ref = map {\n+\t\ts|^[0-9a-f]{40}\\s+refs/heads/||;\n+\t\t$_;\n+\t} $git->command(qw(ls-remote --heads), $info->{'URL'});\n+\t$info->{'LS_REMOTE'} = \\@ref;\n+}\n+\n+sub show_wildcard_mapping {\n+\tmy ($forced, $ours, $ls) = @_;\n+\tmy %refs;\n+\tfor (@$ls) {\n+\t\t$refs{$_} = 01; # bit #0 to say \"they have\"\n+\t}\n+\tfor ($git->command('for-each-ref', \"refs/remotes/$ours\")) {\n+\t\tchomp;\n+\t\tnext unless (s|^[0-9a-f]{40}\\s[a-z]+\\srefs/remotes/$ours/||);\n+\t\tnext if ($_ eq 'HEAD');\n+\t\t$refs{$_} ||= 0;\n+\t\t$refs{$_} |= 02; # bit #1 to say \"we have\"\n+\t}\n+\tmy (@new, @stale, @tracked);\n+\tfor (sort keys %refs) {\n+\t\tmy $have = $refs{$_};\n+\t\tif ($have == 1) {\n+\t\t\tpush @new, $_;\n+\t\t}\n+\t\telsif ($have == 2) {\n+\t\t\tpush @stale, $_;\n+\t\t}\n+\t\telsif ($have == 3) {\n+\t\t\tpush @tracked, $_;\n+\t\t}\n+\t}\n+\tif (@new) {\n+\t\tprint \"  New remote branches (next fetch will store in remotes/$ours)\\n\";\n+\t\tprint \"    @new\\n\";\n+\t}\n+\tif (@stale) {\n+\t\tprint \"  Stale tracking branches in remotes/$ours (you'd better remove them)\\n\";\n+\t\tprint \"    @stale\\n\";\n+\t}\n+\tif (@tracked) {\n+\t\tprint \"  Tracked remote branches\\n\";\n+\t\tprint \"    @tracked\\n\";\n+\t}\n+}\n+\n+sub show_mapping {\n+\tmy ($name, $info) = @_;\n+\tmy $fetch = $info->{'FETCH'};\n+\tmy $ls = $info->{'LS_REMOTE'};\n+\tmy (@stale, @tracked);\n+\n+\tfor (@$fetch) {\n+\t\tnext unless (/(\\+)?([^:]+):(.*)/);\n+\t\tmy ($forced, $theirs, $ours) = ($1, $2, $3);\n+\t\tif ($theirs eq 'refs/heads/*' &&\n+\t\t    $ours =~ /^refs\\/remotes\\/(.*)\\/\\*$/) {\n+\t\t\t# wildcard mapping\n+\t\t\tshow_wildcard_mapping($forced, $1, $ls);\n+\t\t}\n+\t\telsif ($theirs =~ /\\*/ || $ours =~ /\\*/) {\n+\t\t\tprint STDERR \"Warning: unrecognized mapping in remotes.$name.fetch: $_\\n\";\n+\t\t}\n+\t\telsif ($theirs =~ s|^refs/heads/||) {\n+\t\t\tif (!grep { $_ eq $theirs } @$ls) {\n+\t\t\t\tpush @stale, $theirs;\n+\t\t\t}\n+\t\t\telsif ($ours ne '') {\n+\t\t\t\tpush @tracked, $theirs;\n+\t\t\t}\n+\t\t}\n+\t}\n+\tif (@stale) {\n+\t\tprint \"  Stale tracking branches in remotes/$name (you'd better remove them)\\n\";\n+\t\tprint \"    @stale\\n\";\n+\t}\n+\tif (@tracked) {\n+\t\tprint \"  Tracked remote branches\\n\";\n+\t\tprint \"    @tracked\\n\";\n+\t}\n+}\n+\n+sub show_remote {\n+\tmy ($name, $ls_remote) = @_;\n+\tif (!exists $remote->{$name}) {\n+\t\tprint STDERR \"No such remote $name\\n\";\n+\t\treturn;\n+\t}\n+\tmy $info = $remote->{$name};\n+\tupdate_ls_remote($ls_remote, $info);\n+\n+\tprint \"* remote $name\\n\";\n+\tprint \"  URL: $info->{'URL'}\\n\";\n+\tfor my $branchname (sort keys %$branch) {\n+\t\tnext if ($branch->{$branchname}{'REMOTE'} ne $name);\n+\t\tmy @merged = map {\n+\t\t\ts|^refs/heads/||;\n+\t\t\t$_;\n+\t\t} split(' ',\"@{$branch->{$branchname}{'MERGE'}}\");\n+\t\tnext unless (@merged);\n+\t\tprint \"  Remote branch(es) merged with 'git pull' while on branch $branchname\\n\";\n+\t\tprint \"    @merged\\n\";\n+\t}\n+\tif ($info->{'LS_REMOTE'}) {\n+\t\tshow_mapping($name, $info);\n+\t}\n+}\n+\n+sub add_remote {\n+\tmy ($name, $url) = @_;\n+\tif (exists $remote->{$name}) {\n+\t\tprint STDERR \"remote $name already exists.\\n\";\n+\t\texit(1);\n+\t}\n+\t$git->command('repo-config', \"remote.$name.url\", $url);\n+\t$git->command('repo-config', \"remote.$name.fetch\",\n+\t\t      \"+refs/heads/*:refs/remotes/$name/*\");\n+}\n+\n+if (!@ARGV) {\n+\tfor (sort keys %$remote) {\n+\t\tprint \"$_\\n\";\n+\t}\n+}\n+elsif ($ARGV[0] eq 'show') {\n+\tif (@ARGV != 2) {\n+\t\tprint STDERR \"Usage: git remote show <remote>\\n\";\n+\t\texit(1);\n+\t}\n+\tshow_remote($ARGV[1], 1);\n+}\n+elsif ($ARGV[0] eq 'add') {\n+\tif (@ARGV != 3) {\n+\t\tprint STDERR \"Usage: git remote show <name> <url>\\n\";\n+\t\texit(1);\n+\t}\n+\tadd_remote($ARGV[1], $ARGV[2]);\n+}\n+\n-- \n1.5.0.rc0.gcc26\n"},{"id":"30776","messageId":"enh953$7l0$1@sea.gmane.org","threadId":"6212","inReplyTo":"7vfyarokk7.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-01-03T22:05:24Z","receivedAt":"2007-01-03T22:05:24Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> +elsif ($ARGV[0] eq 'add') {\n> +       if (@ARGV != 3) {\n> +               print STDERR \"Usage: git remote show <name> <url>\\n\";\n\nI think you meant to write here \"Usage: git remote add <name> <url>\\n\";\n(\"add\" instead of \"show\").\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"30854","messageId":"20070105030245.GC14042@spearce.org","threadId":"6212","inReplyTo":"7vfyarokk7.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-05T03:02:45Z","receivedAt":"2007-01-05T03:02:45Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> It might be handy to have a single command that helps you manage\n> your configuration that relates to downloading from remote\n> repositories.  This currently does only about 20% of what I want\n> it to do.\n> \n> \t$ git remote\n\nThis is pretty cool.  It would be nice if something like it was\nin 1.5.0.  ;-)\n\n-- \nShawn.\n"},{"id":"30856","messageId":"7vodpejhmt.fsf@assigned-by-dhcp.cox.net","threadId":"6212","inReplyTo":"20070105030245.GC14042@spearce.org","subject":"Re: [RFC] git-remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-05T03:07:38Z","receivedAt":"2007-01-05T03:07:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> It might be handy to have a single command that helps you manage\n>> your configuration that relates to downloading from remote\n>> repositories.  This currently does only about 20% of what I want\n>> it to do.\n>> \n>> \t$ git remote\n>\n> This is pretty cool.  It would be nice if something like it was\n> in 1.5.0.  ;-)\n\nHmph.\n\nBy the way, do you have comments on my counterproposal for\nlockfile fix?\n"},{"id":"30857","messageId":"20070105031715.GE14042@spearce.org","threadId":"6212","inReplyTo":"7vodpejhmt.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-05T03:17:15Z","receivedAt":"2007-01-05T03:17:15Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> By the way, do you have comments on my counterproposal for\n> lockfile fix?\n\nYea, see the email in that thread.\n\nSorry for the lag.  I've been sidetracked by a new and fairly useless\n(to me anyway) project that I have to put a lot of time into now.\nArrgh.  At least I have a sound version control system to track\nits source code in.  :-)\n\n-- \nShawn.\n"},{"id":"30882","messageId":"8aa486160701050459p4da586cdk2c2ddaabda5b4ca7@mail.gmail.com","threadId":"6212","inReplyTo":"7vfyarokk7.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-01-05T12:59:25Z","receivedAt":"2007-01-05T12:59:25Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"+1. And much better than my RFC for \"git clone --add\".\n\nJust some comments. I know it's in its early shape, tell me if you\nwant this kind of comments later.\n\n* I think it is more coherent to list the tracked branches first and\nsecond the \"branch merges\".\n\n* In \"git remote add <name> <remote>\": git could use the remote url to\ndeduce a <name>, like what git-clone does.\n\n* If a branch does not have a branch.<name>.remote git-remote does not\ndefault it to \"origin\" and sends an:\n\nUse of uninitialized value in string ne at\n/home/santi/usr/stow/git/bin/git-remote line 222.\n\nMaybe, in addition to this, git should require a branch.<name>.remote.\n\n* With the config:\n\n[remote \"origin\"]\n        url = git://git2.kernel.org/pub/scm/git/git.git\n        fetch = master:refs/remotes/origin/master\n        fetch = next:refs/remotes/origin/next\n        fetch = +refs/heads/pu:refs/remotes/origin/pu\n        fetch = refs/heads/*:refs/remotes/origin/*\n\n[branch \"next\"]\n        merge=next\n\nIt outputs something as:\n* remote origin\n  URL: git://git2.kernel.org/pub/scm/git/git.git\n  Tracked remote branches\n    html maint man master next pu todo\n  Tracked remote branches\n    pu\n\n* The first \"Tracked ...\" is for the wildcards and the second for the\nexplicit fetch. Maybe it should join the two or mark different as:\n\n  Implicit tracked ...\n  Tracked ...\n\n* The next and master branches are missing because they are written\nwithout the refs/heads/ prefix. And for this reason there is no:\n\nRemote branch(es) merged with 'git pull' while on branch next\n  next\n\n(and the absence of branch.next.remote).\n\n* In addition I would reformat this as:\n\nMerges with 'git pull' while on branch:\n  \"next\" merges \"next\"\n  \"topic\" merges \"master\"\n  ...\n\nThat's all for today :)\n\nSanti\n"},{"id":"30884","messageId":"Pine.LNX.4.63.0701051448560.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6212","inReplyTo":"8aa486160701050459p4da586cdk2c2ddaabda5b4ca7@mail.gmail.com","subject":"Re: [RFC] git-remote","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-05T13:53:18Z","receivedAt":"2007-01-05T13:53:18Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 5 Jan 2007, Santi Béjar wrote:\n\n> * In \"git remote add <name> <remote>\": git could use the remote url to \n> deduce a <name>, like what git-clone does.\n\nThat does not make any sense. For example, I track \n\"git://git.kernel.org/.../git.git\" and \"192.168.0.128:gits/git.git\". \nSomething very similar applies to the host name: if you track multiple \nLinux repos, chances are that most of them are on git.kernel.org.\n\nI guess _if_ you have more than one upstream you are tracking (which is \nnot the most common case, but hey, git-remote is for exactly that case) it \nis not uncommon to have similar urls.\n\nIMHO Junio's proposal is as good as it gets.\n\nCiao,\nDscho\n"},{"id":"30899","messageId":"8aa486160701051153h52a93c16k2b190f58e652cb2e@mail.gmail.com","threadId":"6212","inReplyTo":"Pine.LNX.4.63.0701051448560.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC] git-remote","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-01-05T19:53:22Z","receivedAt":"2007-01-05T19:53:22Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On 1/5/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Fri, 5 Jan 2007, Santi Béjar wrote:\n>\n> > * In \"git remote add <name> <remote>\": git could use the remote url to\n> > deduce a <name>, like what git-clone does.\n>\n> That does not make any sense. For example, I track\n> \"git://git.kernel.org/.../git.git\" and \"192.168.0.128:gits/git.git\".\n> Something very similar applies to the host name: if you track multiple\n> Linux repos, chances are that most of them are on git.kernel.org.\n>\n> I guess _if_ you have more than one upstream you are tracking (which is\n> not the most common case, but hey, git-remote is for exactly that case) it\n> is not uncommon to have similar urls.\n>\n> IMHO Junio's proposal is as good as it gets.\n>\n\nI was talking about the default name, so you could do:\n\n$ git clone\\\ngit://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n$ cd linux-2.6\n$ git remote add \\\ngit://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-2.6.git\n$ git remote show libata-2.6\n\nSanti\n"},{"id":"30949","messageId":"87ac0xgp12.wl%cworth@cworth.org","threadId":"6212","inReplyTo":"8aa486160701051153h52a93c16k2b190f58e652cb2e@mail.gmail.com","subject":"Re: [RFC] git-remote","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2007-01-05T21:08:25Z","receivedAt":"2007-01-05T21:08:25Z","isPatch":false,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"On Fri, 5 Jan 2007 20:53:22 +0100, \"=?ISO-8859-1?Q?Santi_B=E9jar?=\" wrote:\n> I was talking about the default name, so you could do:\n>\n> $ git clone\\\n> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n> $ cd linux-2.6\n> $ git remote add \\\n> git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-2.6.git\n> $ git remote show libata-2.6\n\nYes.\n\nI'd go one further and say that it'd be really nice if git-clone could\nbe seen as equivalent, (and basically equivalent internally), to a\nsimple sequence of steps that could be performed manually. Something\nlike:\n\n\tname=$(basename $url)\n\tmkdir $name\n\tcd $name\n\tgit init-db\n\tgit remote add $url\n\tgit pull $name\n\nI haven't played with the new git-remote stuff at all yet, but the\nrest of the above does work already, (but for a \"warning: no common\ncommits\" message). The only thing missing compared to git-clone is the\nremotes configuration. So if the new git-remote can provide behavior\nequivalent to what git clone provides, that would be excellent.\n\nIf for one have often wanted the ability to easily add a second remote\nas if from git-clone.\n\n-Carl\n"},{"id":"30952","messageId":"7vvejkap9j.fsf@assigned-by-dhcp.cox.net","threadId":"6212","inReplyTo":"87ac0xgp12.wl%cworth@cworth.org","subject":"Re: [RFC] git-remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-06T01:59:52Z","receivedAt":"2007-01-06T01:59:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Worth <cworth@cworth.org> writes:\n\n> On Fri, 5 Jan 2007 20:53:22 +0100, \"=?ISO-8859-1?Q?Santi_B=E9jar?=\" wrote:\n>> I was talking about the default name, so you could do:\n>>\n>> $ git clone\\\n>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n>> $ cd linux-2.6\n>> $ git remote add \\\n>> git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-2.6.git\n>> $ git remote show libata-2.6\n>\n> Yes.\n\nNo.  Because...\n\n> I'd go one further and say that it'd be really nice if git-clone could\n> be seen as equivalent, (and basically equivalent internally), to a\n> simple sequence of steps that could be performed manually. Something\n> like:\n>\n> \tname=$(basename $url)\n> \tmkdir $name\n> \tcd $name\n> \tgit init-db\n> \tgit remote add $url\n> \tgit pull $name\n\nyou could say \"git remote add $name $url\" here, having computed\n$name already.\n\nBut you guessed what I was driving at right ;-).\n"},{"id":"31168","messageId":"87lkkdyvuj.wl%cworth@cworth.org","threadId":"6212","inReplyTo":"7vvejkap9j.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2007-01-08T22:52:52Z","receivedAt":"2007-01-08T22:52:52Z","isPatch":false,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"On Fri, 05 Jan 2007 17:59:52 -0800, Junio C Hamano wrote:\n> > \tgit init-db\n> > \tgit remote add $url\n> > \tgit pull $name\n>\n> you could say \"git remote add $name $url\" here, having computed\n> $name already.\n\nThough I guess clone would actually be doing the equivalent of:\n\n\tgit remote add origin $url\n\ncorrect?\n\nSo that undercuts my argument a bit. If clone is always just using\n\"origin\" for the remote that it creates then it's harder to justify\nmaking \"remote add\" use part of the URL for the name. It would seem\nconvenient to be able to do:\n\n\tgit remote add git://hosting.org/$project/$maintainer1\n\tgit remote add git://hosting.org/$project/$maintainer2\n\nbut I guess that wouldn't help much if the project were organized\nsuch that what's need is actually:\n\n\tgit remote add $maintainer1 git://hosting.org/~$maintainer1/$project\n\tgit remote add $maintainer2 git://hosting.org/~$maintainer2/$project\n\nBut the other piece is that clone does one thing more than setting up\na remote. It also creates a local branch \"master\" that is configured\nwith \"remote\" and \"merge\" entries. There's still no simple command\nthat sets this up that could be added to make the above list of steps\nfor a \"manual clone\" complete is there?\n\nAnd by \"simple\" I mean something other than:\n\n\tgit repo-config branch.master.remote origin\n\tgit repo-config branch.master.merge refs/heads/master\n\nIt seems we're still missing a simple command that would create this\ncommonly desired arrangement. The only real input here is a local\nbranch name and a corresponding remote-tracking branch, (from which\nthe values for remote and merge could be determined). We've mentioned\nbefore that \"git checkout newbranch remote-tracking-branch\" already\naccepts those two pieces of information, so maybe we just want an\noption there to create this extra configuration for further\ntracking/merging.\n\n-Carl\n\nPS. It's probably too late, since \"remote\" already appears in\n.git/remotes and in branch.*.remote entries in .git/config, but I do\nhave to say that \"git remote add\" looks really odd. The most natural\nway to parse that is with \"remote\" as an adjective---so perhaps\ninterpreting this as a variant of \"git add\" that does something on the\nremote side?\n\nPreviously, when I've wanted the functionality of what is now \"remote\nadd\" I've imagined it as a variant of \"git clone\" that would clone\n\"into\" my existing repository (with a new \"remote\" name) rather than\ncreating a new repository. Or maybe this could be some new verb, (I'd\nlike something like \"git track url [name]\" perhaps. Though using a\nverb would make it harder to add other actions beyond creation.\n\nAnyway, there's some naming feedback, but like I said, it might be too\nlate to be used at all.\n"},{"id":"31190","messageId":"20070109042851.GF1686@fieldses.org","threadId":"6212","inReplyTo":"7vfyarokk7.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-01-09T04:28:51Z","receivedAt":"2007-01-09T04:28:51Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Wed, Jan 03, 2007 at 01:40:56PM -0800, Junio C Hamano wrote:\n> \t$ git add another git://git.kernel.org/pub/...\n> \n> defines the default remote.another.url and remote.another.fetch\n> entries just like a clone does; you can say \"git fetch another\"\n> afterwards.\n\nNifty.\n\nWould it make sense for \"git add\" to do the initial fetch as well?\n\nThat'd also help catch any typos in the URL early--the first time I used\nthis I mistyped the URL, then had to delete the configuration by hand\nafter I found the problem....\n\nHow about this as a man page?\n\n--b.\n\nDocumentation: add git-remote man page\n\nAdd a preliminary man page for git-remote.\n\nSigned-off-by: \"J. Bruce Fields\" <bfields@citi.umich.edu>\n---\n Documentation/git-remote.txt |   76 ++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 76 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nnew file mode 100644\nindex 0000000..7d6663e\n--- /dev/null\n+++ b/Documentation/git-remote.txt\n@@ -0,0 +1,76 @@\n+git-remote(1)\n+============\n+\n+NAME\n+----\n+git-remote - manage set of tracked repositories\n+\n+\n+SYNOPSIS\n+--------\n+[verse]\n+'git-remote'\n+'git-remote' add <name> <url>\n+'git-remote' show <name>\n+\n+DESCRIPTION\n+-----------\n+\n+Manage the set of repositories (\"remotes\") whose branches you track.\n+\n+With no arguments, shows a list of existing remotes.\n+\n+In the second form, adds a remote named <name> for the repository at\n+<url>.  The command `git fetch <name>` can then be used to create and\n+update remote-tracking branches <name>/<branch>.\n+\n+In the third form, gives some information about the remote <name>.\n+\n+The remote configuration is achieved using the `remote.origin.url` and\n+`remote.origin.fetch` configuration variables.  (See\n+gitlink:git-repo-config[1]).\n+\n+Examples\n+--------\n+\n+Add a new remote, fetch, and check out a branch from it:\n+\n+------------\n+$ git remote\n+origin\n+$ git branch -r\n+origin/master\n+$ git remote add linux-nfs git://linux-nfs.org/pub/nfs-2.6.git\n+$ git remote\n+linux-nfs\n+origin\n+$ git fetch\n+* refs/remotes/linux-nfs/master: storing branch 'master' ...\n+  commit: bf81b46\n+$ git branch -r\n+origin/master\n+linux-nfs/master\n+$ git checkout -b nfs linux-nfs/master\n+...\n+------------\n+\n+See Also\n+--------\n+gitlink:git-fetch[1]\n+gitlink:git-branch[1]\n+gitlink:git-repo-config[1]\n+\n+Author\n+------\n+Written by Junio Hamano \n+\n+\n+Documentation\n+--------------\n+Documentation by J. Bruce Fields and the git-list <git@vger.kernel.org>.\n+\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\n-- \n1.4.4.4.g4083\n"},{"id":"31199","messageId":"7vvejgsqbx.fsf@assigned-by-dhcp.cox.net","threadId":"6212","inReplyTo":"20070109042851.GF1686@fieldses.org","subject":"Re: [RFC] git-remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-09T05:48:34Z","receivedAt":"2007-01-09T05:48:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"J. Bruce Fields\" <bfields@fieldses.org> writes:\n\n> How about this as a man page?\n>\n> --b.\n>\n> Documentation: add git-remote man page\n\nThanks.\n"},{"id":"31200","messageId":"7vr6u4sq9e.fsf@assigned-by-dhcp.cox.net","threadId":"6212","inReplyTo":"20070109042851.GF1686@fieldses.org","subject":"Re: [RFC] git-remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-09T05:50:05Z","receivedAt":"2007-01-09T05:50:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"J. Bruce Fields\" <bfields@fieldses.org> writes:\n\n> Would it make sense for \"git add\" to do the initial fetch as well?\n\nIt would be handy.\n\nAnd perhaps we could make it the default but with a command line\noverride to help disconnected people.\n"},{"id":"31216","messageId":"45A35EED.5090105@op5.se","threadId":"6212","inReplyTo":"7vr6u4sq9e.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] git-remote","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-01-09T09:22:53Z","receivedAt":"2007-01-09T09:22:53Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> \"J. Bruce Fields\" <bfields@fieldses.org> writes:\n> \n>> Would it make sense for \"git add\" to do the initial fetch as well?\n> \n> It would be handy.\n> \n> And perhaps we could make it the default but with a command line\n> override to help disconnected people.\n> \n\nI'd rather do it the other way around (\"--fetch\" switch) and if that \nwasn't supplied, tell the user that he should now run\n\n\tgit fetch $whatever_name_was_supplied\n\nThe reason being it's easier to fetch afterwards than it is to undo the \nfetch if you didn't mean to do it straight away. Judging by its other \nuses, I also wouldn't expect the command to actually work over the network.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"31402","messageId":"20070110181320.GA20108@fieldses.org","threadId":"6212","inReplyTo":"45A35EED.5090105@op5.se","subject":"Re: [RFC] git-remote","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-01-10T18:13:20Z","receivedAt":"2007-01-10T18:13:20Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Tue, Jan 09, 2007 at 10:22:53AM +0100, Andreas Ericsson wrote:\n> Junio C Hamano wrote:\n> >\"J. Bruce Fields\" <bfields@fieldses.org> writes:\n> >\n> >>Would it make sense for \"git add\" to do the initial fetch as well?\n> >\n> >It would be handy.\n> >\n> >And perhaps we could make it the default but with a command line\n> >override to help disconnected people.\n> >\n> \n> I'd rather do it the other way around (\"--fetch\" switch) and if that \n> wasn't supplied, tell the user that he should now run\n> \n> \tgit fetch $whatever_name_was_supplied\n> \n> The reason being it's easier to fetch afterwards than it is to undo the \n> fetch if you didn't mean to do it straight away. Judging by its other \n> uses, I also wouldn't expect the command to actually work over the network.\n\nActually, \"git remote show\" also seems to require the network, as it\ndoes an ls-remote.  That I found a little more surprising.\n\nI don't think a user should be surprised that a command that takes a url\nwould require the network.  And although I could imagine uses for \"git\nremote add\" when disconnected, I'd imagine by far the most common uses\nwould be where the user also wants to examine a remote branch\nimmediately.\n\n--b.\n"}]}