Remove unused object-ref code
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									271b8d25b2
								
							
						
					
					
						commit
						7914053ba9
					
				
							
								
								
									
										2
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										2
									
								
								Makefile
								
								
								
								
							|  | @ -312,7 +312,7 @@ LIB_OBJS = \ | ||||||
| 	patch-ids.o \ | 	patch-ids.o \ | ||||||
| 	object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \ | 	object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \ | ||||||
| 	sideband.o reachable.o reflog-walk.o \ | 	sideband.o reachable.o reflog-walk.o \ | ||||||
| 	quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \ | 	quote.o read-cache.o refs.o run-command.o dir.o \ | ||||||
| 	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \ | 	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \ | ||||||
| 	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \ | 	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \ | ||||||
| 	revision.o pager.o tree-walk.o xdiff-interface.o \ | 	revision.o pager.o tree-walk.o xdiff-interface.o \ | ||||||
|  |  | ||||||
|  | @ -385,7 +385,6 @@ static int everything_local(struct ref **refs, int nr_match, char **match) | ||||||
| 	int retval; | 	int retval; | ||||||
| 	unsigned long cutoff = 0; | 	unsigned long cutoff = 0; | ||||||
|  |  | ||||||
| 	track_object_refs = 0; |  | ||||||
| 	save_commit_buffer = 0; | 	save_commit_buffer = 0; | ||||||
|  |  | ||||||
| 	for (ref = *refs; ref; ref = ref->next) { | 	for (ref = *refs; ref; ref = ref->next) { | ||||||
|  |  | ||||||
|  | @ -2009,7 +2009,6 @@ static void get_object_list(int ac, const char **av) | ||||||
|  |  | ||||||
| 	init_revisions(&revs, NULL); | 	init_revisions(&revs, NULL); | ||||||
| 	save_commit_buffer = 0; | 	save_commit_buffer = 0; | ||||||
| 	track_object_refs = 0; |  | ||||||
| 	setup_revisions(ac, av, &revs, NULL); | 	setup_revisions(ac, av, &revs, NULL); | ||||||
|  |  | ||||||
| 	while (fgets(line, sizeof(line), stdin) != NULL) { | 	while (fgets(line, sizeof(line), stdin) != NULL) { | ||||||
|  |  | ||||||
|  | @ -605,7 +605,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) | ||||||
| 		usage(rev_list_usage); | 		usage(rev_list_usage); | ||||||
|  |  | ||||||
| 	save_commit_buffer = revs.verbose_header || revs.grep_filter; | 	save_commit_buffer = revs.verbose_header || revs.grep_filter; | ||||||
| 	track_object_refs = 0; |  | ||||||
| 	if (bisect_list) | 	if (bisect_list) | ||||||
| 		revs.limited = 1; | 		revs.limited = 1; | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								commit.c
								
								
								
								
							
							
						
						
									
										11
									
								
								commit.c
								
								
								
								
							|  | @ -290,17 +290,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size) | ||||||
| 	} | 	} | ||||||
| 	item->date = parse_commit_date(bufptr, tail); | 	item->date = parse_commit_date(bufptr, tail); | ||||||
|  |  | ||||||
| 	if (track_object_refs) { |  | ||||||
| 		unsigned i = 0; |  | ||||||
| 		struct commit_list *p; |  | ||||||
| 		struct object_refs *refs = alloc_object_refs(n_refs); |  | ||||||
| 		if (item->tree) |  | ||||||
| 			refs->ref[i++] = &item->tree->object; |  | ||||||
| 		for (p = item->parents; p; p = p->next) |  | ||||||
| 			refs->ref[i++] = &p->item->object; |  | ||||||
| 		set_object_refs(&item->object, refs); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -1,87 +0,0 @@ | ||||||
| #include "cache.h" |  | ||||||
| #include "object.h" |  | ||||||
| #include "decorate.h" |  | ||||||
|  |  | ||||||
| int track_object_refs = 0; |  | ||||||
|  |  | ||||||
| static struct decoration ref_decorate; |  | ||||||
|  |  | ||||||
| struct object_refs *lookup_object_refs(struct object *base) |  | ||||||
| { |  | ||||||
| 	return lookup_decoration(&ref_decorate, base); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static void add_object_refs(struct object *obj, struct object_refs *refs) |  | ||||||
| { |  | ||||||
| 	if (add_decoration(&ref_decorate, obj, refs)) |  | ||||||
| 		die("object %s tried to add refs twice!", sha1_to_hex(obj->sha1)); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| struct object_refs *alloc_object_refs(unsigned count) |  | ||||||
| { |  | ||||||
| 	struct object_refs *refs; |  | ||||||
| 	size_t size = sizeof(*refs) + count*sizeof(struct object *); |  | ||||||
|  |  | ||||||
| 	refs = xcalloc(1, size); |  | ||||||
| 	refs->count = count; |  | ||||||
| 	return refs; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static int compare_object_pointers(const void *a, const void *b) |  | ||||||
| { |  | ||||||
| 	const struct object * const *pa = a; |  | ||||||
| 	const struct object * const *pb = b; |  | ||||||
| 	if (*pa == *pb) |  | ||||||
| 		return 0; |  | ||||||
| 	else if (*pa < *pb) |  | ||||||
| 		return -1; |  | ||||||
| 	else |  | ||||||
| 		return 1; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void set_object_refs(struct object *obj, struct object_refs *refs) |  | ||||||
| { |  | ||||||
| 	unsigned int i, j; |  | ||||||
|  |  | ||||||
| 	/* Do not install empty list of references */ |  | ||||||
| 	if (refs->count < 1) { |  | ||||||
| 		free(refs); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/* Sort the list and filter out duplicates */ |  | ||||||
| 	qsort(refs->ref, refs->count, sizeof(refs->ref[0]), |  | ||||||
| 	      compare_object_pointers); |  | ||||||
| 	for (i = j = 1; i < refs->count; i++) { |  | ||||||
| 		if (refs->ref[i] != refs->ref[i - 1]) |  | ||||||
| 			refs->ref[j++] = refs->ref[i]; |  | ||||||
| 	} |  | ||||||
| 	if (j < refs->count) { |  | ||||||
| 		/* Duplicates were found - reallocate list */ |  | ||||||
| 		size_t size = sizeof(*refs) + j*sizeof(struct object *); |  | ||||||
| 		refs->count = j; |  | ||||||
| 		refs = xrealloc(refs, size); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	for (i = 0; i < refs->count; i++) |  | ||||||
| 		refs->ref[i]->used = 1; |  | ||||||
| 	add_object_refs(obj, refs); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void mark_reachable(struct object *obj, unsigned int mask) |  | ||||||
| { |  | ||||||
| 	const struct object_refs *refs; |  | ||||||
|  |  | ||||||
| 	if (!track_object_refs) |  | ||||||
| 		die("cannot do reachability with object refs turned off"); |  | ||||||
| 	/* If we've been here already, don't bother */ |  | ||||||
| 	if (obj->flags & mask) |  | ||||||
| 		return; |  | ||||||
| 	obj->flags |= mask; |  | ||||||
| 	refs = lookup_object_refs(obj); |  | ||||||
| 	if (refs) { |  | ||||||
| 		unsigned i; |  | ||||||
| 		for (i = 0; i < refs->count; i++) |  | ||||||
| 			mark_reachable(refs->ref[i], mask); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
							
								
								
									
										8
									
								
								object.h
								
								
								
								
							
							
						
						
									
										8
									
								
								object.h
								
								
								
								
							|  | @ -35,14 +35,11 @@ struct object { | ||||||
| 	unsigned char sha1[20]; | 	unsigned char sha1[20]; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| extern int track_object_refs; |  | ||||||
|  |  | ||||||
| extern const char *typename(unsigned int type); | extern const char *typename(unsigned int type); | ||||||
| extern int type_from_string(const char *str); | extern int type_from_string(const char *str); | ||||||
|  |  | ||||||
| extern unsigned int get_max_object_index(void); | extern unsigned int get_max_object_index(void); | ||||||
| extern struct object *get_indexed_object(unsigned int); | extern struct object *get_indexed_object(unsigned int); | ||||||
| extern struct object_refs *lookup_object_refs(struct object *); |  | ||||||
|  |  | ||||||
| /** Internal only **/ | /** Internal only **/ | ||||||
| struct object *lookup_object(const unsigned char *sha1); | struct object *lookup_object(const unsigned char *sha1); | ||||||
|  | @ -61,11 +58,6 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t | ||||||
| /** Returns the object, with potentially excess memory allocated. **/ | /** Returns the object, with potentially excess memory allocated. **/ | ||||||
| struct object *lookup_unknown_object(const unsigned  char *sha1); | struct object *lookup_unknown_object(const unsigned  char *sha1); | ||||||
|  |  | ||||||
| struct object_refs *alloc_object_refs(unsigned count); |  | ||||||
| void set_object_refs(struct object *obj, struct object_refs *refs); |  | ||||||
|  |  | ||||||
| void mark_reachable(struct object *obj, unsigned int mask); |  | ||||||
|  |  | ||||||
| struct object_list *object_list_insert(struct object *item, | struct object_list *object_list_insert(struct object *item, | ||||||
| 				       struct object_list **list_p); | 				       struct object_list **list_p); | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										6
									
								
								tag.c
								
								
								
								
							
							
						
						
									
										6
									
								
								tag.c
								
								
								
								
							|  | @ -84,12 +84,6 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size) | ||||||
| 		item->tagged = NULL; | 		item->tagged = NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (item->tagged && track_object_refs) { |  | ||||||
| 		struct object_refs *refs = alloc_object_refs(1); |  | ||||||
| 		refs->ref[0] = item->tagged; |  | ||||||
| 		set_object_refs(&item->object, refs); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										48
									
								
								tree.c
								
								
								
								
							
							
						
						
									
										48
									
								
								tree.c
								
								
								
								
							|  | @ -202,52 +202,6 @@ struct tree *lookup_tree(const unsigned char *sha1) | ||||||
| 	return (struct tree *) obj; | 	return (struct tree *) obj; | ||||||
| } | } | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * NOTE! Tree refs to external git repositories |  | ||||||
|  * (ie gitlinks) do not count as real references. |  | ||||||
|  * |  | ||||||
|  * You don't have to have those repositories |  | ||||||
|  * available at all, much less have the objects |  | ||||||
|  * accessible from the current repository. |  | ||||||
|  */ |  | ||||||
| static void track_tree_refs(struct tree *item) |  | ||||||
| { |  | ||||||
| 	int n_refs = 0, i; |  | ||||||
| 	struct object_refs *refs; |  | ||||||
| 	struct tree_desc desc; |  | ||||||
| 	struct name_entry entry; |  | ||||||
|  |  | ||||||
| 	/* Count how many entries there are.. */ |  | ||||||
| 	init_tree_desc(&desc, item->buffer, item->size); |  | ||||||
| 	while (tree_entry(&desc, &entry)) { |  | ||||||
| 		if (S_ISGITLINK(entry.mode)) |  | ||||||
| 			continue; |  | ||||||
| 		n_refs++; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/* Allocate object refs and walk it again.. */ |  | ||||||
| 	i = 0; |  | ||||||
| 	refs = alloc_object_refs(n_refs); |  | ||||||
| 	init_tree_desc(&desc, item->buffer, item->size); |  | ||||||
| 	while (tree_entry(&desc, &entry)) { |  | ||||||
| 		struct object *obj; |  | ||||||
|  |  | ||||||
| 		if (S_ISGITLINK(entry.mode)) |  | ||||||
| 			continue; |  | ||||||
| 		if (S_ISDIR(entry.mode)) |  | ||||||
| 			obj = &lookup_tree(entry.sha1)->object; |  | ||||||
| 		else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) |  | ||||||
| 			obj = &lookup_blob(entry.sha1)->object; |  | ||||||
| 		else { |  | ||||||
| 			warning("in tree %s: entry %s has bad mode %.6o\n", |  | ||||||
| 			     sha1_to_hex(item->object.sha1), entry.path, entry.mode); |  | ||||||
| 			obj = lookup_unknown_object(entry.sha1); |  | ||||||
| 		} |  | ||||||
| 		refs->ref[i++] = obj; |  | ||||||
| 	} |  | ||||||
| 	set_object_refs(&item->object, refs); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size) | int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size) | ||||||
| { | { | ||||||
| 	if (item->object.parsed) | 	if (item->object.parsed) | ||||||
|  | @ -256,8 +210,6 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size) | ||||||
| 	item->buffer = buffer; | 	item->buffer = buffer; | ||||||
| 	item->size = size; | 	item->size = size; | ||||||
|  |  | ||||||
| 	if (track_object_refs) |  | ||||||
| 		track_tree_refs(item); |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -392,7 +392,6 @@ static int get_common_commits(void) | ||||||
| 	char hex[41], last_hex[41]; | 	char hex[41], last_hex[41]; | ||||||
| 	int len; | 	int len; | ||||||
|  |  | ||||||
| 	track_object_refs = 0; |  | ||||||
| 	save_commit_buffer = 0; | 	save_commit_buffer = 0; | ||||||
|  |  | ||||||
| 	for(;;) { | 	for(;;) { | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								walker.c
								
								
								
								
							
							
						
						
									
										1
									
								
								walker.c
								
								
								
								
							|  | @ -256,7 +256,6 @@ int walker_fetch(struct walker *walker, int targets, char **target, | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
| 	save_commit_buffer = 0; | 	save_commit_buffer = 0; | ||||||
| 	track_object_refs = 0; |  | ||||||
|  |  | ||||||
| 	for (i = 0; i < targets; i++) { | 	for (i = 0; i < targets; i++) { | ||||||
| 		if (!write_ref || !write_ref[i]) | 		if (!write_ref || !write_ref[i]) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Martin Koegler
						Martin Koegler