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

Re: [PATCH] fix simple deepening of a repo

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2009, 05:21 UTC
Message-ID
<7vab1osc2m.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090825021223.GE1033@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 7 quoted lines
> We aren't quite at the 50k ref stage yet, but we're starting to
> consider that some of our repositories have a ton of refs, and
> that the initial advertisement for either fetch or push is horrid.
>
> Since the refs are immutable I could actually teach the JGit
> daemon to hide them from JGit's receive-pack, thus cutting down the
> advertisement on push, but the refs exist so you can literally say:
What do you mean "refs are immutable"?

Do you mean "In the particular application, Gerrit, the server knows that certain refs will never move nor get deleted, once they are created"? If so, then I would understand, but otherwise what you are describing is not git anymore ;-)

And I think it is probably worth thinking things through to find a way to take advantage of that knowledge.

Even though refs under refs/changes/ hierarchy may have that property, the client won't know what's available unless you advertise it in some way.

You could assume some offline measure outside the git protocol exists for clients to find out about them, and protocol extension could say "I do not want to hear about refs that match these globs during this exchange, because I have learnt about them offline", and the server could skip advertisement.

>   git fetch --uploadpack='git upload-pack --ref refs/changes/88/4488/2' URL refs/changes/88/4488/2
>
> Personally I'd prefer extending the protocol, because making the
> end user supply information twice is stupid.

In the upload-pack protocol, the server talks first, so it is rather hard to shoehorn a request from a client to ask "I know about refs/changes/* hiearchy, so don't talk about them".

I however think it is entirely reasonable to have a server side configuration that tells upload-pack not to advertise refs/changes/* hierarchy but still remembers they are OUR_REF. In send_ref() in upload-pack.c, you'd do something like (I know, I know, you'd be doing an equivalent of this in jgit):

	static const char *capabilities = "multi_ack ...";
	struct object *o = parse_object(sha1);
	int skip_advertisement = exclude_ref_from_advertisement(refname);
	if (!o)
		die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
	if (!skip_advertisement) {
		if (capabilities)
			packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
				0, capabilities);
		else
			packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
		capabilities = NULL;
	}
	if (!(o->flags & OUR_REF)) {
		o->flags |= OUR_REF;
		nr_our_refs++;
	}
	if (o->type == OBJ_TAG) {
		o = deref_tag(o, refname, 0);
		if (o && !skip_advertisement)
			packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
	}
	return 0;

Doing it this way, receive_needs() will allow refs/changes/88/4488/2 to be requested, because that is what send_ref() saw and marked as OUR_REF. It was just not sent to the client. And get_common_commits() will behave the same with or without this abbreviated advertisement,

Of course, the client side cannot grab everything with refs/*:refs/remotes/* wildcard refspecs from such a server, but I think that can be considered a feature.

Previous: Sverre RabbelierNext: Shawn O. Pearce
Message 12 of 22 in “git fetch --depth=* broken?”
  1. Nicolas PitreAug 22, 2009
  2. fix simple deepening of a repoNicolas Pitre, Aug 24, 2009
  3. Junio C HamanoAug 24, 2009
  4. Nicolas PitreAug 24, 2009
  5. Johan HerlandAug 24, 2009
  6. Junio C HamanoAug 24, 2009
  7. Daniel BarkalowAug 24, 2009
  8. Julian PhillipsAug 24, 2009
  9. Nicolas PitreAug 25, 2009
  10. Shawn O. PearceAug 25, 2009
  11. Sverre RabbelierAug 25, 2009
  12. Junio C HamanoAug 25, 2009
  13. Shawn O. PearceAug 25, 2009
  14. Junio C HamanoAug 25, 2009
  15. Shawn O. PearceAug 25, 2009
  16. Shawn O. PearceAug 26, 2009
  17. Johannes SixtAug 26, 2009
  18. Shawn O. PearceAug 26, 2009
  19. Junio C HamanoAug 26, 2009
  20. Shawn O. PearceAug 26, 2009
  21. upload-pack: expand capability advertises additional refsShawn O. Pearce, Aug 28, 2009
  22. Junio C HamanoAug 28, 2009

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.