]>
git.proxmox.com Git - libgit2.git/blob - src/pack.h
2 * Copyright (C) 2009-2011 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
8 #ifndef INCLUDE_pack_h__
9 #define INCLUDE_pack_h__
18 #define PACK_SIGNATURE 0x5041434b /* "PACK" */
19 #define PACK_VERSION 2
20 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
21 struct git_pack_header
{
22 uint32_t hdr_signature
;
28 * The first four bytes of index formats later than version 1 should
29 * start with this signature, as all older git binaries would find this
30 * value illegal and abort reading the file.
32 * This is the case because the number of objects in a packfile
33 * cannot exceed 1,431,660,000 as every object would need at least
34 * 3 bytes of data and the overall packfile cannot exceed 4 GiB with
35 * version 1 of the index file due to the offsets limited to 32 bits.
36 * Clearly the signature exceeds this maximum.
38 * Very old git binaries will also compare the first 4 bytes to the
39 * next 4 bytes in the index and abort with a "non-monotonic index"
40 * error if the second 4 byte word is smaller than the first 4
41 * byte word. This would be true in the proposed future index
42 * format as idx_signature would be greater than idx_version.
45 #define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
47 struct git_pack_idx_header
{
48 uint32_t idx_signature
;
52 struct git_pack_file
{
57 uint32_t num_bad_objects
;
58 git_oid
*bad_object_sha1
; /* array of git_oid */
62 unsigned pack_local
:1, pack_keep
:1, has_cache
:1;
66 /* something like ".git/objects/pack/xxxxx.pack" */
67 char pack_name
[GIT_FLEX_ARRAY
]; /* more */
70 struct git_pack_entry
{
73 struct git_pack_file
*p
;
76 int git_packfile_unpack_header(
79 git_mwindow_file
*mwf
,
83 int git_packfile_unpack(git_rawobj
*obj
, struct git_pack_file
*p
, off_t
*obj_offset
);
85 off_t
get_delta_base(struct git_pack_file
*p
, git_mwindow
**w_curs
,
86 off_t
*curpos
, git_otype type
,
87 off_t delta_obj_offset
);
89 void packfile_free(struct git_pack_file
*p
);
90 int git_packfile_check(struct git_pack_file
**pack_out
, const char *path
);
91 int git_pack_entry_find(
92 struct git_pack_entry
*e
,
93 struct git_pack_file
*p
,
94 const git_oid
*short_oid
,