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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:41

Björn Gustavsson [off-list ref] writes:
'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.
+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?

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

From: Björn Gustavsson <hidden>
Date: 2016-06-15 22:47:41

2009/11/8 Junio C Hamano [off-list ref]:
Björn Gustavsson [off-list ref] writes:

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.
OK.
Very nice.  I like the simplicity of this.
Thanks!
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?
Yes, it can be done, but it will lose some of its simplicity. I'll send a new
patch series that do that soon.

/Björn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help