diff options
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 46 |
1 files changed, 41 insertions, 5 deletions
@@ -4,6 +4,7 @@ #include "git-compat-util.h" #include "strbuf.h" #include "hashmap.h" +#include "mru.h" #include "advice.h" #include "gettext.h" #include "convert.h" @@ -443,6 +444,7 @@ static inline enum object_type object_type(unsigned int mode) #define GIT_NOGLOB_PATHSPECS_ENVIRONMENT "GIT_NOGLOB_PATHSPECS" #define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS" #define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH" +#define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS" /* * This environment variable is expected to contain a boolean indicating @@ -600,9 +602,28 @@ extern int do_read_index(struct index_state *istate, const char *path, extern int read_index_from(struct index_state *, const char *path); extern int is_index_unborn(struct index_state *); extern int read_index_unmerged(struct index_state *); + +/* For use with `write_locked_index()`. */ #define COMMIT_LOCK (1 << 0) -#define CLOSE_LOCK (1 << 1) + +/* + * Write the index while holding an already-taken lock. Close the lock, + * and if `COMMIT_LOCK` is given, commit it. + * + * Unless a split index is in use, write the index into the lockfile. + * + * With a split index, write the shared index to a temporary file, + * adjust its permissions and rename it into place, then write the + * split index to the lockfile. If the temporary file for the shared + * index cannot be created, fall back to the behavior described in + * the previous paragraph. + * + * With `COMMIT_LOCK`, the lock is always committed or rolled back. + * Without it, the lock is closed, but neither committed nor rolled + * back. + */ extern int write_locked_index(struct index_state *, struct lock_file *lock, unsigned flags); + extern int discard_index(struct index_state *); extern void move_index_extensions(struct index_state *dst, struct index_state *src); extern int unmerged_index(const struct index_state *); @@ -714,6 +735,10 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); extern int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg); extern struct cache_entry *refresh_cache_entry(struct cache_entry *, unsigned int); +/* + * Opportunistically update the index but do not complain if we can't. + * The lockfile is always committed or rolled back. + */ extern void update_index_if_able(struct index_state *, struct lock_file *); extern int hold_locked_index(struct lock_file *, int); @@ -783,6 +808,11 @@ extern int protect_ntfs; extern int ref_paranoia; /* + * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value). + */ +int use_optional_locks(void); + +/* * The character that begins a commented line in user-editable file * that is subject to stripspace. */ @@ -1243,8 +1273,8 @@ static inline unsigned int hexval(unsigned char c) */ static inline int hex2chr(const char *s) { - int val = hexval(s[0]); - return (val < 0) ? val : (val << 4) | hexval(s[1]); + unsigned int val = hexval(s[0]); + return (val & ~0xf) ? val : (val << 4) | hexval(s[1]); } /* Convert to/from hex/sha1 representation */ @@ -1311,6 +1341,13 @@ extern int get_sha1_hex(const char *hex, unsigned char *sha1); extern int get_oid_hex(const char *hex, struct object_id *sha1); /* + * Read `len` pairs of hexadecimal digits from `hex` and write the + * values to `binary` as `len` bytes. Return 0 on success, or -1 if + * the input does not consist of hex digits). + */ +extern int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); + +/* * Convert a binary sha1 to its hex equivalent. The `_r` variant is reentrant, * and writes the NUL-terminated output to the buffer `out`, which must be at * least `GIT_SHA1_HEXSZ + 1` bytes, and returns a pointer to out for @@ -1589,8 +1626,7 @@ extern struct packed_git { * A most-recently-used ordered version of the packed_git list, which can * be iterated instead of packed_git (and marked via mru_mark). */ -struct mru; -extern struct mru *packed_git_mru; +extern struct mru packed_git_mru; struct pack_entry { off_t offset; |