git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Farhan Khan <khanzf@gmail.com>
To: git@vger.kernel.org
Subject: Understanding Index Header
Date: Sat, 6 Oct 2018 17:13:45 -0400	[thread overview]
Message-ID: <CAFd4kYC5psSkXxrHVU11b5bufFFVr-qP=S_Fn9AegCyADLw+HA@mail.gmail.com> (raw)

Hi all,

I am writing a program that parses out the .git/index file. I am
reading the git index header documentation, but I seem to be getting
jibberish data.
https://github.com/git/git/blob/master/Documentation/technical/index-format.txt

The first 12 bytes are the signature, version and entries. Great so far.

Afterwards, I try to read the extension signature, which the
documentation says: "4-byte extension signature. If the first byte is
'A'..'Z' the
extension is optional and can be ignored.". I am getting jibberish. Is
this expected?

Then, the extension size comes back as 35560000 (after ntohl()). That
seems extremely high. My structure is as follows:

struct _indexfile_hdr {
        unsigned char   sig[4];         /* Always "DIRC" */
        uint32_t        version;        /* Version Number */
        uint32_t        entries;        /* Number of extensions */
        unsigned char   extsig[4];      /* Extension signature */
        uint32_t        extsize;        /* Size of the extension */
        uint8_t         sha[8];         /* SHA1 of index before checksum */
} __packed;

Am I doing something wrong? Is there some offset or padding that I missed?

Thanks,
--
Farhan Khan
PGP Fingerprint: B28D 2726 E2BC A97E 3854 5ABE 9A9F 00BC D525 16EE

             reply	other threads:[~2018-10-06 21:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-06 21:13 Farhan Khan [this message]
2018-10-06 22:31 ` Understanding Index Header Kevin Daudt

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='CAFd4kYC5psSkXxrHVU11b5bufFFVr-qP=S_Fn9AegCyADLw+HA@mail.gmail.com' \
    --to=khanzf@gmail.com \
    --cc=git@vger.kernel.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.
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).