Skip to content

Commit eabdcd4

Browse files
committed
Merge branch 'jt/packmigrate'
Code movement to make it easier to hack later. * jt/packmigrate: (23 commits) pack: move for_each_packed_object() pack: move has_pack_index() pack: move has_sha1_pack() pack: move find_pack_entry() and make it global pack: move find_sha1_pack() pack: move find_pack_entry_one(), is_pack_valid() pack: move check_pack_index_ptr(), nth_packed_object_offset() pack: move nth_packed_object_{sha1,oid} pack: move clear_delta_base_cache(), packed_object_info(), unpack_entry() pack: move unpack_object_header() pack: move get_size_from_delta() pack: move unpack_object_header_buffer() pack: move {,re}prepare_packed_git and approximate_object_count pack: move install_packed_git() pack: move add_packed_git() pack: move unuse_pack() pack: move use_pack() pack: move pack-closing functions pack: move release_pack_memory() pack: move open_pack_index(), parse_pack_index() ...
2 parents f2dd90f + 7709f46 commit eabdcd4

37 files changed

+2354
-2287
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ LIB_OBJS += notes-merge.o
817817
LIB_OBJS += notes-utils.o
818818
LIB_OBJS += object.o
819819
LIB_OBJS += oidset.o
820+
LIB_OBJS += packfile.o
820821
LIB_OBJS += pack-bitmap.o
821822
LIB_OBJS += pack-bitmap-write.o
822823
LIB_OBJS += pack-check.o

builtin/am.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "mailinfo.h"
3232
#include "apply.h"
3333
#include "string-list.h"
34+
#include "packfile.h"
3435

3536
/**
3637
* Returns 1 if the file is empty or does not exist, 0 otherwise.

builtin/cat-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "streaming.h"
1313
#include "tree-walk.h"
1414
#include "sha1-array.h"
15+
#include "packfile.h"
1516

1617
struct batch_options {
1718
int enabled;

builtin/clone.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "remote.h"
2626
#include "run-command.h"
2727
#include "connected.h"
28+
#include "packfile.h"
2829

2930
/*
3031
* Overall FIXMEs:

builtin/count-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "builtin.h"
1111
#include "parse-options.h"
1212
#include "quote.h"
13+
#include "packfile.h"
1314

1415
static unsigned long garbage;
1516
static off_t size_garbage;

builtin/fetch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "connected.h"
1818
#include "argv-array.h"
1919
#include "utf8.h"
20+
#include "packfile.h"
2021

2122
static const char * const builtin_fetch_usage[] = {
2223
N_("git fetch [<options>] [<repository> [<refspec>...]]"),

builtin/fsck.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "progress.h"
1616
#include "streaming.h"
1717
#include "decorate.h"
18+
#include "packfile.h"
1819

1920
#define REACHABLE 0x0001
2021
#define SEEN 0x0002

builtin/gc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "sigchain.h"
2020
#include "argv-array.h"
2121
#include "commit.h"
22+
#include "packfile.h"
2223

2324
#define FAILED_RUN "failed to run %s"
2425

builtin/index-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "exec_cmd.h"
1313
#include "streaming.h"
1414
#include "thread-utils.h"
15+
#include "packfile.h"
1516

1617
static const char index_pack_usage[] =
1718
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";

builtin/merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "gpg-interface.h"
3333
#include "sequencer.h"
3434
#include "string-list.h"
35+
#include "packfile.h"
3536

3637
#define DEFAULT_TWOHEAD (1<<0)
3738
#define DEFAULT_OCTOPUS (1<<1)

builtin/pack-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "sha1-array.h"
2626
#include "argv-array.h"
2727
#include "mru.h"
28+
#include "packfile.h"
2829

2930
static const char *pack_usage[] = {
3031
N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"),

builtin/pack-redundant.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include "builtin.h"
10+
#include "packfile.h"
1011

1112
#define BLKSIZE 512
1213

builtin/prune-packed.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cache.h"
33
#include "progress.h"
44
#include "parse-options.h"
5+
#include "packfile.h"
56

67
static const char * const prune_packed_usage[] = {
78
N_("git prune-packed [-n | --dry-run] [-q | --quiet]"),

builtin/receive-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "fsck.h"
2424
#include "tmp-objdir.h"
2525
#include "oidset.h"
26+
#include "packfile.h"
2627

2728
static const char * const receive_pack_usage[] = {
2829
N_("git receive-pack <git-dir>"),

bulk-checkin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "csum-file.h"
77
#include "pack.h"
88
#include "strbuf.h"
9+
#include "packfile.h"
910

1011
static struct bulk_checkin_state {
1112
unsigned plugged:1;

cache.h

Lines changed: 1 addition & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -902,20 +902,6 @@ extern void check_repository_format(void);
902902
*/
903903
extern const char *sha1_file_name(const unsigned char *sha1);
904904

