All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Dana How <danahow@gmail.com>
Cc: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 6/8] git-repack --max-pack-size: write_one() implements limits
Date: Tue, 1 May 2007 01:25:17 -0400	[thread overview]
Message-ID: <20070501052517.GA5942@spearce.org> (raw)
In-Reply-To: <46367A68.4010008@gmail.com>

Dana How <danahow@gmail.com> wrote:
> 
> If --max-pack-size is specified,  generate the appropriate
> write limit for each object and pass it to write_object().
> Detect and return write "failure".
> 
> Signed-off-by: Dana L. How <danahow@gmail.com>
> ---
>  builtin-pack-objects.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
> index d3ebe1d..b50de05 100644
> --- a/builtin-pack-objects.c
> +++ b/builtin-pack-objects.c
> @@ -612,11 +612,17 @@ static off_t write_one(struct sha1file *f,
>  		return offset;
>  
>  	/* if we are deltified, write out base object first. */
> -	if (e->delta)
> +	if (e->delta) {
>  		offset = write_one(f, e->delta, offset);
> +		if (!offset)
> +			return 0;
> +	}

So offset == 0 means we didn't write this object into this packfile?
Did I read your changes right?

>  	e->offset = offset;
> -	size = write_object(f, e, 0);
> +	/* pass in write limit if limited packsize and not first object */
> +	size = write_object(f, e, pack_size_limit && nr_written ? pack_size_limit - offset : 0);

Why wasn't this in the prior patch?  You had almost everything in
place, but hardcoded the option to 0, to then just change it here
in this patch to non-zero under some conditions?

I'd also like to see that line <80 characters, but that's just me
and my own style preferences.

But isn't that argument actually kind of silly here?  None of
the values that are used to compute that 3rd boolean argument to
write_objet depend on things that are local to write_one - they
are all global values.  Can't we spare the poor register-starved
x86 platform and just let write_object compute that value itself?

> +	if (!size)
> +		return e->offset = 0;

Ugh.  I don't really like to see assignment in the middle of an
evaluation of an rvalue, and especially here in a return.  Burn the
couple of lines to segment it out:

	if (!size) {
		e->offset = 0;
		return 0;
	}

or something.  Because its a lot more clear and doesn't look like
you missed an = to make "return e->offset == 0".

-- 
Shawn.

  reply	other threads:[~2007-05-01  5:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-30 23:23 [PATCH 6/8] git-repack --max-pack-size: write_one() implements limits Dana How
2007-05-01  5:25 ` Shawn O. Pearce [this message]
2007-05-01  6:00   ` Dana How
  -- strict thread matches above, loose matches on Subject: below --
2007-04-08 23:25 Dana How

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=20070501052517.GA5942@spearce.org \
    --to=spearce@spearce.org \
    --cc=danahow@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.