From: Junio C Hamano Date: Wed, 3 Apr 2013 16:34:00 +0000 (-0700) Subject: Merge branch 'nd/checkout-paths-reduce-match-pathspec-calls' X-Git-Tag: v1.8.3-rc0~129 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/97fefaf6d32d3e8dbb78778f62fcdd980dcf46c7?ds=inline;hp=-c Merge branch 'nd/checkout-paths-reduce-match-pathspec-calls' Consolidate repeated pathspec matches on the same paths, while fixing a bug in "git checkout dir/" code started from an unmerged index. * nd/checkout-paths-reduce-match-pathspec-calls: checkout: avoid unnecessary match_pathspec calls --- 97fefaf6d32d3e8dbb78778f62fcdd980dcf46c7 diff --combined cache.h index ec2fd7a304,54a42a1178..c12957bb03 --- a/cache.h +++ b/cache.h @@@ -34,7 -34,6 +34,7 @@@ int git_inflate(git_zstream *, int flus void git_deflate_init(git_zstream *, int level); void git_deflate_init_gzip(git_zstream *, int level); +void git_deflate_init_raw(git_zstream *, int level); void git_deflate_end(git_zstream *); int git_deflate_abort(git_zstream *); int git_deflate_end_gently(git_zstream *); @@@ -132,6 -131,7 +132,6 @@@ struct cache_entry unsigned int ce_namelen; unsigned char sha1[20]; struct cache_entry *next; - struct cache_entry *dir_next; char name[FLEX_ARRAY]; /* more */ }; @@@ -162,6 -162,9 +162,9 @@@ #define CE_UNPACKED (1 << 24) #define CE_NEW_SKIP_WORKTREE (1 << 25) + /* used to temporarily mark paths matched by pathspecs */ + #define CE_MATCHED (1 << 26) + /* * Extended on-disk flags */ @@@ -267,15 -270,25 +270,15 @@@ struct index_state unsigned name_hash_initialized : 1, initialized : 1; struct hash_table name_hash; + struct hash_table dir_hash; }; extern struct index_state the_index; /* Name hashing */ extern void add_name_hash(struct index_state *istate, struct cache_entry *ce); -/* - * We don't actually *remove* it, we can just mark it invalid so that - * we won't find it in lookups. - * - * Not only would we have to search the lists (simple enough), but - * we'd also have to rehash other hash buckets in case this makes the - * hash bucket empty (common). So it's much better to just mark - * it. - */ -static inline void remove_name_hash(struct cache_entry *ce) -{ - ce->ce_flags |= CE_UNHASHED; -} +extern void remove_name_hash(struct index_state *istate, struct cache_entry *ce); +extern void free_name_hash(struct index_state *istate); #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS @@@ -331,11 -344,9 +334,11 @@@ static inline enum object_type object_t OBJ_BLOB; } +/* Double-check local_repo_env below if you add to this list. */ #define GIT_DIR_ENVIRONMENT "GIT_DIR" #define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE" #define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE" +#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX" #define DEFAULT_GIT_DIR_ENVIRONMENT ".git" #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" #define INDEX_ENVIRONMENT "GIT_INDEX_FILE" @@@ -357,24 -368,13 +360,24 @@@ #define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS" /* - * Repository-local GIT_* environment variables - * The array is NULL-terminated to simplify its usage in contexts such - * environment creation or simple walk of the list. - * The number of non-NULL entries is available as a macro. + * This environment variable is expected to contain a boolean indicating + * whether we should or should not treat: + * + * GIT_DIR=foo.git git ... + * + * as if GIT_WORK_TREE=. was given. It's not expected that users will make use + * of this, but we use it internally to communicate to sub-processes that we + * are in a bare repo. If not set, defaults to true. + */ +#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE" + +/* + * Repository-local GIT_* environment variables; these will be cleared + * when git spawns a sub-process that runs inside another repository. + * The array is NULL-terminated, which makes it easy to pass in the "env" + * parameter of a run-command invocation, or to do a simple walk. */ -#define LOCAL_REPO_ENV_SIZE 9 -extern const char *const local_repo_env[LOCAL_REPO_ENV_SIZE + 1]; +extern const char * const local_repo_env[]; extern int is_bare_repository_cfg; extern int is_bare_repository(void); @@@ -1053,9 -1053,7 +1056,9 @@@ struct extra_have_objects int nr, alloc; unsigned char (*array)[20]; }; -extern struct ref **get_remote_heads(int in, struct ref **list, unsigned int flags, struct extra_have_objects *); +extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len, + struct ref **list, unsigned int flags, + struct extra_have_objects *); extern int server_supports(const char *feature); extern int parse_feature_request(const char *features, const char *feature); extern const char *server_feature_value(const char *feature, int *len_ret);