From: Junio C Hamano Date: Mon, 24 Apr 2017 05:07:49 +0000 (-0700) Subject: Merge branch 'jh/verify-index-checksum-only-in-fsck' X-Git-Tag: v2.13.0-rc1~29 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cdfe138b360cd10f74ef9d2d031cb10447cb3338?ds=inline;hp=-c Merge branch 'jh/verify-index-checksum-only-in-fsck' The index file has a trailing SHA-1 checksum to detect file corruption, and historically we checked it every time the index file is used. Omit the validation during normal use, and instead verify only in "git fsck". * jh/verify-index-checksum-only-in-fsck: read-cache: force_verify_index_checksum --- cdfe138b360cd10f74ef9d2d031cb10447cb3338 diff --combined cache.h index 75cce814bd,ed3c5927cc..ef0fe43a9d --- a/cache.h +++ b/cache.h @@@ -66,12 -66,8 +66,12 @@@ unsigned long git_deflate_bound(git_zst #define GIT_SHA1_RAWSZ 20 #define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ) +/* The length in byte and in hex digits of the largest possible hash value. */ +#define GIT_MAX_RAWSZ GIT_SHA1_RAWSZ +#define GIT_MAX_HEXSZ GIT_SHA1_HEXSZ + struct object_id { - unsigned char hash[GIT_SHA1_RAWSZ]; + unsigned char hash[GIT_MAX_RAWSZ]; }; #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT) @@@ -415,7 -411,6 +415,7 @@@ static inline enum object_type object_t #define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE" #define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX" #define GIT_SUPER_PREFIX_ENVIRONMENT "GIT_INTERNAL_SUPER_PREFIX" +#define GIT_TOPLEVEL_PREFIX_ENVIRONMENT "GIT_INTERNAL_TOPLEVEL_PREFIX" #define DEFAULT_GIT_DIR_ENVIRONMENT ".git" #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" #define INDEX_ENVIRONMENT "GIT_INDEX_FILE" @@@ -710,6 -705,8 +710,8 @@@ extern void update_index_if_able(struc extern int hold_locked_index(struct lock_file *, int); extern void set_alternate_index_output(const char *); + extern int verify_index_checksum; + /* Environment bits from configuration mechanism */ extern int trust_executable_bit; extern int trust_ctime; @@@ -982,7 -979,7 +984,7 @@@ extern char *sha1_pack_index_name(cons extern const char *find_unique_abbrev(const unsigned char *sha1, int len); extern int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len); -extern const unsigned char null_sha1[GIT_SHA1_RAWSZ]; +extern const unsigned char null_sha1[GIT_MAX_RAWSZ]; extern const struct object_id null_oid; static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) @@@ -1164,7 -1161,7 +1166,7 @@@ typedef int create_file_fn(const char * int raceproof_create_file(const char *path, create_file_fn fn, void *cb); int mkdir_in_gitdir(const char *path); -extern char *expand_user_path(const char *path); +extern char *expand_user_path(const char *path, int real_home); const char *enter_repo(const char *path, int strict); static inline int is_absolute_path(const char *path) { @@@ -1364,7 -1361,7 +1366,7 @@@ extern int get_sha1_with_context(const extern int get_oid(const char *str, struct object_id *oid); -typedef int each_abbrev_fn(const unsigned char *sha1, void *); +typedef int each_abbrev_fn(const struct object_id *oid, void *); extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *); extern int set_disambiguate_hint_config(const char *var, const char *value); @@@ -1679,12 -1676,9 +1681,12 @@@ extern struct packed_git *find_sha1_pac extern void pack_report(void); /* - * Create a temporary file rooted in the object database directory. + * Create a temporary file rooted in the object database directory, or + * die on failure. The filename is taken from "pattern", which should have the + * usual "XXXXXX" trailer, and the resulting filename is written into the + * "template" buffer. Returns the open descriptor. */ -extern int odb_mkstemp(char *template, size_t limit, const char *pattern); +extern int odb_mkstemp(struct strbuf *template, const char *pattern); /* * Generate the filename to be used for a pack file with checksum "sha1" and @@@ -1908,7 -1902,6 +1910,7 @@@ extern int git_parse_maybe_bool(const c extern int git_config_int(const char *, const char *); extern int64_t git_config_int64(const char *, const char *); extern unsigned long git_config_ulong(const char *, const char *); +extern ssize_t git_config_ssize_t(const char *, const char *); extern int git_config_bool_or_int(const char *, const char *, int *); extern int git_config_bool(const char *, const char *); extern int git_config_maybe_bool(const char *, const char *);