# [PATCH] bundle doc: 'verify' is not about verifying the bundle

4 messages from 2016-03-01 to 2016-03-02. Participants: Junio C Hamano, Philip Oakley, Jeff King.
Thread: https://gitlist.dev/t/41586

## Junio C Hamano, 2016-03-01 21:36

Subject: [PATCH] bundle doc: 'verify' is not about verifying the bundle
Message-ID: <xmqqd1rd7uey.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqd1rd7uey.fsf%40gitster.mtv.corp.google.com

```
Even though the command does read the bundle header and checks to
see if it looks reasonable, the thin-pack data stream that follows
the header in the bundle file is not checked.  More importantly,
because the thin-pack data does not have a trailing checksum like
on-disk packfiles do, there isn't much "verification" the command
can do without unpacking the objects from the stream even if it
wanted to.

The documentation gives an incorrect impression that the thin-pack
data contained in the bundle is validated, but the command is to
validate that the receiving repository is ready to accept the
bundle, not to check the validity of a bundle file.  Rephrase the
paragraph to clarify this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-bundle.txt | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt
index 3a8120c..c0113a8 100644
--- a/Documentation/git-bundle.txt
+++ b/Documentation/git-bundle.txt
@@ -38,11 +38,10 @@ create <file>::
 	'git-rev-list-args' arguments to define the bundle contents.
 
 verify <file>::
-	Used to check that a bundle file is valid and will apply
-	cleanly to the current repository.  This includes checks on the
-	bundle format itself as well as checking that the prerequisite
-	commits exist and are fully linked in the current repository.
-	'git bundle' prints a list of missing commits, if any, and exits
+	Verifies that the given 'file' has a valid-looking bundle
+	header, and that your repository has all prerequisite
+	objects necessary to unpack the file as a bundle.  The
+	command prints a list of missing commits, if any, and exits
 	with a non-zero status.
 
 list-heads <file>::
-- 
2.8.0-rc0-114-g0b3e5e5

```

## Philip Oakley, 2016-03-01 22:49

Subject: Re: [PATCH] bundle doc: 'verify' is not about verifying the bundle
Message-ID: <499EFADFE03B4EDFA48F7E0B99A0E36D@PhilipOakley>
URL: https://gitlist.dev/e/499EFADFE03B4EDFA48F7E0B99A0E36D%40PhilipOakley
In-Reply-To: <xmqqd1rd7uey.fsf@gitster.mtv.corp.google.com>

```
From: "Junio C Hamano" <gitster@pobox.com>
> Even though the command does read the bundle header and checks to
> see if it looks reasonable, the thin-pack data stream that follows
> the header in the bundle file is not checked.  More importantly,
> because the thin-pack data does not have a trailing checksum like
> on-disk packfiles do, there isn't much "verification" the command
> can do without unpacking the objects from the stream even if it
> wanted to.
> 
> The documentation gives an incorrect impression that the thin-pack
> data contained in the bundle is validated, but the command is to
> validate that the receiving repository is ready to accept the
> bundle, not to check the validity of a bundle file.  Rephrase the
> paragraph to clarify this.
> 

This looks good to me.

I was actually looking at this over the weekend with respect to a back-
burner issue about indicating which ref is HEAD within the bundle.
(thread variously $gmane/265001 and it's prior links, though now I'm minded
to add \0HEAD after the correct ref; e.g. '<sha1>  refs/heads/<ref>\0HEAD')

Philip

> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> Documentation/git-bundle.txt | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt
> index 3a8120c..c0113a8 100644
> --- a/Documentation/git-bundle.txt
> +++ b/Documentation/git-bundle.txt
> @@ -38,11 +38,10 @@ create <file>::
>  'git-rev-list-args' arguments to define the bundle contents.
> 
> verify <file>::
> - Used to check that a bundle file is valid and will apply
> - cleanly to the current repository.  This includes checks on the
> - bundle format itself as well as checking that the prerequisite
> - commits exist and are fully linked in the current repository.
> - 'git bundle' prints a list of missing commits, if any, and exits
> + Verifies that the given 'file' has a valid-looking bundle
> + header, and that your repository has all prerequisite
> + objects necessary to unpack the file as a bundle.  The
> + command prints a list of missing commits, if any, and exits
>  with a non-zero status.
> 
> list-heads <file>::
> -- 
> 2.8.0-rc0-114-g0b3e5e5
> 
> --

```

## Jeff King, 2016-03-02 09:22

Subject: Re: [PATCH] bundle doc: 'verify' is not about verifying the bundle
Message-ID: <20160302092236.GB30065@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160302092236.GB30065%40sigill.intra.peff.net
In-Reply-To: <xmqqd1rd7uey.fsf@gitster.mtv.corp.google.com>

```
On Tue, Mar 01, 2016 at 01:36:05PM -0800, Junio C Hamano wrote:

> Even though the command does read the bundle header and checks to
> see if it looks reasonable, the thin-pack data stream that follows
> the header in the bundle file is not checked.  More importantly,
> because the thin-pack data does not have a trailing checksum like
> on-disk packfiles do, there isn't much "verification" the command
> can do without unpacking the objects from the stream even if it
> wanted to.

Are you sure about that trailing checksum thing?

  $ git tag foo $(echo foo | git hash-object -w --stdin)
  $ git bundle create foo.bundle foo
  $ perl -ne '
      BEGIN { binmode STDIN; binmode STDOUT }
      $print = 1 if /^PACK/;
      print if $print;
    ' <foo.bundle >foo.pack

  $ tail -c 20 foo.pack | xxd -p -c 20
  aa4e77be3695e8003bf4fbd2139b3fe0a9a22c8f

  $ git index-pack --stdin <foo.pack
  aa4e77be3695e8003bf4fbd2139b3fe0a9a22c8f

So I think we could pretty easily check for bit errors in the packfile
(we can't in the ref data; including a separate sha1 there might be a
nice improvement).

But...

> The documentation gives an incorrect impression that the thin-pack
> data contained in the bundle is validated, but the command is to
> validate that the receiving repository is ready to accept the
> bundle, not to check the validity of a bundle file.  Rephrase the
> paragraph to clarify this.

I still think this is a good change, though. "verify" is doing a
separate thing here than asking "did I get bit errors". We might _also_
want that check, but it is probably less interesting than "does the
bundle have all of the objects it claims to". And you can only find that
by expanding the objects, which would _also_ notice bit errors.

And the simplest way to do that is "git bundle apply". :)

-Peff

```

## Junio C Hamano, 2016-03-02 18:18

Subject: Re: [PATCH] bundle doc: 'verify' is not about verifying the bundle
Message-ID: <xmqqbn6w4ubj.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqbn6w4ubj.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20160302092236.GB30065@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Tue, Mar 01, 2016 at 01:36:05PM -0800, Junio C Hamano wrote:
>
>> Even though the command does read the bundle header and checks to
>> see if it looks reasonable, the thin-pack data stream that follows
>> the header in the bundle file is not checked.  More importantly,
>> because the thin-pack data does not have a trailing checksum like
>> on-disk packfiles do, there isn't much "verification" the command
>> can do without unpacking the objects from the stream even if it
>> wanted to.
>
> Are you sure about that trailing checksum thing?

No.  I misread the fact that we do not say the final csum on the
command output from pack-objects in the --stdout case. We do call
the sha1close() to append the csum at the end of the pack stream;
we just do not make it available to the caller who is driving the
pack-object procedure.

```
