Remove unused object-ref code
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Koegler committed
Feb 25, 2008 at 22:46 UTC
7914053ba9901be1f1530f46e8e2e6ee6f4ae5b1
11 files changed
+1
-166
Makefile
+1
-1
@@ -312,7 +312,7 @@ LIB_OBJS = \
312
patch-ids.o \
313
object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
314
sideband.o reachable.o reflog-walk.o \
315
- quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
315
+ quote.o read-cache.o refs.o run-command.o dir.o \
316
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
317
tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
318
revision.o pager.o tree-walk.o xdiff-interface.o \
builtin-fetch-pack.c
-1
@@ -385,7 +385,6 @@ static int everything_local(struct ref **refs, int nr_match, char **match)
385
int retval;
386
unsigned long cutoff = 0;
387
388
- track_object_refs = 0;
388
save_commit_buffer = 0;
389
390
for (ref = *refs; ref; ref = ref->next) {
builtin-pack-objects.c
-1
@@ -2009,7 +2009,6 @@ static void get_object_list(int ac, const char **av)
2009
2010
init_revisions(&revs, NULL);
2011
save_commit_buffer = 0;
2012
- track_object_refs = 0;
2012
setup_revisions(ac, av, &revs, NULL);
2013
2014
while (fgets(line, sizeof(line), stdin) != NULL) {
builtin-rev-list.c
-1
@@ -605,7 +605,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
605
usage(rev_list_usage);
606
607
save_commit_buffer = revs.verbose_header || revs.grep_filter;
608
- track_object_refs = 0;
608
if (bisect_list)
609
revs.limited = 1;
610
commit.c
-11
@@ -290,17 +290,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
290
}
291
item->date = parse_commit_date(bufptr, tail);
292
293
- if (track_object_refs) {
294
- unsigned i = 0;
295
- struct commit_list *p;
296
- struct object_refs *refs = alloc_object_refs(n_refs);
297
- if (item->tree)
298
- refs->ref[i++] = &item->tree->object;
299
- for (p = item->parents; p; p = p->next)
300
- refs->ref[i++] = &p->item->object;
301
- set_object_refs(&item->object, refs);
302
- }
303
-
293
return 0;
294
}
295
object-refs.c
deleted
-87
@@ -1,87 +0,0 @@
1
-#include "cache.h"
2
-#include "object.h"
3
-#include "decorate.h"
4
-
5
-int track_object_refs = 0;
6
-
7
-static struct decoration ref_decorate;
8
-
9
-struct object_refs *lookup_object_refs(struct object *base)
10
-{
11
- return lookup_decoration(&ref_decorate, base);
12
-}
13
-
14
-static void add_object_refs(struct object *obj, struct object_refs *refs)
15
-{
16
- if (add_decoration(&ref_decorate, obj, refs))
17
- die("object %s tried to add refs twice!", sha1_to_hex(obj->sha1));
18
-}
19
-
20
-struct object_refs *alloc_object_refs(unsigned count)
21
-{
22
- struct object_refs *refs;
23
- size_t size = sizeof(*refs) + count*sizeof(struct object *);
24
-
25
- refs = xcalloc(1, size);
26
- refs->count = count;
27
- return refs;
28
-}
29
-
30
-static int compare_object_pointers(const void *a, const void *b)
31
-{
32
- const struct object * const *pa = a;
33
- const struct object * const *pb = b;
34
- if (*pa == *pb)
35
- return 0;
36
- else if (*pa < *pb)
37
- return -1;
38
- else
39
- return 1;
40
-}
41
-
42
-void set_object_refs(struct object *obj, struct object_refs *refs)
43
-{
44
- unsigned int i, j;
45
-
46
- /* Do not install empty list of references */
47
- if (refs->count < 1) {
48
- free(refs);
49
- return;
50
- }
51
-
52
- /* Sort the list and filter out duplicates */
53
- qsort(refs->ref, refs->count, sizeof(refs->ref[0]),
54
- compare_object_pointers);
55
- for (i = j = 1; i < refs->count; i++) {
56
- if (refs->ref[i] != refs->ref[i - 1])
57
- refs->ref[j++] = refs->ref[i];
58
- }
59
- if (j < refs->count) {
60
- /* Duplicates were found - reallocate list */
61
- size_t size = sizeof(*refs) + j*sizeof(struct object *);
62
- refs->count = j;
63
- refs = xrealloc(refs, size);
64
- }
65
-
66
- for (i = 0; i < refs->count; i++)
67
- refs->ref[i]->used = 1;
68
- add_object_refs(obj, refs);
69
-}
70
-
71
-void mark_reachable(struct object *obj, unsigned int mask)
72
-{
73
- const struct object_refs *refs;
74
-
75
- if (!track_object_refs)
76
- die("cannot do reachability with object refs turned off");
77
- /* If we've been here already, don't bother */
78
- if (obj->flags & mask)
79
- return;
80
- obj->flags |= mask;
81
- refs = lookup_object_refs(obj);
82
- if (refs) {
83
- unsigned i;
84
- for (i = 0; i < refs->count; i++)
85
- mark_reachable(refs->ref[i], mask);
86
- }
87
-}
object.h
-8
@@ -35,14 +35,11 @@ struct object {
35
unsigned char sha1[20];
36
};
37
38
-extern int track_object_refs;
39
-
38
extern const char *typename(unsigned int type);
39
extern int type_from_string(const char *str);
40
41
extern unsigned int get_max_object_index(void);
42
extern struct object *get_indexed_object(unsigned int);
45
-extern struct object_refs *lookup_object_refs(struct object *);
43
44
/** Internal only **/
45
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
58
/** Returns the object, with potentially excess memory allocated. **/
59
struct object *lookup_unknown_object(const unsigned char *sha1);
60
64
-struct object_refs *alloc_object_refs(unsigned count);
65
-void set_object_refs(struct object *obj, struct object_refs *refs);
66
-
67
-void mark_reachable(struct object *obj, unsigned int mask);
68
-
61
struct object_list *object_list_insert(struct object *item,
62
struct object_list **list_p);
63
tag.c
-6
@@ -84,12 +84,6 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
84
item->tagged = NULL;
85
}
86
87
- if (item->tagged && track_object_refs) {
88
- struct object_refs *refs = alloc_object_refs(1);
89
- refs->ref[0] = item->tagged;
90
- set_object_refs(&item->object, refs);
91
- }
92
-
87
return 0;
88
}
89
tree.c
-48
@@ -202,52 +202,6 @@ struct tree *lookup_tree(const unsigned char *sha1)
202
return (struct tree *) obj;
203
}
204
205
-/*
206
- * NOTE! Tree refs to external git repositories
207
- * (ie gitlinks) do not count as real references.
208
- *
209
- * You don't have to have those repositories
210
- * available at all, much less have the objects
211
- * accessible from the current repository.
212
- */
213
-static void track_tree_refs(struct tree *item)
214
-{
215
- int n_refs = 0, i;
216
- struct object_refs *refs;
217
- struct tree_desc desc;
218
- struct name_entry entry;
219
-
220
- /* Count how many entries there are.. */
221
- init_tree_desc(&desc, item->buffer, item->size);
222
- while (tree_entry(&desc, &entry)) {
223
- if (S_ISGITLINK(entry.mode))
224
- continue;
225
- n_refs++;
226
- }
227
-
228
- /* Allocate object refs and walk it again.. */
229
- i = 0;
230
- refs = alloc_object_refs(n_refs);
231
- init_tree_desc(&desc, item->buffer, item->size);
232
- while (tree_entry(&desc, &entry)) {
233
- struct object *obj;
234
-
235
- if (S_ISGITLINK(entry.mode))
236
- continue;
237
- if (S_ISDIR(entry.mode))
238
- obj = &lookup_tree(entry.sha1)->object;
239
- else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
240
- obj = &lookup_blob(entry.sha1)->object;
241
- else {
242
- warning("in tree %s: entry %s has bad mode %.6o\n",
243
- sha1_to_hex(item->object.sha1), entry.path, entry.mode);
244
- obj = lookup_unknown_object(entry.sha1);
245
- }
246
- refs->ref[i++] = obj;
247
- }
248
- set_object_refs(&item->object, refs);
249
-}
250
-
205
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
206
{
207
if (item->object.parsed)
@@ -256,8 +210,6 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
210
item->buffer = buffer;
211
item->size = size;
212
259
- if (track_object_refs)
260
- track_tree_refs(item);
213
return 0;
214
}
215
upload-pack.c
-1
@@ -392,7 +392,6 @@ static int get_common_commits(void)
392
char hex[41], last_hex[41];
393
int len;
394
395
- track_object_refs = 0;
395
save_commit_buffer = 0;
396
397
for(;;) {
walker.c
-1
@@ -256,7 +256,6 @@ int walker_fetch(struct walker *walker, int targets, char **target,
256
int i;
257
258
save_commit_buffer = 0;
259
- track_object_refs = 0;
259
260
for (i = 0; i < targets; i++) {
261
if (!write_ref || !write_ref[i])