git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] Documentation/user-manual.txt: example for generating object hashes

From
Dirk Gouders <dirk@gouders.net>
Date
Mar 8, 2024, 06:45 UTC
Message-ID
<ghbk7p43xq.fsf@gouders.net>
In-Reply-To
<xmqqil27c5p1.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Dirk Gouders <dirk@gouders.net> writes:
Show 29 quoted lines
>> +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
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 10 in “Documentation/user-manual.txt: try to clarify on object hashes”
  1. 0/1 Documentation/user-manual.txt: try to clarify on object hashesDirk Gouders, Feb 29, 2024
  2. 1/1 Documentation/user-manual.txt: example for generating object hashesDirk Gouders, Feb 29, 2024
  3. Junio C HamanoFeb 29, 2024
  4. Dirk GoudersFeb 29, 2024
  5. Junio C HamanoFeb 29, 2024
  6. Dirk GoudersMar 8, 2024
  7. Junio C HamanoMar 8, 2024
  8. Dirk GoudersMar 8, 2024
  9. 0/1 Documentation/user-manual.txt: try to clarify on object hashesDirk Gouders, Mar 12, 2024
  10. 1/1 Documentation/user-manual.txt: example for generating object hashesDirk Gouders, Mar 12, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.