Code

Remove unused object-ref code
authorMartin Koegler <mkoegler@auto.tuwien.ac.at>
Mon, 25 Feb 2008 21:46:06 +0000 (22:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Feb 2008 07:57:35 +0000 (23:57 -0800)
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
builtin-fetch-pack.c
builtin-pack-objects.c
builtin-rev-list.c
commit.c
object-refs.c [deleted file]
object.h
tag.c
tree.c
upload-pack.c
walker.c

index 33c367dfb1c92723b7e1d099398ab11e90b646ed..8ff0c772f1f21e230f08175c2aff704b507e64b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -312,7 +312,7 @@ LIB_OBJS = \
        patch-ids.o \
        object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.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 \
        tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
        revision.o pager.o tree-walk.o xdiff-interface.o \
index e68e01592d044a2c2570f096668856eef5caa1a2..410414d91fc5249a2152600f5a7fb5d90745942d 100644 (file)
@@ -385,7 +385,6 @@ static int everything_local(struct ref **refs, int nr_match, char **match)
        int retval;
        unsigned long cutoff = 0;
 
-       track_object_refs = 0;
        save_commit_buffer = 0;
 
        for (ref = *refs; ref; ref = ref->next) {
index d3efeff03f89cc0f4d0da463ddf878c28effb31e..6f8f388bdfbab6728f843802bd4e685510b1184c 100644 (file)
@@ -2009,7 +2009,6 @@ static void get_object_list(int ac, const char **av)
 
        init_revisions(&revs, NULL);
        save_commit_buffer = 0;
-       track_object_refs = 0;
        setup_revisions(ac, av, &revs, NULL);
 
        while (fgets(line, sizeof(line), stdin) != NULL) {
index de80158fd4762aa692193edb7c0f8e85e6189877..14e86ceabc954eb979d56ef67eaccb6e47e56dbe 100644 (file)
@@ -605,7 +605,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                usage(rev_list_usage);
 
        save_commit_buffer = revs.verbose_header || revs.grep_filter;
-       track_object_refs = 0;
        if (bisect_list)
                revs.limited = 1;
 
index 22ce7768639465f896e52b08a73cf5605940700b..6684c4e73113f50f046c6541af8f2142751dea5b 100644 (file)
--- a/commit.c
+++ b/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);
 
-       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;
 }
 
diff --git a/object-refs.c b/object-refs.c
deleted file mode 100644 (file)
index 5345671..0000000
+++ /dev/null
@@ -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);
-       }
-}
index 397bbfa090cd281214013c42a5f0b1de6063a861..036bd66fe9b6591e959e6df51160e636ab1a682e 100644 (file)
--- a/object.h
+++ b/object.h
@@ -35,14 +35,11 @@ struct object {
        unsigned char sha1[20];
 };
 
-extern int track_object_refs;
-
 extern const char *typename(unsigned int type);
 extern int type_from_string(const char *str);
 
 extern unsigned int get_max_object_index(void);
 extern struct object *get_indexed_object(unsigned int);
-extern struct object_refs *lookup_object_refs(struct object *);
 
 /** Internal only **/
 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. **/
 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 **list_p);
 
diff --git a/tag.c b/tag.c
index 38bf9134f97c18973fe189c8703438f5e1135e49..d19f56d60cb166600f9fe906a213f20a04afe22e 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -84,12 +84,6 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
                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;
 }
 
diff --git a/tree.c b/tree.c
index 8c0819fa721771f6dc2e727860345376edb3ea60..113e1bb0a4778f68779b010c00c26322b26db254 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -202,52 +202,6 @@ struct tree *lookup_tree(const unsigned char *sha1)
        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)
 {
        if (item->object.parsed)
@@ -256,8 +210,6 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
        item->buffer = buffer;
        item->size = size;
 
-       if (track_object_refs)
-               track_tree_refs(item);
        return 0;
 }
 
index d1d2c2a1f77a53417e7bebcd71bffe5b1588f8f3..ba9ba599768330838ff2f09887d93d70035bf5ca 100644 (file)
@@ -392,7 +392,6 @@ static int get_common_commits(void)
        char hex[41], last_hex[41];
        int len;
 
-       track_object_refs = 0;
        save_commit_buffer = 0;
 
        for(;;) {
index adc3e80ce14ab60b585e295d029261f5b53acb51..c10eca88261eed6b0e5c3fc2fdc19b8332c4ac6b 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -256,7 +256,6 @@ int walker_fetch(struct walker *walker, int targets, char **target,
        int i;
 
        save_commit_buffer = 0;
-       track_object_refs = 0;
 
        for (i = 0; i < targets; i++) {
                if (!write_ref || !write_ref[i])