{"thread":{"id":"6875","subject":"[PATCH] Teach git-remote to update existing remotes by fetching from them","startedAt":"2007-02-19T04:00:00Z","lastAt":"2007-02-20T15:24:59Z","messageCount":8,"participants":["Theodore Ts'o","Junio C Hamano","Shawn O. Pearce","Alex Riesen","Theodore Tso","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"34976","messageId":"E1HIzh2-0001Ph-T2@candygram.thunk.org","threadId":"6875","inReplyTo":null,"subject":"[PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2007-02-19T04:00:00Z","receivedAt":"2007-02-19T04:00:00Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"\nThis allows users to use the command \"git remote update\" to update all\nremotes that are being tracked in the repository.\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n---\n Documentation/config.txt     |    4 ++++\n Documentation/git-remote.txt |   10 +++++++++-\n git-remote.perl              |   13 +++++++++++++\n 3 files changed, 26 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 3865535..d8e696f 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -439,6 +439,10 @@ pull.octopus::\n pull.twohead::\n \tThe default merge strategy to use when pulling a single branch.\n \n+remote.fetch::\n+\tThe list of remotes which are fetched by \"git remote update\".\n+\tSee gitlink:git-remote[1].\n+\n remote.<name>.url::\n \tThe URL of a remote repository.  See gitlink:git-fetch[1] or\n \tgitlink:git-push[1].\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex a60c31a..eed7aa2 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -13,6 +13,7 @@ SYNOPSIS\n 'git-remote' add <name> <url>\n 'git-remote' show <name>\n 'git-remote' prune <name>\n+'git-remote' update\n \n DESCRIPTION\n -----------\n@@ -40,7 +41,14 @@ Gives some information about the remote <name>.\n \n Deletes all stale tracking branches under <name>.\n These stale branches have already been removed from the remote repository\n-referenced by <name>, but are still locally available in \"remotes/<name>\".\n+referenced by <name>, but are still locally available in\n+\"remotes/<name>\".\n+\n+'update'::\n+\n+Fetch updates for the remotes in the repository.  By default all remotes\n+are updated, but this can be configured via the configuration parameter \n+'remote.fetch'.   (See gitlink:git-config[1]).\n \n \n DISCUSSION\ndiff --git a/git-remote.perl b/git-remote.perl\nindex c56c5a8..1db9901 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -303,6 +303,18 @@ elsif ($ARGV[0] eq 'show') {\n \t\tshow_remote($ARGV[$i], $ls_remote);\n \t}\n }\n+elsif ($ARGV[0] eq 'update') {\n+        my $conf = $git->config(\"remote.fetch\");\n+\tif (defined($conf)) {\n+\t    \t@remotes = split(' ', $conf);\n+\t} else {\n+\t        @remotes = sort keys %$remote;\n+\t}\n+\tfor (@remotes) {\n+\t\tprint \"Fetching $_\\n\";\n+\t\t$git->command('fetch', \"$_\");\n+\t}\n+}\n elsif ($ARGV[0] eq 'prune') {\n \tmy $ls_remote = 1;\n \tmy $i;\n@@ -360,5 +372,6 @@ else {\n \tprint STDERR \"       git remote add <name> <url>\\n\";\n \tprint STDERR \"       git remote show <name>\\n\";\n \tprint STDERR \"       git remote prune <name>\\n\";\n+\tprint STDERR \"       git remote update\\n\";\n \texit(1);\n }\n-- \n1.5.0.50.gb75812-dirty\n"},{"id":"34977","messageId":"7virdybu9a.fsf@assigned-by-dhcp.cox.net","threadId":"6875","inReplyTo":"E1HIzh2-0001Ph-T2@candygram.thunk.org","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-19T05:18:09Z","receivedAt":"2007-02-19T05:18:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Theodore Ts'o\" <tytso@mit.edu> writes:\n\n> This allows users to use the command \"git remote update\" to update all\n> remotes that are being tracked in the repository.\n\nSounds like a good idea.  Thanks.\n"},{"id":"34979","messageId":"20070219073238.GA30030@spearce.org","threadId":"6875","inReplyTo":"7virdybu9a.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-19T07:32:38Z","receivedAt":"2007-02-19T07:32:38Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Theodore Ts'o\" <tytso@mit.edu> writes:\n> \n> > This allows users to use the command \"git remote update\" to update all\n> > remotes that are being tracked in the repository.\n> \n> Sounds like a good idea.  Thanks.\n\n<personalwishlist>\n\nIt would be nice to define \"gang remotes\".  For example I want to\nbe able to have:\n\n  `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`\n  `git fetch jc`  ==  `git fetch origin; git fetch alt`\n\nWhy?  Well, I often have multiple remotes setup to the *same*\nrepository depending on the SSH hostname I want to use to access\nthat repository.  This has a lot to do with the way my firewalls\nare setup and where I'm physically connected at any given time.\n\nYes, I really do have multiple remotes setup to the access the\nsame (remote) physical disk.  :)\n\nPossible syntax:\n\n\t[remote \"cs\"]\n\t\tremote = cs-one\n\t\tremote = cs-two\n\t[remote \"jc\"]\n\t\tremote = origin\n\t\tremote = alt\n\n</personalwishlist>\n\nObviously this is more work than Ted's nice little patch.  :)\n\n-- \nShawn.\n"},{"id":"35000","messageId":"81b0412b0702190305j20cf2d10w8f75c4345ba0fc26@mail.gmail.com","threadId":"6875","inReplyTo":"20070219073238.GA30030@spearce.org","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-02-19T11:05:15Z","receivedAt":"2007-02-19T11:05:15Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 2/19/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Junio C Hamano <junkio@cox.net> wrote:\n> > \"Theodore Ts'o\" <tytso@mit.edu> writes:\n> >\n> > > This allows users to use the command \"git remote update\" to update all\n> > > remotes that are being tracked in the repository.\n> >\n> > Sounds like a good idea.  Thanks.\n>\n> <personalwishlist>\n>\n> It would be nice to define \"gang remotes\".  For example I want to\n> be able to have:\n>\n>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`\n>   `git fetch jc`  ==  `git fetch origin; git fetch alt`\n\nI was thinking about something very similar.\n\n> Why?  Well, I often have multiple remotes setup to the *same*\n> repository depending on the SSH hostname I want to use to access\n> that repository.  This has a lot to do with the way my firewalls\n> are setup and where I'm physically connected at any given time.\n\nFor all the same reasons :)\n\n> Yes, I really do have multiple remotes setup to the access the\n> same (remote) physical disk.  :)\n>\n> Possible syntax:\n>\n>         [remote \"cs\"]\n>                 remote = cs-one\n>                 remote = cs-two\n>         [remote \"jc\"]\n>                 remote = origin\n>                 remote = alt\n>\n\nOr :\n\n  [remote \"jc\"]\n    url = git://...\n    fetch = refs/heads/*:remotes/jc/*\n    remote (\"include\"? \"next\"?) = origin\n\n(I mean: it can be allowed to mix url/fetch and remote).\n\nAnd:\n\n  [remote \"jc\"]\n    fail = all-fail\n    remote = origin\n    remote = backup\n\nIOW: the fetch fails only if all fetches fail (with default\nbeing \"fail = first\").\n"},{"id":"35003","messageId":"20070219125219.GD25490@thunk.org","threadId":"6875","inReplyTo":"20070219073238.GA30030@spearce.org","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Theodore Tso","fromEmail":"tytso@mit.edu","sentAt":"2007-02-19T12:52:19Z","receivedAt":"2007-02-19T12:52:19Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Mon, Feb 19, 2007 at 02:32:38AM -0500, Shawn O. Pearce wrote:\n> <personalwishlist>\n> \n> It would be nice to define \"gang remotes\".  For example I want to\n> be able to have:\n> \n>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`\n>   `git fetch jc`  ==  `git fetch origin; git fetch alt`\n> \n> Why?  Well, I often have multiple remotes setup to the *same*\n> repository depending on the SSH hostname I want to use to access\n> that repository.  This has a lot to do with the way my firewalls\n> are setup and where I'm physically connected at any given time.\n> \n> Yes, I really do have multiple remotes setup to the access the\n> same (remote) physical disk.  :)\n\nHere are a couple of things that I'm thinking about doing with the\npatch I submitted yesterday:\n\n1) Change the configuration parameter from remote.fetch to\nremotes.default.update, and let \"git remote update\" take a parameter,\n\"git remote update <name>\", where it will look up the list of remotes\nto fetch via remotes.<name>.update, and default <name> to \"default\" if\nit is not specified.\n\n2) In the case of <name> == default, if remotes.default.update does\nnot exist, it will update all remotes, skipping remotes where\nremote.*.no_default_fetch is true.  (This allows people who want to\nomit certain special case remotes that only work if their connection\nto the intranet is up, etc., to be able to set up something\nconvenientl; but for people who have more complex setups, they will\nhave to use the method specified in (1) above.\n\nI thought about doing this via git-fetch, but (1) git-fetch.sh is\nalready way too complicated as it is, and I see that JC is in the\nprocess of rewriting portions of it to C; by implementing in\ngit-remote.perl I avoided potential patch conflicts, and (2) fetching\ngroups of remotes would be overloading concepts for git-fetch, which\nmakes not only the implementation hard, but also the potential\nsemantics.  i.e., what does this mean?\n\n[remote \"cs\"]\n\tremote = cs-one\n\tremote = cs-two\n\turl = git://git.kernel.org/pub/scm/git/git.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n\n\t\t\t\t\t\t- Ted\n"},{"id":"35005","messageId":"erc846$bk7$1@sea.gmane.org","threadId":"6875","inReplyTo":"81b0412b0702190305j20cf2d10w8f75c4345ba0fc26@mail.gmail.com","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-02-19T13:21:01Z","receivedAt":"2007-02-19T13:21:01Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Alex Riesen wrote:\n\n> On 2/19/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> Junio C Hamano <junkio@cox.net> wrote:\n>> > \"Theodore Ts'o\" <tytso@mit.edu> writes:\n>> >\n>> > > This allows users to use the command \"git remote update\" to update all\n>> > > remotes that are being tracked in the repository.\n>> >\n>> > Sounds like a good idea.  Thanks.\n>>\n>> <personalwishlist>\n>>\n>> It would be nice to define \"gang remotes\".  For example I want to\n>> be able to have:\n>>\n>>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`\n>>   `git fetch jc`  ==  `git fetch origin; git fetch alt`\n> \n> I was thinking about something very similar.\n> \n>> Why?  Well, I often have multiple remotes setup to the *same*\n>> repository depending on the SSH hostname I want to use to access\n>> that repository.  This has a lot to do with the way my firewalls\n>> are setup and where I'm physically connected at any given time.\n> \n> For all the same reasons :)\n> \n>> Yes, I really do have multiple remotes setup to the access the\n>> same (remote) physical disk.  :)\n>>\n>> Possible syntax:\n>>\n>>         [remote \"cs\"]\n>>                 remote = cs-one\n>>                 remote = cs-two\n>>         [remote \"jc\"]\n>>                 remote = origin\n>>                 remote = alt\n>>\n> \n> Or :\n> \n>   [remote \"jc\"]\n>     url = git://...\n>     fetch = refs/heads/*:remotes/jc/*\n>     remote (\"include\"? \"next\"?) = origin\n> \n> (I mean: it can be allowed to mix url/fetch and remote).\n> \n> And:\n> \n>   [remote \"jc\"]\n>     fail = all-fail\n>     remote = origin\n>     remote = backup\n> \n> IOW: the fetch fails only if all fetches fail (with default\n> being \"fail = first\").\n\nOr just allow fetch remotes to have multiple URLs, and fetch from all/try to fetch starting from first.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"35024","messageId":"7vfy917vu3.fsf@assigned-by-dhcp.cox.net","threadId":"6875","inReplyTo":"20070219125219.GD25490@thunk.org","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-19T20:09:56Z","receivedAt":"2007-02-19T20:09:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Tso <tytso@mit.edu> writes:\n\n> ..., and (2) fetching\n> groups of remotes would be overloading concepts for git-fetch, which\n> makes not only the implementation hard, but also the potential\n> semantics.\n\nI am with you 100% on this one.  Pushing to two separate places\nmakes perfect sense, but fetching (or worse, pulling) from two\nseparate places has certain \"Huh?\" factor in its semantics.\n"},{"id":"35120","messageId":"200702201625.00841.jnareb@gmail.com","threadId":"6875","inReplyTo":"20070219201111.GA3407@steel.home","subject":"Re: [PATCH] Teach git-remote to update existing remotes by fetching from them","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-02-20T15:24:59Z","receivedAt":"2007-02-20T15:24:59Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Alex Riesen wrote:\n> Jakub Narebski, Mon, Feb 19, 2007 14:21:01 +0100:\n>>> \n>>> IOW: the fetch fails only if all fetches fail (with default\n>>> being \"fail = first\").\n>> \n>> Or just allow fetch remotes to have multiple URLs, and fetch from\n>> all/try to fetch starting from first. \n> \n> How do you define which refs to get from which url?\n\nI was thinking about \"mirror\" situation, so all URL would be the same\nrepository, and the same refs. On fetch, try to fetch starting from \nfirst, on push, push to all.\n\n-- \nJakub Narebski\nPoland\n"}]}