905-
/*
906-
* Return the name of the (local) packfile with the specified sha1 in
907-
* its name. The return value is a pointer to memory that is
908-
* overwritten each time this function is called.
909-
*/
910-
extern char *sha1_pack_name(const unsigned char *sha1);
911-
912-
/*
913-
* Return the name of the (local) pack index file with the specified
914-
* sha1 in its name. The return value is a pointer to memory that is
915-
* overwritten each time this function is called.
916-
*/
917-
extern char *sha1_pack_index_name(const unsigned char *sha1);
918-
919905
/*
920906
* Return an abbreviated sha1 unique within this repository's object database.
921907
* The result will be at least `len` characters long, and will be NUL
@@ -1201,15 +1187,10 @@ extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
12011187
extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
12021188
extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
12031189

1204-
/* global flag to enable extra checks when accessing packed objects */
1205-
extern int do_check_packed_object_crc;
1206-
12071190
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
12081191

12091192
extern int finalize_object_file(const char *tmpfile, const char *filename);
12101193

1211-
extern int has_sha1_pack(const unsigned char *sha1);
1212-
12131194
/*
12141195
* Open the loose object at path, check its sha1, and return the contents,
12151196
* type, and size. If the object is a blob, then "contents" may return NULL,
@@ -1245,8 +1226,6 @@ extern int has_object_file_with_flags(const struct object_id *oid, int flags);
12451226
*/
12461227
extern int has_loose_object_nonlocal(const unsigned char *sha1);
12471228

1248-
extern int has_pack_index(const unsigned char *sha1);
1249-
12501229
extern void assert_sha1_type(const unsigned char *sha1, enum object_type expect);
12511230

12521231
/* Helper to check and "touch" a file */
@@ -1619,29 +1598,6 @@ struct pack_entry {
16191598
struct packed_git *p;
16201599
};
16211600

1622-
extern struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);
1623-
1624-
/* A hook to report invalid files in pack directory */
1625-
#define PACKDIR_FILE_PACK 1
1626-
#define PACKDIR_FILE_IDX 2
1627-
#define PACKDIR_FILE_GARBAGE 4
1628-
extern void (*report_garbage)(unsigned seen_bits, const char *path);
1629-
1630-
extern void prepare_packed_git(void);
1631-
extern void reprepare_packed_git(void);
1632-
extern void install_packed_git(struct packed_git *pack);
1633-
1634-
/*
1635-
* Give a rough count of objects in the repository. This sacrifices accuracy
1636-
* for speed.
1637-
*/
1638-
unsigned long approximate_object_count(void);
1639-
1640-
extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
1641-
struct packed_git *packs);
1642-
1643-
extern void pack_report(void);
1644-
16451601
/*
16461602
* Create a temporary file rooted in the object database directory, or
16471603
* die on failure. The filename is taken from "pattern", which should have the
@@ -1650,83 +1606,13 @@ extern void pack_report(void);
16501606
*/
16511607
extern int odb_mkstemp(struct strbuf *template, const char *pattern);
16521608

1653-
/*
1654-
* Generate the filename to be used for a pack file with checksum "sha1" and
1655-
* extension "ext". The result is written into the strbuf "buf", overwriting
1656-
* any existing contents. A pointer to buf->buf is returned as a convenience.
1657-
*
1658-
* Example: odb_pack_name(out, sha1, "idx") => ".git/objects/pack/pack-1234..idx"
1659-
*/
1660-
extern char *odb_pack_name(struct strbuf *buf, const unsigned char *sha1, const char *ext);
1661-
16621609
/*
16631610
* Create a pack .keep file named "name" (which should generally be the output
16641611
* of odb_pack_name). Returns a file descriptor opened for writing, or -1 on
16651612
* error.
16661613
*/
16671614
extern int odb_pack_keep(const char *name);
16681615

