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

Re: [PATCH v5 3/3] push: teach --recurse-submodules the on-demand option

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2012, 03:34 UTC
Message-ID
<7v7gzq9jg2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120213093008.GD15585@t1405.greatnet.de>
Heiko Voigt <hvoigt@hvoigt.net> writes:
Show 30 quoted lines
> diff --git a/submodule.c b/submodule.c
> index 3c714c2..ff0cfd8 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -411,6 +411,54 @@ int check_submodule_needs_pushing(unsigned char new_sha1[20],
>  	return needs_pushing->nr;
>  }
>  
> +static int push_submodule(const char *path)
> +{
> +	if (add_submodule_odb(path))
> +		return 1;
> +
> +	if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
> +		struct child_process cp;
> +		const char *argv[] = {"push", NULL};
> +
> +		memset(&cp, 0, sizeof(cp));
> +		cp.argv = argv;
> +		cp.env = local_repo_env;
> +		cp.git_cmd = 1;
> +		cp.no_stdin = 1;
> +		cp.dir = path;
> +		if (run_command(&cp))
> +			return 0;
> +		close(cp.out);
> +	}
> +
> +	return 1;
> +}

Hmm, this makes me wonder if we fire subprocesses and have them run in parallel (to a reasonably limited parallelism), it might make the overall user experience more pleasant, and if we did the same on the fetching side, it would be even nicer.

We would need to keep track of children and after firing a handful of them we would need to start waiting for some to finish and collect their exit status before firing more, and at the end we would need to wait for the remaining ones and find how each one of them did before returning from push_unpushed_submodules(). If we were to do so, what are the missing support we would need from the run_command() subsystem?

Show 19 quoted lines
> +int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name)
> +{
> +	int i, ret = 1;
> +	struct string_list needs_pushing;
> +
> +	memset(&needs_pushing, 0, sizeof(struct string_list));
> +	needs_pushing.strdup_strings = 1;
> +
> +	if (!check_submodule_needs_pushing(new_sha1, remotes_name, &needs_pushing))
> +		return 1;
> +
> +	for (i = 0; i < needs_pushing.nr; i++) {
> +		const char *path = needs_pushing.items[i].string;
> +		fprintf(stderr, "Pushing submodule '%s'\n", path);
> +		if (!push_submodule(path)) {
> +			fprintf(stderr, "Unable to push submodule '%s'\n", path);
> +			ret = 0;
> +		}
> +	}
Previous: Heiko VoigtNext: Jens Lehmann
Message 12 of 17 in “push: submodule support”
  1. 0/3 push: submodule supportHeiko Voigt, Feb 13, 2012
  2. 1/3 Teach revision walking machinery to walk multiple times sequenciallyHeiko Voigt, Feb 13, 2012
  3. Junio C HamanoFeb 14, 2012
  4. Heiko VoigtMar 26, 2012
  5. Junio C HamanoMar 26, 2012
  6. 2/3 Refactor submodule push check to use string list instead of integerHeiko Voigt, Feb 13, 2012
  7. Junio C HamanoFeb 14, 2012
  8. Heiko VoigtMar 26, 2012
  9. Heiko VoigtMar 26, 2012
  10. Junio C HamanoMar 26, 2012
  11. 3/3 push: teach --recurse-submodules the on-demand optionHeiko Voigt, Feb 13, 2012
  12. Junio C HamanoFeb 14, 2012
  13. Jens LehmannFeb 15, 2012
  14. Heiko VoigtMar 26, 2012
  15. read from 2 filedescriptors simultaneously into one strbufHeiko Voigt, May 13, 2012
  16. Zbigniew Jędrzejewski-SzmekMar 26, 2012
  17. Heiko VoigtMar 28, 2012

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.