mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 10:37:05 +00:00
Move the pack structs to an internal header
This commit is contained in:
parent
7bfdb3d22b
commit
c7c9e18388
@ -33,68 +33,10 @@
|
||||
#include "delta-apply.h"
|
||||
#include "sha1_lookup.h"
|
||||
#include "mwindow.h"
|
||||
#include "pack.h"
|
||||
|
||||
#include "git2/odb_backend.h"
|
||||
|
||||
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
|
||||
#define PACK_VERSION 2
|
||||
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
|
||||
struct pack_header {
|
||||
uint32_t hdr_signature;
|
||||
uint32_t hdr_version;
|
||||
uint32_t hdr_entries;
|
||||
};
|
||||
|
||||
/*
|
||||
* The first four bytes of index formats later than version 1 should
|
||||
* start with this signature, as all older git binaries would find this
|
||||
* value illegal and abort reading the file.
|
||||
*
|
||||
* This is the case because the number of objects in a packfile
|
||||
* cannot exceed 1,431,660,000 as every object would need at least
|
||||
* 3 bytes of data and the overall packfile cannot exceed 4 GiB with
|
||||
* version 1 of the index file due to the offsets limited to 32 bits.
|
||||
* Clearly the signature exceeds this maximum.
|
||||
*
|
||||
* Very old git binaries will also compare the first 4 bytes to the
|
||||
* next 4 bytes in the index and abort with a "non-monotonic index"
|
||||
* error if the second 4 byte word is smaller than the first 4
|
||||
* byte word. This would be true in the proposed future index
|
||||
* format as idx_signature would be greater than idx_version.
|
||||
*/
|
||||
#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
|
||||
|
||||
struct pack_idx_header {
|
||||
uint32_t idx_signature;
|
||||
uint32_t idx_version;
|
||||
};
|
||||
|
||||
struct pack_file {
|
||||
int pack_fd;
|
||||
git_mwindow_file mwf;
|
||||
//git_mwindow *windows;
|
||||
off_t pack_size;
|
||||
git_map index_map;
|
||||
|
||||
uint32_t num_objects;
|
||||
uint32_t num_bad_objects;
|
||||
git_oid *bad_object_sha1; /* array of git_oid */
|
||||
|
||||
int index_version;
|
||||
git_time_t mtime;
|
||||
unsigned pack_local:1, pack_keep:1;
|
||||
git_oid sha1;
|
||||
|
||||
/* something like ".git/objects/pack/xxxxx.pack" */
|
||||
char pack_name[GIT_FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
struct pack_entry {
|
||||
off_t offset;
|
||||
git_oid sha1;
|
||||
struct pack_file *p;
|
||||
};
|
||||
|
||||
struct pack_backend {
|
||||
git_odb_backend parent;
|
||||
git_vector packs;
|
||||
|
94
src/pack.h
Normal file
94
src/pack.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* In addition to the permissions in the GNU General Public License,
|
||||
* the authors give you unlimited permission to link the compiled
|
||||
* version of this file into combinations with other programs,
|
||||
* and to distribute those combinations without any restriction
|
||||
* coming from the use of this file. (The General Public License
|
||||
* restrictions do apply in other respects; for example, they cover
|
||||
* modification of the file, and distribution when not linked into
|
||||
* a combined executable.)
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_pack_h__
|
||||
#define INCLUDE_pack_h__
|
||||
|
||||
#include "git2/oid.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "map.h"
|
||||
#include "mwindow.h"
|
||||
|
||||
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
|
||||
#define PACK_VERSION 2
|
||||
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
|
||||
struct pack_header {
|
||||
uint32_t hdr_signature;
|
||||
uint32_t hdr_version;
|
||||
uint32_t hdr_entries;
|
||||
};
|
||||
|
||||
/*
|
||||
* The first four bytes of index formats later than version 1 should
|
||||
* start with this signature, as all older git binaries would find this
|
||||
* value illegal and abort reading the file.
|
||||
*
|
||||
* This is the case because the number of objects in a packfile
|
||||
* cannot exceed 1,431,660,000 as every object would need at least
|
||||
* 3 bytes of data and the overall packfile cannot exceed 4 GiB with
|
||||
* version 1 of the index file due to the offsets limited to 32 bits.
|
||||
* Clearly the signature exceeds this maximum.
|
||||
*
|
||||
* Very old git binaries will also compare the first 4 bytes to the
|
||||
* next 4 bytes in the index and abort with a "non-monotonic index"
|
||||
* error if the second 4 byte word is smaller than the first 4
|
||||
* byte word. This would be true in the proposed future index
|
||||
* format as idx_signature would be greater than idx_version.
|
||||
*/
|
||||
|
||||
#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
|
||||
|
||||
struct pack_idx_header {
|
||||
uint32_t idx_signature;
|
||||
uint32_t idx_version;
|
||||
};
|
||||
|
||||
struct pack_file {
|
||||
int pack_fd;
|
||||
git_mwindow_file mwf;
|
||||
off_t pack_size;
|
||||
git_map index_map;
|
||||
|
||||
uint32_t num_objects;
|
||||
uint32_t num_bad_objects;
|
||||
git_oid *bad_object_sha1; /* array of git_oid */
|
||||
|
||||
int index_version;
|
||||
git_time_t mtime;
|
||||
unsigned pack_local:1, pack_keep:1;
|
||||
git_oid sha1;
|
||||
|
||||
/* something like ".git/objects/pack/xxxxx.pack" */
|
||||
char pack_name[GIT_FLEX_ARRAY]; /* more */
|
||||
};
|
||||
|
||||
struct pack_entry {
|
||||
off_t offset;
|
||||
git_oid sha1;
|
||||
struct pack_file *p;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user