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

Re: [PATCH] Do not send "want" lines for complete objects

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 20, 2005, 02:04 UTC
Message-ID
<Pine.LNX.4.63.0510200351260.26594@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vwtk9vvhg.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 19 Oct 2005, Junio C Hamano wrote:
Show 16 quoted lines
> Junio C Hamano <junkio@cox.net> writes:
> 
> > Let's draw a single strand of pearl case to illustrate.  You
> > have a commit chain A->B->C->D, and the other end says she has
> > C.  At this point, telling her that you have C is enough, and by
> > not telling her about A and B, you would save her from depreting
> > MAX_HAVE slots.  Of course, if the other end has D as another
> > head, then the above logic would give "^D^" to rev-list as well,
> > telling it not to tell her about C, but that is what we want --
> > because she already knows you have C too when you tell her that
> > you have D.  I think I like this optimization.
> 
> This was subtly wrong.  ^D^ would barf if D is a tag that points
> at a non commit (refs/tags/v2.6.11-tree).  Also it would do a
> suboptimal thing for a merge commit, since it will not cull the
> second and later parents.

Right, I keep forgetting about tags. And again right, like I said, it is suboptimal but helps the common case.

> +		if (has_sha1_file(remote) &&
> +		    ((o = parse_object(remote)) != NULL) &&
> +		    (o->flags & COMPLETE) &&
Why not split it here, and do a separate block here:
Show 11 quoted lines
> +		    ((commit = (struct commit *) deref_tag(o)) != NULL) &&
> +		    (commit->object.type = commit_type)) {
> +			struct commit_list *p = commit->parents;
> +			while (p && rev_command_len + 44 < sizeof(rev_command)) {
>  				snprintf(rev_command + rev_command_len, 44,
> -					" ^%s^", sha1_to_hex(remote));
> +					 " ^%s",
> +					 sha1_to_hex(p->item->object.sha1));
>  				rev_command_len += 43;
> +				p = p->next;
>  			}

And here I am at a loss: why only continue if p is empty? I mean, remote could be a tag, and still be complete, no?

Show 8 quoted lines
> -
> -			continue;
> +			if (!p)
> +				continue;
>  		}
>  
>  		packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
> 

If the git-rev-list call goes, this probably gets prettier. I'll try to come up with a patch.

Ciao, Dscho

Previous: Junio C HamanoNext: Johannes Schindelin
Message 4 of 11 in “Do not send "want" lines for complete objects”
  1. Do not send "want" lines for complete objectsJohannes Schindelin, Oct 19, 2005
  2. Junio C HamanoOct 19, 2005
  3. Junio C HamanoOct 20, 2005
  4. Johannes SchindelinOct 20, 2005
  5. Johannes SchindelinOct 20, 2005
  6. Junio C HamanoOct 20, 2005
  7. Daniel BarkalowOct 20, 2005
  8. Johannes SchindelinOct 20, 2005
  9. Junio C HamanoOct 21, 2005
  10. Daniel BarkalowOct 21, 2005
  11. Johannes SchindelinOct 20, 2005

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.