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

Re: [PATCH 3/8] bundle: give list_prerequisites() loop body its own function

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2010, 18:04 UTC
Message-ID
<7vmxuc5rcv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100626062047.GD15881@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 59 quoted lines
> No functional change intended.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  bundle.c |   57 +++++++++++++++++++++++++++++++--------------------------
>  1 files changed, 31 insertions(+), 26 deletions(-)
>
> diff --git a/bundle.c b/bundle.c
> index 0dd2acb..e90b5c5 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -193,6 +193,33 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
>  		(revs->min_age == -1 || revs->min_age > date);
>  }
>  
> +static void list_prerequisite(int bundle_fd, struct rev_info *revs,
> +		struct commit *rev)
> +{
> +	struct strbuf buf = STRBUF_INIT;
> +	struct pretty_print_context ctx = {0};
> +	enum object_type type;
> +	unsigned long size;
> +
> +	/*
> +	 * The commit buffer is needed
> +	 * to pretty-print boundary commits.
> +	 */
> +	rev->buffer = read_sha1_file(rev->object.sha1, &type, &size);
> +
> +	strbuf_addch(&buf, '-');
> +	strbuf_add(&buf, sha1_to_hex(rev->object.sha1), 40);
> +	strbuf_addch(&buf, ' ');
> +	pretty_print_commit(CMIT_FMT_ONELINE, rev, &buf, &ctx);
> +	strbuf_addch(&buf, '\n');
> +
> +	write_or_die(bundle_fd, buf.buf, buf.len);
> +
> +	rev->object.flags |= UNINTERESTING;
> +	add_pending_object(revs, &rev->object, buf.buf);
> +	strbuf_release(&buf);
> +}
> +
>  static int list_prerequisites(int bundle_fd, struct rev_info *revs,
>  		int argc, const char * const *argv)
>  {
> @@ -209,33 +236,11 @@ static int list_prerequisites(int bundle_fd, struct rev_info *revs,
>  	if (prepare_revision_walk(&boundary_revs))
>  		return error("revision walk setup failed");
>  
> -	while ((rev = get_revision(&boundary_revs))) {
> -		if (rev->object.flags & BOUNDARY) {
> -...
> -		} else {
> +	while ((rev = get_revision(revs))) {
> +		if (rev->object.flags & BOUNDARY)
> +			list_prerequisite(bundle_fd, revs, rev);
> +		else
>  			rev->object.flags |= SHOWN;
> -		}

You used to walk boundary_revs but now you walk revs that is given by the caller, exhausting the revs.pending the caller wanted to use later to feed pack_objects with?

Confused...
Previous: Jonathan NiederNext: Jonathan Nieder
Message 13 of 19 in “bug: git-bundle create foo --stdin -> segfault”
  1. Joey HessJan 19, 2010
  2. Johannes SchindelinJan 19, 2010
  3. 0/2 test bundle --stdin, fix objects_array_remove_duplicates()Jonathan Nieder, Apr 19, 2010
  4. 1/2 t5704 (bundle): add tests for bundle --stdinJonathan Nieder, Apr 19, 2010
  5. 2/2 fix "bundle --stdin" segfaultJonathan Nieder, Apr 19, 2010
  6. Junio C HamanoApr 20, 2010
  7. 0/8 Re: bug: git-bundle create foo --stdin -> segfaultJonathan Nieder, Jun 26, 2010
  8. 1/8 bundle: split basis discovery into its own functionJonathan Nieder, Jun 26, 2010
  9. 2/8 bundle: use libified rev-list --boundaryJonathan Nieder, Jun 26, 2010
  10. Junio C HamanoJun 30, 2010
  11. Jonathan NiederJun 30, 2010
  12. 3/8 bundle: give list_prerequisites() loop body its own functionJonathan Nieder, Jun 26, 2010
  13. Junio C HamanoJun 30, 2010
  14. Jonathan NiederJun 30, 2010
  15. 4/8 bundle: split table of contents output into its own functionJonathan Nieder, Jun 26, 2010
  16. 5/8 bundle: reuse setup_revisions resultJonathan Nieder, Jun 26, 2010
  17. 6/8 Fix bundle --stdinJonathan Nieder, Jun 26, 2010
  18. 7/8 bundle: Keep names of basis refs after discoveryJonathan Nieder, Jun 26, 2010
  19. 8/8 bundle_create: Do not exit when given no revs to bundleJonathan Nieder, Jun 26, 2010

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.