git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Teach the --all option to 'git fetch'

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2009, 09:33 UTC
Message-ID
<7vaayxfji4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4AF682A5.5020500@gmail.com>
Björn Gustavsson <bgustavsson@gmail.com> writes:
Show 5 quoted lines
> 'git remote' is meant for managing remotes and 'git fetch' is meant
> for actually fetching data from remote repositories. Therefore, it is
> not logical that you must use 'git remote update' to fetch from
> several repositories at once. (Junio called 'git remote update'
> a "half-baked UI experiment that failed" in topic 130891 in Gmane.)

Please drop the "because I said so" part, as I made myself clear in the message I was speaking as mere one-of-participants to the project, not as the maintainer.

Show 42 quoted lines
> +static int get_one_remote_for_fetch(struct remote *remote, void *priv)
> +{
> +	struct string_list *list = priv;
> +	string_list_append(remote->name, list);
> +	return 0;
> +}
> +
> +static int fetch_all(int argc)
> +{
> +...
> +	for (i = 0; i < list.nr; i++) {
> +		const char *name = list.items[i].string;
> +		argv[argc] = name;
> +		if (verbosity >= 0)
> +			printf("Fetching %s\n", name);
> +		if (run_command_v_opt(argv, RUN_GIT_CMD)) {
> +			error("Could not fetch %s", name);
> +			result = 1;
> +		}
> +	}
> +...
> +}
> +
> ...
> +int cmd_fetch(int argc, const char **argv, const char *prefix)
> +{
> +	int i;
> +
> +	/* Record the command line for the reflog */
> +	strbuf_addstr(&default_rla, "fetch");
> +	for (i = 1; i < argc; i++)
> +		strbuf_addf(&default_rla, " %s", argv[i]);
> +
> +	argc = parse_options(argc, argv, prefix,
> +			     builtin_fetch_options, builtin_fetch_usage, 0);
> +
> +	if (all) {
> +		return fetch_all(argc);
> +	} else {
> +		return fetch_one(argc, argv);
> +	}
> +}
Very nice.  I like the simplicity of this.

Hopefully after the parse_options() we can inspect the "repo" argument to see if it names remote groups and transplant the support for that from "remote update" codepath into this, right?

Previous: Björn GustavssonNext: Björn Gustavsson
Message 2 of 3 in “Teach the --all option to 'git fetch'”
  1. Teach the --all option to 'git fetch'Björn Gustavsson, Nov 8, 2009
  2. Junio C HamanoNov 8, 2009
  3. Björn GustavssonNov 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.