git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Chico Sokol <chico.sokol@gmail.com>
To: John Szakmeister <john@szakmeister.net>
Cc: git <git@vger.kernel.org>
Subject: Re: Reading commit objects
Date: Tue, 21 May 2013 19:18:35 -0300	[thread overview]
Message-ID: <CABx5MBSnpZTthOHECqkbpdbFfkb4e_uSo-rh4owBc8B_oSKjJQ@mail.gmail.com> (raw)
In-Reply-To: <CAEBDL5XwrD8ZbRRSrM1iJGtcRgziH5bFVwRHzg9=_PYzaTfgAg@mail.gmail.com>

Ok, we discovered that the commit object actually contains the tree
object's sha1, by reading its contents with python zlib library.

So the bug must be with our java code (we're building a java lib).

Is there any non-standard issue in git's zlib compression? We're
decompressing its contents with java default zlib api, so it should
work normally, here's our code, that's printing that wrong output:

import java.io.File;
import java.io.FileInputStream;
import java.util.zip.InflaterInputStream;
import org.apache.commons.io.IOUtils;
...
File obj = new File(".git/objects/25/0f67ef017fcb97b5371a302526872cfcadad21");
InflaterInputStream inflaterInputStream = new InflaterInputStream(new
FileInputStream(obj));
System.out.println(IOUtils.readLines(inflaterInputStream));


I know that here it's not the right place to ask about java issues,
but we would appreciate any help any help.



--
Chico Sokol


On Tue, May 21, 2013 at 6:37 PM, John Szakmeister <john@szakmeister.net> wrote:
> On Tue, May 21, 2013 at 5:21 PM, Chico Sokol <chico.sokol@gmail.com> wrote:
>> Hello,
>>
>> I'm building a library to manipulate git repositories (interacting
>> directly with the filesystem).
>>
>> Currently, we're trying to parse commit objects. After decompressing
>> the contents of a commit object file we got the following output:
>>
>> commit 191
>> author Francisco Sokol <chico.sokol@gmail.com> 1369140112 -0300
>> committer Francisco Sokol <chico.sokol@gmail.com> 1369140112 -0300
>>
>> first commit
>
> Does `git cat-file -p <sha1>` show a tree object?  FWIW, I expected to
> see a tree line there, so maybe this object was created without a
> tree?  I also don't see a parent listed.
>
> I did this on one of my repos:
>
>>>> buf = open('.git/objects/cd/da219e4d7beceae55af73c44cb3c9e1ec56802', 'rb').read()
>>>> import zlib
>>>> zlib.decompress(buf)
> 'commit 246\x00tree 2abfe1a7bedb29672a223a5c5f266b7dc70a8d87\nparent
> 0636e7ff6b79470b0cd53ceacea88e7796f202ce\nauthor John Szakmeister
> <john@szakmeister.net> 1369168481 -0400\ncommitter John Szakmeister
> <john@szakmeister.net> 1369168481 -0400\n\nGot a file listing.\n'
>
> So at least creating the commits with Git, I see a tree.  How was the
> commit you're referencing created?  Perhaps something is wrong with
> that process?
>
>> We hoped to get the same output of a "git cat-file -p <sha1>", but
>> that didn't happened. From a commit object, how can I find tree object
>> hash of this commit?
>
> I'd expect that too.
>
> -John

  reply	other threads:[~2013-05-21 22:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21 21:21 Reading commit objects Chico Sokol
2013-05-21 21:25 ` Felipe Contreras
2013-05-21 21:37 ` John Szakmeister
2013-05-21 22:18   ` Chico Sokol [this message]
2013-05-21 22:22     ` Junio C Hamano
2013-05-21 22:33       ` Chico Sokol
2013-05-21 23:34         ` Jonathan Nieder
2013-05-22  5:54         ` Shawn Pearce
2013-05-22  4:51     ` java zlib woes (was: Reading commit objects) Andreas Krey
2013-05-22  5:56       ` Shawn Pearce
2013-05-27  4:11         ` Andreas Krey
2013-06-04 10:18           ` fetch delta resolution vs. checkout (was: java zlib woes) Andreas Krey
2013-05-22  5:59     ` Reading commit objects Shawn Pearce
2013-05-22 14:20       ` Chico Sokol
2013-05-22 20:02         ` Shawn Pearce
2013-05-22 14:25       ` Chico Sokol
2013-05-22 14:47         ` Chico Sokol
2013-05-22 19:59         ` Shawn Pearce
2013-05-21 22:20 ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABx5MBSnpZTthOHECqkbpdbFfkb4e_uSo-rh4owBc8B_oSKjJQ@mail.gmail.com \
    --to=chico.sokol@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=john@szakmeister.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).