# [PATCH 1/2] pack-objects: document --delta-base-offset option

8 messages from 2006-10-13 to 2006-10-13. Participants: Junio C Hamano, Nicolas Pitre, Jakub Narebski.
Thread: https://gitlist.dev/t/5912

## Junio C Hamano, 2006-10-13 05:35

Subject: [PATCH 1/2] pack-objects: document --delta-base-offset option
Message-ID: <11607177011745-git-send-email-junkio@cox.net>
URL: https://gitlist.dev/e/11607177011745-git-send-email-junkio%40cox.net

```
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Documentation/git-pack-objects.txt |   13 ++++++++++++-
 builtin-pack-objects.c             |    2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index d4661dd..5788709 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt
@@ -9,7 +9,7 @@ git-pack-objects - Create a packed archi
 SYNOPSIS
 --------
 [verse]
-'git-pack-objects' [-q] [--no-reuse-delta] [--non-empty]
+'git-pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty]
 	[--local] [--incremental] [--window=N] [--depth=N]
 	[--revs [--unpacked | --all]*] [--stdout | base-name] < object-list
 
@@ -110,6 +110,17 @@ base-name::
 	This flag tells the command not to reuse existing deltas
 	but compute them from scratch.
 
+--delta-base-offset::
+	A packed archive can express base object of a delta as
+	either 20-byte object name or as an offset in the
+	stream, but older version of git does not understand the
+	latter.  By default, git-pack-objects only uses the
+	former format for better compatibility.  This option
+	allows the command to use the latter format for
+	compactness.  Depending on the average delta chain
+	length, this option typically shrinks the resulting
+	packfile by 3-5 per-cent.
+
 
 Author
 ------
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ee5f031..41e1e74 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -15,7 +15,7 @@ #include "list-objects.h"
 #include <sys/time.h>
 #include <signal.h>
 
-static const char pack_usage[] = "git-pack-objects [-q] [--no-reuse-delta] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] [--revs [--unpacked | --all]*] [--stdout | base-name] <ref-list | <object-list]";
+static const char pack_usage[] = "git-pack-objects [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] [--revs [--unpacked | --all]*] [--stdout | base-name] <ref-list | <object-list]";
 
 struct object_entry {
 	unsigned char sha1[20];
-- 
1.4.3.rc2.g51ca

```

## Junio C Hamano, 2006-10-13 05:35

Subject: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <11607177024171-git-send-email-junkio@cox.net>
URL: https://gitlist.dev/e/11607177024171-git-send-email-junkio%40cox.net
In-Reply-To: <11607177011745-git-send-email-junkio@cox.net>

```
This new option makes the resulting pack express the delta base
with more compact "offset" format.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Documentation/git-repack.txt |    8 +++++++-
 git-repack.sh                |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 49f7e0a..5f5530d 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -9,7 +9,7 @@ objects into pack files.
 
 SYNOPSIS
 --------
-'git-repack' [-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]
+'git-repack' [-a] [-b] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]
 
 DESCRIPTION
 -----------
@@ -35,6 +35,12 @@ OPTIONS
 	about people fetching via dumb protocols from it.  Use
 	with '-d'.
 
+-b::
+	Pass the `--delta-base-offset` to `git pack-objects`;
+	see gitlink:git-pack-objects[1].  Do not use this option
+	if you want the repository to be accessible by older
+	versions of git.
+
 -d::
 	After packing, if the newly created packs make some
 	existing packs redundant, remove the redundant packs.
diff --git a/git-repack.sh b/git-repack.sh
index b525fc5..25dae5e 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -14,6 +14,7 @@ do
 	-n)	no_update_info=t ;;
 	-a)	all_into_one=t ;;
 	-d)	remove_redundant=t ;;
+	-b)	extra="$extra --delta-base-offset" ;;
 	-q)	quiet=-q ;;
 	-f)	no_reuse_delta=--no-reuse-delta ;;
 	-l)	local=--local ;;
-- 
1.4.3.rc2.g51ca

```

## Nicolas Pitre, 2006-10-13 13:20

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <Pine.LNX.4.64.0610130912500.2435@xanadu.home>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0610130912500.2435%40xanadu.home
In-Reply-To: <11607177024171-git-send-email-junkio@cox.net>

