All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Teach git-remote to update existing remotes by fetching from them
@ 2007-02-19  4:00 Theodore Ts'o
  2007-02-19  5:18 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Theodore Ts'o @ 2007-02-19  4:00 UTC (permalink / raw)
  To: git


This allows users to use the command "git remote update" to update all
remotes that are being tracked in the repository.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 Documentation/config.txt     |    4 ++++
 Documentation/git-remote.txt |   10 +++++++++-
 git-remote.perl              |   13 +++++++++++++
 3 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3865535..d8e696f 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -439,6 +439,10 @@ pull.octopus::
 pull.twohead::
 	The default merge strategy to use when pulling a single branch.
 
+remote.fetch::
+	The list of remotes which are fetched by "git remote update".
+	See gitlink:git-remote[1].
+
 remote.<name>.url::
 	The URL of a remote repository.  See gitlink:git-fetch[1] or
 	gitlink:git-push[1].
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index a60c31a..eed7aa2 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -13,6 +13,7 @@ SYNOPSIS
 'git-remote' add <name> <url>
 'git-remote' show <name>
 'git-remote' prune <name>
+'git-remote' update
 
 DESCRIPTION
 -----------
@@ -40,7 +41,14 @@ Gives some information about the remote <name>.
 
 Deletes all stale tracking branches under <name>.
 These stale branches have already been removed from the remote repository
-referenced by <name>, but are still locally available in "remotes/<name>".
+referenced by <name>, but are still locally available in
+"remotes/<name>".
+
+'update'::
+
+Fetch updates for the remotes in the repository.  By default all remotes
+are updated, but this can be configured via the configuration parameter 
+'remote.fetch'.   (See gitlink:git-config[1]).
 
 
 DISCUSSION
diff --git a/git-remote.perl b/git-remote.perl
index c56c5a8..1db9901 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -303,6 +303,18 @@ elsif ($ARGV[0] eq 'show') {
 		show_remote($ARGV[$i], $ls_remote);
 	}
 }
+elsif ($ARGV[0] eq 'update') {
+        my $conf = $git->config("remote.fetch");
+	if (defined($conf)) {
+	    	@remotes = split(' ', $conf);
+	} else {
+	        @remotes = sort keys %$remote;
+	}
+	for (@remotes) {
+		print "Fetching $_\n";
+		$git->command('fetch', "$_");
+	}
+}
 elsif ($ARGV[0] eq 'prune') {
 	my $ls_remote = 1;
 	my $i;
@@ -360,5 +372,6 @@ else {
 	print STDERR "       git remote add <name> <url>\n";
 	print STDERR "       git remote show <name>\n";
 	print STDERR "       git remote prune <name>\n";
+	print STDERR "       git remote update\n";
 	exit(1);
 }
-- 
1.5.0.50.gb75812-dirty

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19  4:00 [PATCH] Teach git-remote to update existing remotes by fetching from them Theodore Ts'o
@ 2007-02-19  5:18 ` Junio C Hamano
  2007-02-19  7:32   ` Shawn O. Pearce
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2007-02-19  5:18 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: git

"Theodore Ts'o" <tytso@mit.edu> writes:

> This allows users to use the command "git remote update" to update all
> remotes that are being tracked in the repository.

Sounds like a good idea.  Thanks.

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19  5:18 ` Junio C Hamano
@ 2007-02-19  7:32   ` Shawn O. Pearce
  2007-02-19 11:05     ` Alex Riesen
  2007-02-19 12:52     ` Theodore Tso
  0 siblings, 2 replies; 8+ messages in thread
From: Shawn O. Pearce @ 2007-02-19  7:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Theodore Ts'o, git

Junio C Hamano <junkio@cox.net> wrote:
> "Theodore Ts'o" <tytso@mit.edu> writes:
> 
> > This allows users to use the command "git remote update" to update all
> > remotes that are being tracked in the repository.
> 
> Sounds like a good idea.  Thanks.

<personalwishlist>

It would be nice to define "gang remotes".  For example I want to
be able to have:

  `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`
  `git fetch jc`  ==  `git fetch origin; git fetch alt`

Why?  Well, I often have multiple remotes setup to the *same*
repository depending on the SSH hostname I want to use to access
that repository.  This has a lot to do with the way my firewalls
are setup and where I'm physically connected at any given time.

Yes, I really do have multiple remotes setup to the access the
same (remote) physical disk.  :)

