From: Junio C Hamano Date: Sun, 24 Aug 2008 01:28:37 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.1-rc1~310 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d6096f17d2d5d9ccb453aabf8edc6ee238b166fc?ds=inline;hp=-c Merge branch 'maint' * maint: unpack_trees(): protect the handcrafted in-core index from read_cache() git-p4: Fix one-liner in p4_write_pipe function. Completion: add missing '=' for 'diff --diff-filter' Fix 'git help help' --- d6096f17d2d5d9ccb453aabf8edc6ee238b166fc diff --combined cache.h index a097a959bd,884fae826c..ab9f97efc6 --- a/cache.h +++ b/cache.h @@@ -126,7 -126,6 +126,7 @@@ struct cache_entry #define CE_NAMEMASK (0x0fff) #define CE_STAGEMASK (0x3000) +#define CE_EXTENDED (0x4000) #define CE_VALID (0x8000) #define CE_STAGESHIFT 12 @@@ -223,7 -222,8 +223,8 @@@ struct index_state struct cache_tree *cache_tree; time_t timestamp; void *alloc; - unsigned name_hash_initialized : 1; + unsigned name_hash_initialized : 1, + initialized : 1; struct hash_table name_hash; }; @@@ -392,6 -392,7 +393,6 @@@ extern int ie_modified(const struct ind extern int ce_path_match(const struct cache_entry *ce, const char **pathspec); extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path); -extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object); extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object); extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); @@@ -451,7 -452,6 +452,7 @@@ enum safe_crlf extern enum safe_crlf safe_crlf; enum branch_track { + BRANCH_TRACK_UNSPECIFIED = -1, BRANCH_TRACK_NEVER = 0, BRANCH_TRACK_REMOTE, BRANCH_TRACK_ALWAYS, diff --combined read-cache.c index f0ba224798,35fec468b1..a857c8e12f --- a/read-cache.c +++ b/read-cache.c @@@ -1118,10 -1118,6 +1118,10 @@@ static void convert_from_disk(struct on ce->ce_size = ntohl(ondisk->size); /* On-disk flags are just 16 bits */ ce->ce_flags = ntohs(ondisk->flags); + + /* For future extension: we do not understand this entry yet */ + if (ce->ce_flags & CE_EXTENDED) + die("Unknown index entry format"); hashcpy(ce->sha1, ondisk->sha1); len = ce->ce_flags & CE_NAMEMASK; @@@ -1159,7 -1155,7 +1159,7 @@@ int read_index_from(struct index_state size_t mmap_size; errno = EBUSY; - if (istate->alloc) + if (istate->initialized) return istate->cache_nr; errno = ENOENT; @@@ -1199,6 -1195,7 +1199,7 @@@ * index size */ istate->alloc = xmalloc(estimate_cache_size(mmap_size, istate->cache_nr)); + istate->initialized = 1; src_offset = sizeof(*hdr); dst_offset = 0; @@@ -1251,6 -1248,7 +1252,7 @@@ int discard_index(struct index_state *i cache_tree_free(&(istate->cache_tree)); free(istate->alloc); istate->alloc = NULL; + istate->initialized = 0; /* no need to throw away allocated active_cache */ return 0;