```
On Thu, 12 Oct 2006, Junio C Hamano wrote:

> This new option makes the resulting pack express the delta base
> with more compact "offset" format.

Actually I thought about making it the default whenever git-pack-objects 
supported it, and use a negative option with git-repack to disable it 
instead.

The fact is that there is little reason for not using delta base offsets 
in most cases and specifying -b all the time would become more of an 
annoyance.

What do you think?


Nicolas

```

## Jakub Narebski, 2006-10-13 13:51

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <ego5kp$fm4$1@sea.gmane.org>
URL: https://gitlist.dev/e/ego5kp%24fm4%241%40sea.gmane.org
In-Reply-To: <Pine.LNX.4.64.0610130912500.2435@xanadu.home>

```
Nicolas Pitre wrote:

> On Thu, 12 Oct 2006, Junio C Hamano wrote:
> 
>> This new option makes the resulting pack express the delta base
>> with more compact "offset" format.
> 
> Actually I thought about making it the default whenever git-pack-objects 
> supported it, and use a negative option with git-repack to disable it 
> instead.
> 
> The fact is that there is little reason for not using delta base offsets 
> in most cases and specifying -b all the time would become more of an 
> annoyance.

Perhaps we should leave it to configuretion variable, instead?
And turn the new format on by default, like core.legacyHeaders
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Junio C Hamano, 2006-10-13 21:22

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <7v64endi6x.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v64endi6x.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0610130912500.2435@xanadu.home>

```
Nicolas Pitre <nico@cam.org> writes:

> On Thu, 12 Oct 2006, Junio C Hamano wrote:
>
>> This new option makes the resulting pack express the delta base
>> with more compact "offset" format.
>
> Actually I thought about making it the default whenever git-pack-objects 
> supported it, and use a negative option with git-repack to disable it 
> instead.
>
> The fact is that there is little reason for not using delta base offsets 
> in most cases and specifying -b all the time would become more of an 
> annoyance.
>
> What do you think?

The only time it matters is if the packs in repository being
repacked needs to be readable by older git, which I think is
only when somebody with older git uses commit walkers to
download the pack into a remote repository to use.  Using or not
using delta-base-offset is tied to each repository, and in a
sense that is similar to "repository format version".

So how about

	[core]
        	repackUseDeltaBase = true

```

## Jakub Narebski, 2006-10-13 21:29

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <egp0fk$15b$1@sea.gmane.org>
URL: https://gitlist.dev/e/egp0fk%2415b%241%40sea.gmane.org
In-Reply-To: <7v64endi6x.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> So how about
> 
>         [core]
>                 repackUseDeltaBase = true

+1, but I'd rather first it default to false.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Nicolas Pitre, 2006-10-13 21:58

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <Pine.LNX.4.64.0610131757050.2435@xanadu.home>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0610131757050.2435%40xanadu.home
In-Reply-To: <7v64endi6x.fsf@assigned-by-dhcp.cox.net>

```
On Fri, 13 Oct 2006, Junio C Hamano wrote:

> Nicolas Pitre <nico@cam.org> writes:
> 
> > On Thu, 12 Oct 2006, Junio C Hamano wrote:
> >
> >> This new option makes the resulting pack express the delta base
> >> with more compact "offset" format.
> >
> > Actually I thought about making it the default whenever git-pack-objects 
> > supported it, and use a negative option with git-repack to disable it 
> > instead.
> >
> > The fact is that there is little reason for not using delta base offsets 
> > in most cases and specifying -b all the time would become more of an 
> > annoyance.
> >
> > What do you think?
> 
> The only time it matters is if the packs in repository being
> repacked needs to be readable by older git, which I think is
> only when somebody with older git uses commit walkers to
> download the pack into a remote repository to use.  Using or not
> using delta-base-offset is tied to each repository, and in a
> sense that is similar to "repository format version".
> 
> So how about
> 
> 	[core]
>         	repackUseDeltaBase = true

I agree, although "repackUseDeltaBase" is a bit vague as both delta 
types do use a delta base.


Nicolas

```

## Junio C Hamano, 2006-10-13 22:11

Subject: Re: [PATCH 2/2] git-repack: -b to pass --delta-base-offset
Message-ID: <7vslhrc1e1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vslhrc1e1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0610131757050.2435@xanadu.home>

```
Nicolas Pitre <nico@cam.org> writes:

>> So how about
>> 
>> 	[core]
>>         	repackUseDeltaBase = true
>
> I agree, although "repackUseDeltaBase" is a bit vague as both delta 
> types do use a delta base.

True; core.repackUseDeltaBaseOffset that is.

```
