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

Re: [PATCH] Allow fetching from multiple repositories at once

From
Petr Baudis <pasky@suse.cz>
Date
Jul 28, 2006, 14:04 UTC
Message-ID
<20060728140410.GN13776@pasky.or.cz>
In-Reply-To
<20060728054341.15864.35862.stgit@machine>

Dear diary, on Fri, Jul 28, 2006 at 07:44:21AM CEST, I got a letter where Petr Baudis <pasky@suse.cz> said that...

Show 58 quoted lines
> @@ -461,11 +465,52 @@ static int send_ref(const char *refname,
>  
>  static int upload_pack(void)
>  {
> -	reset_timeout();
> -	head_ref(send_ref);
> -	for_each_ref(send_ref);
> -	packet_flush(1);
> -	receive_needs();
> +	int multirepo = 0;
> +
> +	while (1) {
> +		char *repo;
> +		char cwd[PATH_MAX];
> +
> +		reset_timeout();
> +		head_ref(send_ref);
> +		for_each_ref(send_ref);
> +		packet_flush(1);
> +		repo = receive_needs();
> +		if (!repo)
> +			break;
> +		multirepo++;
> +
> +		fprintf(stderr, "git-upload-pack: switching to repo %s", repo);
> +
> +		/* So that we still find objects of the original repository... */
> +		getcwd(cwd, PATH_MAX);
> +		if (strlen(cwd) < PATH_MAX - 8)
> +			strcat(cwd, "/objects");
> +		link_alt_odb_entry(cwd, strlen(cwd), NULL, 0, 1);
> +
> +		if (!enter_repo(repo, strict) || !security_repo_check(!check_export))
> +			die("git-upload-pack: security violation");
> +	}
> +
> +	if (multirepo) {
> +#define ALTENV_SIZE 65536
> +		/* Propagate all the repositories to the children */
> +		char altenv[ALTENV_SIZE], *p = altenv;
> +		struct alternate_object_database *alt;
> +		strcpy(p, ALTERNATE_DB_ENVIRONMENT "=");
> +		p += sizeof(ALTERNATE_DB_ENVIRONMENT);
> +		for (alt = alt_odb_list; alt; alt = alt->next) {
> +			strncpy(p, alt->base, alt->name - alt->base);
> +			p += alt->name - alt->base;
> +			if (p - altenv < ALTENV_SIZE)
> +				*p++ = ':';
> +			if (p - altenv >= ALTENV_SIZE)
> +				die("fetching too many repositories");
> +		}
> +		p[-1] = '\0';
> +		putenv(altenv);
> +	}
> +
>  	if (!want_obj.nr)
>  		return 0;
>  	get_common_commits();
  Note that you need to be more careful about ALTENV_SIZE checking here,
and I'm not sure if we even need to abuse the alternates database here;
only later I added setting up the alternates variable since I realized
we are executing external tools here, and things would be simpler if we
could get away by just doing that.
  I'm sorry, I don't have time to send the updated patch anymore. :-(
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam
Previous: Petr Baudis
Message 8 of 8 in “Allow fetching from multiple repositories at once”
  1. Allow fetching from multiple repositories at oncePetr Baudis, Jul 28, 2006
  2. Petr BaudisJul 28, 2006
  3. Junio C HamanoJul 28, 2006
  4. Johannes SchindelinJul 28, 2006
  5. Petr BaudisJul 28, 2006
  6. Johannes SchindelinJul 28, 2006
  7. Petr BaudisJul 28, 2006
  8. Petr BaudisJul 28, 2006

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.