1669-
/*
1670-
* mmap the index file for the specified packfile (if it is not
1671-
* already mmapped). Return 0 on success.
1672-
*/
1673-
extern int open_pack_index(struct packed_git *);
1674-
1675-
/*
1676-
* munmap the index file for the specified packfile (if it is
1677-
* currently mmapped).
1678-
*/
1679-
extern void close_pack_index(struct packed_git *);
1680-
1681-
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
1682-
extern void close_pack_windows(struct packed_git *);
1683-
extern void close_all_packs(void);
1684-
extern void unuse_pack(struct pack_window **);
1685-
extern void clear_delta_base_cache(void);
1686-
extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);
1687-
1688-
/*
1689-
* Make sure that a pointer access into an mmap'd index file is within bounds,
1690-
* and can provide at least 8 bytes of data.
1691-
*
1692-
* Note that this is only necessary for variable-length segments of the file
1693-
* (like the 64-bit extended offset table), as we compare the size to the
1694-
* fixed-length parts when we open the file.
1695-
*/
1696-
extern void check_pack_index_ptr(const struct packed_git *p, const void *ptr);
1697-
1698-
/*
1699-
* Return the SHA-1 of the nth object within the specified packfile.
1700-
* Open the index if it is not already open. The return value points
1701-
* at the SHA-1 within the mmapped index. Return NULL if there is an
1702-
* error.
1703-
*/
1704-
extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t n);
1705-
/*
1706-
* Like nth_packed_object_sha1, but write the data into the object specified by
1707-
* the the first argument. Returns the first argument on success, and NULL on
1708-
* error.
1709-
*/
1710-
extern const struct object_id *nth_packed_object_oid(struct object_id *, struct packed_git *, uint32_t n);
1711-
1712-
/*
1713-
* Return the offset of the nth object within the specified packfile.
1714-
* The index must already be opened.
1715-
*/
1716-
extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);
1717-
1718-
/*
1719-
* If the object named sha1 is present in the specified packfile,
1720-
* return its offset within the packfile; otherwise, return 0.
1721-
*/
1722-
extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);
1723-
1724-
extern int is_pack_valid(struct packed_git *);
1725-
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
1726-
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
1727-
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
1728-
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
1729-
17301616
/*
17311617
* Iterate over the files in the loose-object parts of the object
17321618
* directory "path", triggering the following callbacks:
@@ -1776,17 +1662,12 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
17761662
void *data);
17771663

17781664
/*
1779-
* Iterate over loose and packed objects in both the local
1665+
* Iterate over loose objects in both the local
17801666
* repository and any alternates repositories (unless the
17811667
* LOCAL_ONLY flag is set).
17821668
*/
17831669
#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
1784-
typedef int each_packed_object_fn(const struct object_id *oid,
1785-
struct packed_git *pack,
1786-
uint32_t pos,
1787-
void *data);
17881670
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
1789-
extern int for_each_packed_object(each_packed_object_fn, void *, unsigned flags);
17901671

17911672
struct object_info {
17921673
/* Request */
@@ -1836,7 +1717,6 @@ struct object_info {
18361717
/* Do not retry packed storage after checking packed and loose storage */
18371718
#define OBJECT_INFO_QUICK 8
18381719
extern int sha1_object_info_extended(const unsigned char *, struct object_info *, unsigned flags);
1839-
extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);
18401720

18411721
/* Dumb servers support */
18421722
extern int update_server_info(int);

connected.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "sigchain.h"
44
#include "connected.h"
55
#include "transport.h"
6+
#include "packfile.h"
67

78
/*
89
* If we feed all the commits we want to verify to this command

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "string-list.h"
2222
#include "argv-array.h"
2323
#include "graph.h"
24+
#include "packfile.h"
2425

2526
#ifdef NO_FAST_WORKING_DIRECTORY
2627
#define FAST_WORKING_DIRECTORY 0

fast-import.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Format of STDIN stream:
167167
#include "quote.h"
168168
#include "dir.h"
169169
#include "run-command.h"
170+
#include "packfile.h"
170171

171172
#define PACK_ID_BITS 16
172173
#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)

fetch-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "prio-queue.h"
1818
#include "sha1-array.h"
1919
#include "oidset.h"
20+
#include "packfile.h"
2021

2122
static int transfer_unpack_limit = -1;
2223
static int fetch_unpack_limit = -1;

git-compat-util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,6 @@ const char *inet_ntop(int af, const void *src, char *dst, size_t size);
749749
extern int git_atexit(void (*handler)(void));
750750
#endif
751751

752-
extern void release_pack_memory(size_t);
753-
754752
typedef void (*try_to_free_t)(size_t);
755753
extern try_to_free_t set_try_to_free_routine(try_to_free_t);
756754

http-backend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "string-list.h"
1010
#include "url.h"
1111
#include "argv-array.h"
12+
#include "packfile.h"
1213

1314
static const char content_type[] = "Content-Type";
1415
static const char content_length[] = "Content-Length";

http-push.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "list-objects.h"
1212
#include "sigchain.h"
1313
#include "argv-array.h"
14+
#include "packfile.h"
1415

1516
#ifdef EXPAT_NEEDS_XMLPARSE_H
1617
#include <xmlparse.h>

http-walker.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "http.h"
55
#include "list.h"
66
#include "transport.h"
7+
#include "packfile.h"
78

89
struct alt_base {
910
char *base;

http.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "pkt-line.h"
1212
#include "gettext.h"
1313
#include "transport.h"
14+
#include "packfile.h"
1415

1516
static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
1617
#if LIBCURL_VERSION_NUM >= 0x070a08

outgoing/packfile.h

Whitespace-only changes.

pack-bitmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "pack-bitmap.h"
1010
#include "pack-revindex.h"
1111
#include "pack-objects.h"
12+
#include "packfile.h"
1213

1314
/*
1415
* An entry on the bitmap index, representing the bitmap for a given

pack-check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "pack.h"
33
#include "pack-revindex.h"
44
#include "progress.h"
5+
#include "packfile.h"
56

67
struct idx_entry {
78
off_t offset;

0 commit comments

Comments
 (0)