git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, alp@atoker.com
Subject: Re: [PATCH] Allow fetching from multiple repositories at once
Date: Fri, 28 Jul 2006 16:04:10 +0200	[thread overview]
Message-ID: <20060728140410.GN13776@pasky.or.cz> (raw)
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...
> @@ -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

      parent reply	other threads:[~2006-07-28 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-28  5:44 [PATCH] Allow fetching from multiple repositories at once Petr Baudis
2006-07-28  5:46 ` Petr Baudis
2006-07-28  7:35 ` Junio C Hamano
2006-07-28  8:51 ` Johannes Schindelin
2006-07-28 14:00   ` Petr Baudis
2006-07-28 14:13     ` Johannes Schindelin
2006-07-28 14:51       ` Petr Baudis
2006-07-28 14:04 ` Petr Baudis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060728140410.GN13776@pasky.or.cz \
    --to=pasky@suse.cz \
    --cc=alp@atoker.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).