Possible syntax:

	[remote "cs"]
		remote = cs-one
		remote = cs-two
	[remote "jc"]
		remote = origin
		remote = alt

</personalwishlist>

Obviously this is more work than Ted's nice little patch.  :)

-- 
Shawn.

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19  7:32   ` Shawn O. Pearce
@ 2007-02-19 11:05     ` Alex Riesen
  2007-02-19 13:21       ` Jakub Narebski
  2007-02-19 12:52     ` Theodore Tso
  1 sibling, 1 reply; 8+ messages in thread
From: Alex Riesen @ 2007-02-19 11:05 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, Theodore Ts'o, git

On 2/19/07, Shawn O. Pearce <spearce@spearce.org> wrote:
> Junio C Hamano <junkio@cox.net> wrote:
> > "Theodore Ts'o" <tytso@mit.edu> writes:
> >
> > > This allows users to use the command "git remote update" to update all
> > > remotes that are being tracked in the repository.
> >
> > Sounds like a good idea.  Thanks.
>
> <personalwishlist>
>
> It would be nice to define "gang remotes".  For example I want to
> be able to have:
>
>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`
>   `git fetch jc`  ==  `git fetch origin; git fetch alt`

I was thinking about something very similar.

> Why?  Well, I often have multiple remotes setup to the *same*
> repository depending on the SSH hostname I want to use to access
> that repository.  This has a lot to do with the way my firewalls
> are setup and where I'm physically connected at any given time.

For all the same reasons :)

> Yes, I really do have multiple remotes setup to the access the
> same (remote) physical disk.  :)
>
> Possible syntax:
>
>         [remote "cs"]
>                 remote = cs-one
>                 remote = cs-two
>         [remote "jc"]
>                 remote = origin
>                 remote = alt
>

Or :

  [remote "jc"]
    url = git://...
    fetch = refs/heads/*:remotes/jc/*
    remote ("include"? "next"?) = origin

(I mean: it can be allowed to mix url/fetch and remote).

And:

  [remote "jc"]
    fail = all-fail
    remote = origin
    remote = backup

IOW: the fetch fails only if all fetches fail (with default
being "fail = first").

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19  7:32   ` Shawn O. Pearce
  2007-02-19 11:05     ` Alex Riesen
@ 2007-02-19 12:52     ` Theodore Tso
  2007-02-19 20:09       ` Junio C Hamano
  1 sibling, 1 reply; 8+ messages in thread
From: Theodore Tso @ 2007-02-19 12:52 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

On Mon, Feb 19, 2007 at 02:32:38AM -0500, Shawn O. Pearce wrote:
> <personalwishlist>
> 
> It would be nice to define "gang remotes".  For example I want to
> be able to have:
> 
>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`
>   `git fetch jc`  ==  `git fetch origin; git fetch alt`
> 
> Why?  Well, I often have multiple remotes setup to the *same*
> repository depending on the SSH hostname I want to use to access
> that repository.  This has a lot to do with the way my firewalls
> are setup and where I'm physically connected at any given time.
> 
> Yes, I really do have multiple remotes setup to the access the
> same (remote) physical disk.  :)

Here are a couple of things that I'm thinking about doing with the
patch I submitted yesterday:

1) Change the configuration parameter from remote.fetch to
remotes.default.update, and let "git remote update" take a parameter,
"git remote update <name>", where it will look up the list of remotes
to fetch via remotes.<name>.update, and default <name> to "default" if
it is not specified.

