From: Thomas Rast <trast@inf.ethz.ch>
To: Philip Oakley <philipoakley@iee.org>
Cc: Git List <git@vger.kernel.org>
Subject: Re: Manually decoding a git object
Date: Mon, 20 Feb 2012 09:29:46 +0100 [thread overview]
Message-ID: <87mx8dj4at.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <A716A27D407F401DAAC373027D5CFF2A@PhilipOakley> (Philip Oakley's message of "Sun, 19 Feb 2012 18:07:51 -0000")
"Philip Oakley" <philipoakley@iee.org> writes:
> If I have a renamed file which is a git object, such a "Git_Object", was
> 8c-something-or-other, what is the easiest way of examining / decoding /
> recreating the original file (either as its sha1, or a cat-file).
>
> I don't appear to be able to unzip the file in its raw format... I'm using
> Msysgit on windows XP.
The SHA1 is over the decompressed object contents. The file simply
holds a zlib-compressed stream of those contents. (It's pretty much
like gzip without the file header.)
You can use any bindings to zlib and something that does sha1, e.g. in
python:
$ cd g/.git/objects/aa/ # my git.git
$ ls
592bda986a8380b64acd8cbb3d5bdfcbc0834d 6322a757bee31919f54edcc127608a3d724c99
$ python
Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.sha1(open('592bda986a8380b64acd8cbb3d5bdfcbc0834d').read().decode('zlib')).digest().encode('hex')
'aa592bda986a8380b64acd8cbb3d5bdfcbc0834d'
Notice that the first byte of the hash goes into the directory name.
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2012-02-20 8:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-15 13:22 [PATCH/RFC] Document format of basic Git objects Nguyễn Thái Ngọc Duy
2012-02-15 17:31 ` Jonathan Nieder
2012-02-15 19:48 ` Junio C Hamano
2012-02-16 7:12 ` Junio C Hamano
2012-02-19 4:15 ` [PATCH/RFC v2] " Nguyễn Thái Ngọc Duy
2012-02-19 8:39 ` Junio C Hamano
2012-02-19 9:14 ` Junio C Hamano
2012-02-20 13:55 ` Nguyen Thai Ngoc Duy
2012-02-20 16:11 ` Jeff King
2012-02-19 18:07 ` Manually decoding a git object Philip Oakley
2012-02-20 4:45 ` 徐迪
2012-02-20 8:19 ` Philip Oakley
2012-02-20 8:29 ` Thomas Rast [this message]
2012-02-20 10:19 ` Philip Oakley
2012-02-20 10:56 ` Thomas Rast
2012-02-20 11:39 ` 徐迪
2012-02-20 18:27 ` Philip Oakley
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=87mx8dj4at.fsf@thomas.inf.ethz.ch \
--to=trast@inf.ethz.ch \
--cc=git@vger.kernel.org \
--cc=philipoakley@iee.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).