git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: 徐迪 <xudifsd@gmail.com>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: Philip Oakley <philipoakley@iee.org>, Git List <git@vger.kernel.org>
Subject: Re: Manually decoding a git object
Date: Mon, 20 Feb 2012 19:39:32 +0800	[thread overview]
Message-ID: <CAMocUqQdBH3BhWGfFCiCLXhtw=-tRVdL9RBjma_tdoVdj2-Crw@mail.gmail.com> (raw)
In-Reply-To: <871uppbwnu.fsf@thomas.inf.ethz.ch>

2012/2/20 Thomas Rast <trast@inf.ethz.ch>:
> Philip Oakley <philipoakley@iee.org> writes:
>
>> From: "Thomas Rast" <trast@inf.ethz.ch> Sent: Monday, February 20,
>> 2012 8:29 AM
>>>
>>> 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.
>>>
I think Thomas got the point.

> When I tried it from my home directory (not in a git directory):
> $ git cat-file -p Git-Object
> fatal: Not a git repository (or any of the parent directories): .git

this is because git will first do a git-dir-search, if you're current
work dir is not within git repo, it will die.
I really do not know how you get thing that mess. From the link[1] you
give, i think you just want to clone a repo across computer not by
network, if so this[2] will be helpful.

[1]:http://stackoverflow.com/questions/9343260/what-after-git-unpack-objects-to-get-the-actual-file
[2]:http://progit.org/2010/03/10/bundles.html

  reply	other threads:[~2012-02-20 11:39 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
2012-02-20 10:19       ` Philip Oakley
2012-02-20 10:56         ` Thomas Rast
2012-02-20 11:39           ` 徐迪 [this message]
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='CAMocUqQdBH3BhWGfFCiCLXhtw=-tRVdL9RBjma_tdoVdj2-Crw@mail.gmail.com' \
    --to=xudifsd@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=philipoakley@iee.org \
    --cc=trast@inf.ethz.ch \
    /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).