2) In the case of <name> == default, if remotes.default.update does
not exist, it will update all remotes, skipping remotes where
remote.*.no_default_fetch is true.  (This allows people who want to
omit certain special case remotes that only work if their connection
to the intranet is up, etc., to be able to set up something
convenientl; but for people who have more complex setups, they will
have to use the method specified in (1) above.

I thought about doing this via git-fetch, but (1) git-fetch.sh is
already way too complicated as it is, and I see that JC is in the
process of rewriting portions of it to C; by implementing in
git-remote.perl I avoided potential patch conflicts, and (2) fetching
groups of remotes would be overloading concepts for git-fetch, which
makes not only the implementation hard, but also the potential
semantics.  i.e., what does this mean?

[remote "cs"]
	remote = cs-one
	remote = cs-two
	url = git://git.kernel.org/pub/scm/git/git.git
	fetch = +refs/heads/*:refs/remotes/origin/*

						- Ted

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19 11:05     ` Alex Riesen
@ 2007-02-19 13:21       ` Jakub Narebski
       [not found]         ` <20070219201111.GA3407@steel.home>
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2007-02-19 13:21 UTC (permalink / raw)
  To: git

Alex Riesen wrote:

> On 2/19/07, Shawn O. Pearce <spearce@spearce.org> wrote:
>> Junio C Hamano <junkio@cox.net> wrote:
>> > "Theodore Ts'o" <tytso@mit.edu> writes:
>> >
>> > > This allows users to use the command "git remote update" to update all
>> > > remotes that are being tracked in the repository.
>> >
>> > Sounds like a good idea.  Thanks.
>>
>> <personalwishlist>
>>
>> It would be nice to define "gang remotes".  For example I want to
>> be able to have:
>>
>>   `git fetch cs`  ==  `git fetch cs-one; git fetch cs-two`
>>   `git fetch jc`  ==  `git fetch origin; git fetch alt`
> 
> I was thinking about something very similar.
> 
>> Why?  Well, I often have multiple remotes setup to the *same*
>> repository depending on the SSH hostname I want to use to access
>> that repository.  This has a lot to do with the way my firewalls
>> are setup and where I'm physically connected at any given time.
> 
> For all the same reasons :)
> 
>> Yes, I really do have multiple remotes setup to the access the
>> same (remote) physical disk.  :)
>>
>> Possible syntax:
>>
>>         [remote "cs"]
>>                 remote = cs-one
>>                 remote = cs-two
>>         [remote "jc"]
>>                 remote = origin
>>                 remote = alt
>>
> 
> Or :
> 
>   [remote "jc"]
>     url = git://...
>     fetch = refs/heads/*:remotes/jc/*
>     remote ("include"? "next"?) = origin
> 
> (I mean: it can be allowed to mix url/fetch and remote).
> 
> And:
> 
>   [remote "jc"]
>     fail = all-fail
>     remote = origin
>     remote = backup
> 
> IOW: the fetch fails only if all fetches fail (with default
> being "fail = first").

Or just allow fetch remotes to have multiple URLs, and fetch from all/try to fetch starting from first.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
  2007-02-19 12:52     ` Theodore Tso
@ 2007-02-19 20:09       ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2007-02-19 20:09 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Shawn O. Pearce, git

Theodore Tso <tytso@mit.edu> writes:

> ..., and (2) fetching
> groups of remotes would be overloading concepts for git-fetch, which
> makes not only the implementation hard, but also the potential
> semantics.

I am with you 100% on this one.  Pushing to two separate places
makes perfect sense, but fetching (or worse, pulling) from two
separate places has certain "Huh?" factor in its semantics.

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

* Re: [PATCH] Teach git-remote to update existing remotes by fetching from them
       [not found]         ` <20070219201111.GA3407@steel.home>
@ 2007-02-20 15:24           ` Jakub Narebski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2007-02-20 15:24 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git

Alex Riesen wrote:
> Jakub Narebski, Mon, Feb 19, 2007 14:21:01 +0100:
>>> 
>>> IOW: the fetch fails only if all fetches fail (with default
>>> being "fail = first").
>> 
>> Or just allow fetch remotes to have multiple URLs, and fetch from
>> all/try to fetch starting from first. 
> 
> How do you define which refs to get from which url?

I was thinking about "mirror" situation, so all URL would be the same
repository, and the same refs. On fetch, try to fetch starting from 
first, on push, push to all.

-- 
Jakub Narebski
Poland

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

end of thread, other threads:[~2007-02-20 15:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19  4:00 [PATCH] Teach git-remote to update existing remotes by fetching from them Theodore Ts'o
2007-02-19  5:18 ` Junio C Hamano
2007-02-19  7:32   ` Shawn O. Pearce
2007-02-19 11:05     ` Alex Riesen
2007-02-19 13:21       ` Jakub Narebski
     [not found]         ` <20070219201111.GA3407@steel.home>
2007-02-20 15:24           ` Jakub Narebski
2007-02-19 12:52     ` Theodore Tso
2007-02-19 20:09       ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.