All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch'
@ 2009-11-08 15:46 Björn Gustavsson
  2009-11-09  0:59 ` Jay Soffian
  0 siblings, 1 reply; 4+ messages in thread
From: Björn Gustavsson @ 2009-11-08 15:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Add the --multiple option to specify that all arguments are either
groups or remotes. The primary reason for adding this option is
to allow us to re-implement 'git remote update' using fetch.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
 builtin-fetch.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/builtin-fetch.c b/builtin-fetch.c
index a520c1b..7926658 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -24,7 +24,7 @@ enum {
 	TAGS_SET = 2
 };
 
-static int all, append, force, keep, update_head_ok, verbosity;
+static int all, append, force, keep, multiple, update_head_ok, verbosity;
 static int tags = TAGS_DEFAULT;
 static const char *depth;
 static const char *upload_pack;
@@ -41,6 +41,8 @@ static struct option builtin_fetch_options[] = {
 		   "path to upload pack on remote end"),
 	OPT_BOOLEAN('f', "force", &force,
 		    "force overwrite of local branch"),
+	OPT_BOOLEAN('m', "multiple", &multiple,
+		    "fetch from multiple remotes"),
 	OPT_SET_INT('t', "tags", &tags,
 		    "fetch all tags and associated objects", TAGS_SET),
 	OPT_SET_INT('n', NULL, &tags,
@@ -838,6 +840,12 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		/* No arguments -- use default remote */
 		remote = remote_get(NULL);
 		result = fetch_one(remote, argc, argv);
+	} else if (multiple) {
+		/* All arguments are assumed to be remotes or groups */
+		for (i = 0; i < argc; i++)
+			if (!add_remote_or_group(argv[i], &list))
+				die("No such remote or remote group: %s", argv[i]);
+		result = fetch_multiple(&list);
 	} else {
 		/* Single remote or group */
 		(void) add_remote_or_group(argv[0], &list);
-- 
1.6.5.1.69.g36942

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

* Re: [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch'
  2009-11-08 15:46 [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch' Björn Gustavsson
@ 2009-11-09  0:59 ` Jay Soffian
  2009-11-09  1:08   ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Jay Soffian @ 2009-11-09  0:59 UTC (permalink / raw)
  To: Björn Gustavsson; +Cc: git, Junio C Hamano

2009/11/8 Björn Gustavsson <bgustavsson@gmail.com>:
> Add the --multiple option to specify that all arguments are either
> groups or remotes. The primary reason for adding this option is
> to allow us to re-implement 'git remote update' using fetch.

Can't this be determined automagically by inspecting the arguments? I
believe there can be two unambiguous usages:

a) git fetch <repository> <refspec>...
b) git fetch <repository>...

If there is more than one argument, either:

a) arguments 2...N must be refpecs (i.e., each must contain a colon)
b) arguments 2...N must NOT be refspecs

"The format of a <refspec> parameter is an optional plus +, followed
by the source ref <src>, followed by a colon :, followed by the
destination ref <dst>."

j.

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

* Re: [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch'
  2009-11-09  0:59 ` Jay Soffian
@ 2009-11-09  1:08   ` Jeff King
  2009-11-09  6:25     ` Björn Gustavsson
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2009-11-09  1:08 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Björn Gustavsson, git, Junio C Hamano

On Sun, Nov 08, 2009 at 07:59:46PM -0500, Jay Soffian wrote:

> 2009/11/8 Björn Gustavsson <bgustavsson@gmail.com>:
> > Add the --multiple option to specify that all arguments are either
> > groups or remotes. The primary reason for adding this option is
> > to allow us to re-implement 'git remote update' using fetch.
> 
> Can't this be determined automagically by inspecting the arguments? I
> believe there can be two unambiguous usages:
> [...]
> "The format of a <refspec> parameter is an optional plus +, followed
> by the source ref <src>, followed by a colon :, followed by the
> destination ref <dst>."

Isn't the colon optional, indicating that the ref should be fetched into
FETCH_HEAD? I.e.,

  $ git fetch origin pu
  From git://git2.kernel.org/pub/scm/git/git
   * branch            pu         -> FETCH_HEAD

?

-Peff

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

* Re: [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch'
  2009-11-09  1:08   ` Jeff King
@ 2009-11-09  6:25     ` Björn Gustavsson
  0 siblings, 0 replies; 4+ messages in thread
From: Björn Gustavsson @ 2009-11-09  6:25 UTC (permalink / raw)
  To: Jeff King; +Cc: Jay Soffian, git, Junio C Hamano

2009/11/9 Jeff King <peff@peff.net>:
> Isn't the colon optional, indicating that the ref should be fetched into
> FETCH_HEAD?

Yes, that's why I was forced to invent a new option.

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB

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

end of thread, other threads:[~2009-11-09  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-08 15:46 [RFC/PATCH 2/4] Teach the --multiple option to 'git fetch' Björn Gustavsson
2009-11-09  0:59 ` Jay Soffian
2009-11-09  1:08   ` Jeff King
2009-11-09  6:25     ` Björn Gustavsson

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.