packfile.h 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#ifndef PACKFILE_H
#define PACKFILE_H

/*
 * Generate the filename to be used for a pack file with checksum "sha1" and
 * extension "ext". The result is written into the strbuf "buf", overwriting
 * any existing contents. A pointer to buf->buf is returned as a convenience.
 *
 * Example: odb_pack_name(out, sha1, "idx") => ".git/objects/pack/pack-1234..idx"
 */
extern char *odb_pack_name(struct strbuf *buf, const unsigned char *sha1, const char *ext);

/*
 * Return the name of the (local) packfile with the specified sha1 in
 * its name.  The return value is a pointer to memory that is
 * overwritten each time this function is called.
 */
extern char *sha1_pack_name(const unsigned char *sha1);

/*
 * Return the name of the (local) pack index file with the specified
 * sha1 in its name.  The return value is a pointer to memory that is
 * overwritten each time this function is called.
 */
extern char *sha1_pack_index_name(const unsigned char *sha1);

J
Jonathan Tan 已提交
27 28
extern unsigned int pack_open_fds;

29 30
extern struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);

J
Jonathan Tan 已提交
31 32
extern void install_packed_git(struct packed_git *pack);

J
Jonathan Tan 已提交
33 34
extern void pack_report(void);

35 36 37 38 39 40
/*
 * mmap the index file for the specified packfile (if it is not
 * already mmapped).  Return 0 on success.
 */
extern int open_pack_index(struct packed_git *);

J
Jonathan Tan 已提交
41 42 43 44 45 46
/*
 * munmap the index file for the specified packfile (if it is
 * currently mmapped).
 */
extern void close_pack_index(struct packed_git *);

J
Jonathan Tan 已提交
47
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
J
Jonathan Tan 已提交
48 49
extern void close_pack_windows(struct packed_git *);
extern void close_all_packs(void);
J
Jonathan Tan 已提交
50
extern void unuse_pack(struct pack_window **);
J
Jonathan Tan 已提交
51
extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);
J
Jonathan Tan 已提交
52

J
Jonathan Tan 已提交
53 54
extern void release_pack_memory(size_t);

J
Jonathan Tan 已提交
55 56
extern int open_packed_git(struct packed_git *p);

57
#endif