Dear diary, on Fri, Jul 28, 2006 at 07:44:21AM CEST, I got a letter where Petr Baudis <pasky@xxxxxxx> 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 - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html