]>
git.proxmox.com Git - libgit2.git/blob - src/pack.h
2 * This file is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2,
4 * as published by the Free Software Foundation.
6 * In addition to the permissions in the GNU General Public License,
7 * the authors give you unlimited permission to link the compiled
8 * version of this file into combinations with other programs,
9 * and to distribute those combinations without any restriction
10 * coming from the use of this file. (The General Public License
11 * restrictions do apply in other respects; for example, they cover
12 * modification of the file, and distribution when not linked into
13 * a combined executable.)
15 * This file is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
26 #ifndef INCLUDE_pack_h__
27 #define INCLUDE_pack_h__
36 #define PACK_SIGNATURE 0x5041434b /* "PACK" */
37 #define PACK_VERSION 2
38 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
39 struct git_pack_header
{
40 uint32_t hdr_signature
;
46 * The first four bytes of index formats later than version 1 should
47 * start with this signature, as all older git binaries would find this
48 * value illegal and abort reading the file.
50 * This is the case because the number of objects in a packfile
51 * cannot exceed 1,431,660,000 as every object would need at least
52 * 3 bytes of data and the overall packfile cannot exceed 4 GiB with
53 * version 1 of the index file due to the offsets limited to 32 bits.
54 * Clearly the signature exceeds this maximum.
56 * Very old git binaries will also compare the first 4 bytes to the
57 * next 4 bytes in the index and abort with a "non-monotonic index"
58 * error if the second 4 byte word is smaller than the first 4
59 * byte word. This would be true in the proposed future index
60 * format as idx_signature would be greater than idx_version.
63 #define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
65 struct git_pack_idx_header
{
66 uint32_t idx_signature
;
70 struct git_pack_file
{
75 uint32_t num_bad_objects
;
76 git_oid
*bad_object_sha1
; /* array of git_oid */
80 unsigned pack_local
:1, pack_keep
:1;
83 /* something like ".git/objects/pack/xxxxx.pack" */
84 char pack_name
[GIT_FLEX_ARRAY
]; /* more */
87 struct git_pack_entry
{
90 struct git_pack_file
*p
;
93 int git_packfile_unpack_header(
96 git_mwindow_file
*mwf
,
100 int git_packfile_unpack(git_rawobj
*obj
, struct git_pack_file
*p
, off_t
*obj_offset
);
102 off_t
get_delta_base(struct git_pack_file
*p
, git_mwindow
**w_curs
,
103 off_t
*curpos
, git_otype type
,
104 off_t delta_obj_offset
);
106 void packfile_free(struct git_pack_file
*p
);
107 int git_packfile_check(struct git_pack_file
**pack_out
, const char *path
);
108 int git_pack_entry_find(
109 struct git_pack_entry
*e
,
110 struct git_pack_file
*p
,
111 const git_oid
*short_oid
,