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?