git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 10/13] update delta handling in write_object() for --pack-limit
@ 2007-04-05 22:38 Dana How
  2007-04-05 23:18 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Dana How @ 2007-04-05 22:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, danahow

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

---
 builtin-pack-objects.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

[-- Attachment #2: 0010-update-delta-handling-in-write_object-for-pack-l.patch.txt --]
[-- Type: text/plain, Size: 1172 bytes --]

From 7ee505accac1675269d1fcfc7a6e3bcf70792a2f Mon Sep 17 00:00:00 2001
From: Dana How <how@deathvalley.cswitch.com>
Date: Thu, 5 Apr 2007 14:11:21 -0700
Subject: [PATCH 10/13] update delta handling in write_object() for --pack-limit

---
 builtin-pack-objects.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ccc2d15..a243eed 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -419,13 +419,17 @@ static off_t write_object(struct sha1file *f,
 	}
 
 	if (!to_reuse) {
+		int usable_delta =	!entry->delta ? 0 :
+					!offset_limit ? 1 :
+					entry->delta->no_write ? 0 :
+					entry->delta->offset ? 1 : 0;
 		buf = read_sha1_file(entry->sha1, &type, &size);
 		if (!buf)
 			die("unable to read %s", sha1_to_hex(entry->sha1));
 		if (size != entry->size)
 			die("object %s size inconsistency (%lu vs %lu)",
 			    sha1_to_hex(entry->sha1), size, entry->size);
-		if (entry->delta) {
+		if (usable_delta) {
 			buf = delta_against(buf, size, entry);
 			size = entry->delta_size;
 			obj_type = (allow_ofs_delta && entry->delta->offset) ?
-- 
1.5.1.rc2.18.g9c88-dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 10/13] update delta handling in write_object() for --pack-limit
  2007-04-05 22:38 [PATCH 10/13] update delta handling in write_object() for --pack-limit Dana How
@ 2007-04-05 23:18 ` Junio C Hamano
  2007-04-05 23:41   ` Dana How
  2007-04-06  0:43   ` Nicolas Pitre
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-04-05 23:18 UTC (permalink / raw)
  To: Dana How; +Cc: Junio C Hamano, git

"Dana How" <danahow@gmail.com> writes:

> Subject: [PATCH 10/13] update delta handling in write_object() for --pack-limit
>
> ---
>  builtin-pack-objects.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
> index ccc2d15..a243eed 100644
> --- a/builtin-pack-objects.c
> +++ b/builtin-pack-objects.c
> @@ -419,13 +419,17 @@ static off_t write_object(struct sha1file *f,
>  	}
>  
>  	if (!to_reuse) {
> +		int usable_delta =	!entry->delta ? 0 :
> +					!offset_limit ? 1 :
> +					entry->delta->no_write ? 0 :
> +					entry->delta->offset ? 1 : 0;
>  		buf = read_sha1_file(entry->sha1, &type, &size);
>  		if (!buf)
>  			die("unable to read %s", sha1_to_hex(entry->sha1));
>  		if (size != entry->size)
>  			die("object %s size inconsistency (%lu vs %lu)",
>  			    sha1_to_hex(entry->sha1), size, entry->size);
> -		if (entry->delta) {
> +		if (usable_delta) {
>  			buf = delta_against(buf, size, entry);
>  			size = entry->delta_size;
>  			obj_type = (allow_ofs_delta && entry->delta->offset) ?

This really needs explanation on *why*, at least in the commit
log, and perhaps also in the code as comment.

Here is my attempt to understand that logic (please make
necessary corrections).

 (1) When there is no delta base found by the earlier
     find_deltas()/try_delta() loop, obviously we cannot write
     deltified so we write plain.

 (2) Otherwise if we are not offset limited, then we keep the
     old way of using that delta base.

 (3) If the delta base is not in this pack (because of
     offset-limit chomping the pack into two or more), then we
     cannot use it as the base.

 (4) If the delta has already been written, we can use it as the
     base for this object, but otherwise we cannot.

(3) makes me wonder if we can still allow it in the thin-pack
case by just loosening the condition here.

Also I need explanation to understand why (4) is needed --
doesn't write_one() always write base object out before writing
a deltified object that depends on it?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 10/13] update delta handling in write_object() for --pack-limit
  2007-04-05 23:18 ` Junio C Hamano
@ 2007-04-05 23:41   ` Dana How
  2007-04-06  0:43   ` Nicolas Pitre
  1 sibling, 0 replies; 4+ messages in thread
From: Dana How @ 2007-04-05 23:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, danahow

On 4/5/07, Junio C Hamano <junkio@cox.net> wrote:
> "Dana How" <danahow@gmail.com> writes:
> >       if (!to_reuse) {
> > +             int usable_delta =      !entry->delta ? 0 :
> > +                                     !offset_limit ? 1 :
> > +                                     entry->delta->no_write ? 0 :
> > +                                     entry->delta->offset ? 1 : 0;
> >               buf = read_sha1_file(entry->sha1, &type, &size);
> >               if (!buf)
> >                       die("unable to read %s", sha1_to_hex(entry->sha1));
> >               if (size != entry->size)
> >                       die("object %s size inconsistency (%lu vs %lu)",
> >                           sha1_to_hex(entry->sha1), size, entry->size);
> > -             if (entry->delta) {
> > +             if (usable_delta) {
> >                       buf = delta_against(buf, size, entry);
> >                       size = entry->delta_size;
> >                       obj_type = (allow_ofs_delta && entry->delta->offset) ?
>
> This really needs explanation on *why*, at least in the commit
> log, and perhaps also in the code as comment.
Yes,  I need retraining ;-)  I'm accustomed to more expensive
commits in which the log message describes the objective,
not the details.  Or,  I could have followed the example of the
comments on the initialization for "to_reuse".

> Here is my attempt to understand that logic (please make
> necessary corrections).
>
>  (1) When there is no delta base found by the earlier
>      find_deltas()/try_delta() loop, obviously we cannot write
>      deltified so we write plain.
>
>  (2) Otherwise if we are not offset limited, then we keep the
>      old way of using that delta base.
>
>  (3) If the delta base is not in this pack (because of
>      offset-limit chomping the pack into two or more), then we
>      cannot use it as the base.
>
>  (4) If the delta has already been written, we can use it as the
>      base for this object, but otherwise we cannot.
>
> (3) makes me wonder if we can still allow it in the thin-pack
> case by just loosening the condition here.
You are correct.  In response to someone's previous question I think
I said I hadn't handled the --thin-pack cases yet.  Do you
think these will matter?  There is strong sentiment on this list that a pack
should be split at the receiver, not the transmitter, so --thin-pack
and --pack-limit wouldn't be used together.  If you think this
combination does matter,  I'd prefer to add the extra cases
in a separate follow-on patch if that's OK.

> Also I need explanation to understand why (4) is needed --
> doesn't write_one() always write base object out before writing
> a deltified object that depends on it?
Yes, write_one() does that. I was being too cautious,
since I had only known (some of) the code for a few hours!
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 10/13] update delta handling in write_object() for --pack-limit
  2007-04-05 23:18 ` Junio C Hamano
  2007-04-05 23:41   ` Dana How
@ 2007-04-06  0:43   ` Nicolas Pitre
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Pitre @ 2007-04-06  0:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Dana How, git

On Thu, 5 Apr 2007, Junio C Hamano wrote:

> (3) makes me wonder if we can still allow it in the thin-pack
> case by just loosening the condition here.

I don't think thin packs apply in the sliced pack usage scenario anyway.



> 
> Also I need explanation to understand why (4) is needed --
> doesn't write_one() always write base object out before writing
> a deltified object that depends on it?

Yes it does.  This is a requirement for OBJ_OFS_DELTA.


Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-04-06  0:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-05 22:38 [PATCH 10/13] update delta handling in write_object() for --pack-limit Dana How
2007-04-05 23:18 ` Junio C Hamano
2007-04-05 23:41   ` Dana How
2007-04-06  0:43   ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).