All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] git-format-patch: Document format for binary patch
Date: Wed, 24 Mar 2021 10:53:32 -0700	[thread overview]
Message-ID: <xmqqa6qszbdv.fsf@gitster.g> (raw)
In-Reply-To: <20210324123027.29460-3-bagasdotme@gmail.com> (Bagas Sanjaya's message of "Wed, 24 Mar 2021 19:30:27 +0700")

Bagas Sanjaya <bagasdotme@gmail.com> writes:

> Document binary file patch formats that are different from text file
> patch.
>
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>  Documentation/git-format-patch.txt | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index 247033f8fc..8de172b1f4 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -725,6 +725,28 @@ diff format is described as below:
>  
>  include::diff-generate-patch.txt[]
>  
> +Binary Files
> +~~~~~~~~~~~~
> +For binary files, the diff format have some differences compared to text
> +files:

I do not think this is specific to 'format-patch'.  If we need to
describe 'git diff --binary', it should be done there, so that
readers of "git diff --help" would also be able to learn the format.

> +1. Object hashes in index header line (`index <hash>..<hash> <mode>`)

s/Object hash/Object name/;

> +   are always given in full form, as binary patch is designed to be
> +   applied only to an exact copy of original file. This is to ensure
> +   that such patch don't apply to file with similar name but different
> +   hash.

... with similar but different object name.

cf. Documentation/glossary-contents.txt tells you what "object name" is.

> +2. There are additional extended header lines specific to binary files:
> +
> +        GIT binary patch
> +        delta <bytes>
> +        literal <bytes>
> +
> +3. The diff body can be either delta or full (literal) content,
> +   whichever is the smallest size. It is encoded with base85 algorithm,
> +   and emitted in 64 characters each line. All but the last line in
> +   the body are prefixed with `z`.

I do not think this is all that useful; it clutters the description
for a reader who is not interested in reimplementing an encoder or a
decoder from the document.

And it is way too insufficient for a reader who wants to reimplement
an encoder or a decoder.  For example,

 - It does not say anything about what the delta is and how it is
   computed.

 - The 'z' is redundant; the more important is to say that the first
   byte signals how many bytes are on that line and it is a mere
   artifact that we cram up to 52 bytes on a line.

 - It does not say anything about how the binary patch ensures that
   it is reversible (i.e. can be given to "git apply -R").

Thanks.

  reply	other threads:[~2021-03-24 17:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 12:30 [PATCH 0/2] Diff format documentation for git-format-patch Bagas Sanjaya
2021-03-24 12:30 ` [PATCH 1/2] git-format-patch: Include diff-generate-patch documentation Bagas Sanjaya
2021-03-24 17:40   ` Junio C Hamano
2021-03-24 12:30 ` [PATCH 2/2] git-format-patch: Document format for binary patch Bagas Sanjaya
2021-03-24 17:53   ` Junio C Hamano [this message]
2021-03-25  6:22     ` Bagas Sanjaya
2021-03-25 18:25       ` Junio C Hamano

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=xmqqa6qszbdv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    /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.