public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Dirk Gouders <dirk@gouders•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 1/1] Documentation/user-manual.txt: example for generating object hashes
Date: Fri, 08 Mar 2024 07:45:37 +0100	[thread overview]
Message-ID: <ghbk7p43xq.fsf@gouders.net> (raw)
In-Reply-To: <xmqqil27c5p1.fsf@gitster.g> (Junio C. Hamano's message of "Thu, 29 Feb 2024 13:37:46 -0800")

Junio C Hamano <gitster@pobox•com> writes:

> Dirk Gouders <dirk@gouders•net> writes:

>> +The following is a short example that demonstrates how hashes can be
>> +generated manually:
>> +
>> +Let's asume a small text file with the content "Hello git.\n"
>> +-------------------------------------------------
>> +$ cat > hello.txt <<EOF
>> +Hello git.
>> +EOF
>> +-------------------------------------------------
>> +
>> +We can now manually generate the hash `git` would use for this file:
>> +
>> +- The object we want the hash for is of type "blob" and its size is
>> +  11 bytes.
>> +
>> +- Prepend the object header to the file content and feed this to
>> +  sha1sum(1):
>> +
>> +-------------------------------------------------
>> +$ printf "blob 11\0" | cat - hello.txt | sha1sum
>> +7217614ba6e5f4e7db2edaa2cdf5fb5ee4358b57 .
>> +-------------------------------------------------
>> +
>
> ... something like the above (modulo coding style) would be a useful
> addition to help those who want to convince themselves they
> understand how (some parts of) Git works under the hood, and I think
> it would be a welcome addition to some subset of such readers (the
> rest of the world may feel it is way too much detail, though).

May I ask what you meant by "modulo coding style", e.g. where I should
look at to make the code of similar style?

I would also add that git-hash-object(1) could be used to verify the
result if you think that is OK.

In addition to a suggestion in another mail, the commit would
consist of substantial content you suggested and perhaps, you could tell
me how to express this; would a Helped-By be correct?

Dirk

  parent reply	other threads:[~2024-03-08  6:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 20:57 [PATCH 0/1] Documentation/user-manual.txt: try to clarify on object hashes Dirk Gouders
2024-02-29 13:05 ` [PATCH 1/1] Documentation/user-manual.txt: example for generating " Dirk Gouders
2024-02-29 21:37   ` Junio C Hamano
2024-02-29 22:35     ` Dirk Gouders
2024-02-29 22:57       ` Junio C Hamano
2024-03-08  6:45     ` Dirk Gouders [this message]
2024-03-08 15:24       ` Junio C Hamano
2024-03-08 22:11         ` Dirk Gouders
2024-03-12 10:41 ` [PATCH v2 0/1] Documentation/user-manual.txt: try to clarify on " Dirk Gouders
2024-03-12 10:41   ` [PATCH v2 1/1] Documentation/user-manual.txt: example for generating " Dirk Gouders

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=ghbk7p43xq.fsf@gouders.net \
    --to=dirk@gouders$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox