cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch
By default, index compat macros are off from now on, because they could hide the_index dependency. Only those in builtin can use it. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									150fe065f7
								
							
						
					
					
						commit
						f8adbec9fe
					
				
							
								
								
									
										1
									
								
								attr.c
								
								
								
								
							
							
						
						
									
										1
									
								
								attr.c
								
								
								
								
							|  | @ -7,7 +7,6 @@ | |||
|  * an insanely large number of attributes. | ||||
|  */ | ||||
|  | ||||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "exec-cmd.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) 2006 Linus Torvalds | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "builtin.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Based on git-am.sh by Junio C Hamano. | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "builtin.h" | ||||
|  |  | |||
|  | @ -1007,7 +1007,8 @@ parse_done: | |||
| 		long bottom, top; | ||||
| 		if (parse_range_arg(range_list.items[range_i].string, | ||||
| 				    nth_line_cb, &sb, lno, anchor, | ||||
| 				    &bottom, &top, sb.path, &the_index)) | ||||
| 				    &bottom, &top, sb.path, | ||||
| 				    the_repository->index)) | ||||
| 			usage(blame_usage); | ||||
| 		if ((!lno && (top || bottom)) || lno < bottom) | ||||
| 			die(Q_("file %s has only %lu line", | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "builtin.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
|  * Copyright (C) 2005 Linus Torvalds | ||||
|  * | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "checkout.h" | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
|  * Based on git-clean.sh by Pavel Roskin | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
|  * Clone a repository into a different directory that does not yet exist. | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|  * Based on git-commit.sh by Junio C Hamano and Linus Torvalds | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "diff.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "diff.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "diff.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (c) 2006 Junio C Hamano | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ | |||
|  * | ||||
|  * Copyright (C) 2016 Johannes Schindelin | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "builtin.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "repository.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (c) 2006 Junio C Hamano | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "repository.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -40,7 +40,8 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags, | |||
| 	if (fstat(fd, &st) < 0 || | ||||
| 	    (literally | ||||
| 	     ? hash_literally(&oid, fd, type, flags) | ||||
| 	     : index_fd(&the_index, &oid, fd, &st, type_from_string(type), path, flags))) | ||||
| 	     : index_fd(the_repository->index, &oid, fd, &st, | ||||
| 			type_from_string(type), path, flags))) | ||||
| 		die((flags & HASH_WRITE_OBJECT) | ||||
| 		    ? "Unable to add %s to database" | ||||
| 		    : "Unable to hash %s", path); | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
|  * (C) Copyright 2006 Linus Torvalds | ||||
|  *		 2006 Junio Hamano | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "refs.h" | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "repository.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "run-command.h" | ||||
|  | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
|  * | ||||
|  * Pretend we resolved the heads, but declare our tree trumps everybody else. | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "git-compat-util.h" | ||||
| #include "builtin.h" | ||||
| #include "diff.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "tree-walk.h" | ||||
| #include "xdiff-interface.h" | ||||
|  | @ -76,7 +77,8 @@ static void *result(struct merge_list *entry, unsigned long *size) | |||
| 	their = NULL; | ||||
| 	if (entry) | ||||
| 		their = entry->blob; | ||||
| 	return merge_blobs(&the_index, path, base, our, their, size); | ||||
| 	return merge_blobs(the_repository->index, path, | ||||
| 			   base, our, their, size); | ||||
| } | ||||
|  | ||||
| static void *origin(struct merge_list *entry, unsigned long *size) | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
|  * Based on git-merge.sh by Junio C Hamano. | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "parse-options.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) 2006 Johannes Schindelin | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "pathspec.h" | ||||
|  |  | |||
|  | @ -970,7 +970,7 @@ static int no_try_delta(const char *path) | |||
|  | ||||
| 	if (!check) | ||||
| 		check = attr_check_initl("delta", NULL); | ||||
| 	git_check_attr(&the_index, path, check); | ||||
| 	git_check_attr(the_repository->index, path, check); | ||||
| 	if (ATTR_FALSE(check->items[0].value)) | ||||
| 		return 1; | ||||
| 	return 0; | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|  * | ||||
|  * Fetch one or more remote refs and merge it/them into the current HEAD. | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "builtin.h" | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
|  * Copyright (c) 2018 Pratik Karki | ||||
|  */ | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "run-command.h" | ||||
| #include "exec-cmd.h" | ||||
|  |  | |||
|  | @ -295,7 +295,7 @@ static int import_object(struct object_id *oid, enum object_type type, | |||
| 			close(fd); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (index_fd(&the_index, oid, fd, &st, type, NULL, flags) < 0) | ||||
| 		if (index_fd(the_repository->index, oid, fd, &st, type, NULL, flags) < 0) | ||||
| 			return error(_("unable to write object to database")); | ||||
| 		/* index_fd close()s fd for us */ | ||||
| 	} | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
|  * | ||||
|  * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "commit.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds 2006 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "repository.h" | ||||
| #include "cache.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "lockfile.h" | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "builtin.h" | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
|  |  | |||
|  | @ -51,7 +51,7 @@ void prime_cache_tree(struct repository *, struct index_state *, struct tree *); | |||
|  | ||||
| int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info); | ||||
|  | ||||
| #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix) | ||||
| { | ||||
| 	return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix); | ||||
|  |  | |||
							
								
								
									
										6
									
								
								cache.h
								
								
								
								
							
							
						
						
									
										6
									
								
								cache.h
								
								
								
								
							|  | @ -338,8 +338,6 @@ struct index_state { | |||
| 	struct mem_pool *ce_mem_pool; | ||||
| }; | ||||
|  | ||||
| extern struct index_state the_index; | ||||
|  | ||||
| /* Name hashing */ | ||||
| extern int test_lazy_init_name_hash(struct index_state *istate, int try_threaded); | ||||
| extern void add_name_hash(struct index_state *istate, struct cache_entry *ce); | ||||
|  | @ -401,7 +399,9 @@ struct cache_entry *dup_cache_entry(const struct cache_entry *ce, struct index_s | |||
|  */ | ||||
| void validate_cache_entries(const struct index_state *istate); | ||||
|  | ||||
| #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| extern struct index_state the_index; | ||||
|  | ||||
| #define active_cache (the_index.cache) | ||||
| #define active_nr (the_index.cache_nr) | ||||
| #define active_alloc (the_index.cache_alloc) | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "object-store.h" | ||||
|  |  | |||
							
								
								
									
										1
									
								
								dir.c
								
								
								
								
							
							
						
						
									
										1
									
								
								dir.c
								
								
								
								
							|  | @ -7,7 +7,6 @@ | |||
|  * Copyright (C) Linus Torvalds, 2005-2006 | ||||
|  *		 Junio Hamano, 2005-2006 | ||||
|  */ | ||||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "dir.h" | ||||
|  |  | |||
							
								
								
									
										4
									
								
								git.c
								
								
								
								
							
							
						
						
									
										4
									
								
								git.c
								
								
								
								
							|  | @ -417,9 +417,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
|  | ||||
| 	trace_argv_printf(argv, "trace: built-in: git"); | ||||
|  | ||||
| 	validate_cache_entries(&the_index); | ||||
| 	validate_cache_entries(the_repository->index); | ||||
| 	status = p->fn(argc, argv, prefix); | ||||
| 	validate_cache_entries(&the_index); | ||||
| 	validate_cache_entries(the_repository->index); | ||||
|  | ||||
| 	if (status) | ||||
| 		return status; | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
|  * | ||||
|  * Copyright (C) 2008 Linus Torvalds | ||||
|  */ | ||||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "thread-utils.h" | ||||
|  | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "dir.h" | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
|  * | ||||
|  * Copyright (C) Linus Torvalds, 2005 | ||||
|  */ | ||||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "config.h" | ||||
| #include "diff.h" | ||||
|  | @ -95,7 +94,6 @@ static struct mem_pool *find_mem_pool(struct index_state *istate) | |||
| 	return *pool_ptr; | ||||
| } | ||||
|  | ||||
| struct index_state the_index; | ||||
| static const char *alternate_index_output; | ||||
|  | ||||
| static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce) | ||||
|  |  | |||
|  | @ -1,3 +1,8 @@ | |||
| /* | ||||
|  * not really _using_ the compat macros, just make sure the_index | ||||
|  * declaration matches the definition in this file. | ||||
|  */ | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "repository.h" | ||||
| #include "object-store.h" | ||||
|  | @ -9,6 +14,7 @@ | |||
| /* The main repository */ | ||||
| static struct repository the_repo; | ||||
| struct repository *the_repository; | ||||
| struct index_state the_index; | ||||
|  | ||||
| void initialize_the_repository(void) | ||||
| { | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
|  | ||||
| #include "cache.h" | ||||
| #include "repository.h" | ||||
|  |  | |||
|  | @ -3,11 +3,11 @@ | |||
|  | ||||
| int cmd__dump_fsmonitor(int ac, const char **av) | ||||
| { | ||||
| 	struct index_state *istate = &the_index; | ||||
| 	struct index_state *istate = the_repository->index; | ||||
| 	int i; | ||||
|  | ||||
| 	setup_git_directory(); | ||||
| 	if (do_read_index(istate, get_index_file(), 0) < 0) | ||||
| 	if (do_read_index(istate, the_repository->index_file, 0) < 0) | ||||
| 		die("unable to read index file"); | ||||
| 	if (!istate->fsmonitor_last_update) { | ||||
| 		printf("no fsmonitor\n"); | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "test-tool.h" | ||||
| #include "cache.h" | ||||
| #include "dir.h" | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| #ifndef TEST_TOOL_H | ||||
| #define TEST_TOOL_H | ||||
|  | ||||
| #define USE_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "git-compat-util.h" | ||||
|  | ||||
| int cmd__chmtime(int argc, const char **argv); | ||||
|  |  | |||
							
								
								
									
										1
									
								
								tree.c
								
								
								
								
							
							
						
						
									
										1
									
								
								tree.c
								
								
								
								
							|  | @ -1,4 +1,3 @@ | |||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "cache-tree.h" | ||||
| #include "tree.h" | ||||
|  |  | |||
|  | @ -1,4 +1,3 @@ | |||
| #define NO_THE_INDEX_COMPATIBILITY_MACROS | ||||
| #include "cache.h" | ||||
| #include "argv-array.h" | ||||
| #include "repository.h" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Nguyễn Thái Ngọc Duy
						Nguyễn Thái Ngọc Duy