Skip to content

Commit 1be111d

Browse files
peffgitster
authored andcommitted
reachable: use revision machinery's --indexed-objects code
This does the same thing as our custom code, so let's not repeat ourselves. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4fe1021 commit 1be111d

File tree

1 file changed

+1
-51
lines changed

1 file changed

+1
-51
lines changed

reachable.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,56 +32,6 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
3232
return 0;
3333
}
3434

35-
static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
36-
{
37-
struct tree *tree = lookup_tree(sha1);
38-
if (tree)
39-
add_pending_object(revs, &tree->object, "");
40-
}
41-
42-
static void add_cache_tree(struct cache_tree *it, struct rev_info *revs)
43-
{
44-
int i;
45-
46-
if (it->entry_count >= 0)
47-
add_one_tree(it->sha1, revs);
48-
for (i = 0; i < it->subtree_nr; i++)
49-
add_cache_tree(it->down[i]->cache_tree, revs);
50-
}
51-
52-
static void add_cache_refs(struct rev_info *revs)
53-
{
54-
int i;
55-
56-
read_cache();
57-
for (i = 0; i < active_nr; i++) {
58-
struct blob *blob;
59-
60-
/*
61-
* The index can contain blobs and GITLINKs, GITLINKs are hashes
62-
* that don't actually point to objects in the repository, it's
63-
* almost guaranteed that they are NOT blobs, so we don't call
64-
* lookup_blob() on them, to avoid populating the hash table
65-
* with invalid information
66-
*/
67-
if (S_ISGITLINK(active_cache[i]->ce_mode))
68-
continue;
69-
70-
blob = lookup_blob(active_cache[i]->sha1);
71-
if (blob)
72-
blob->object.flags |= SEEN;
73-
74-
/*
75-
* We could add the blobs to the pending list, but quite
76-
* frankly, we don't care. Once we've looked them up, and
77-
* added them as objects, we've really done everything
78-
* there is to do for a blob
79-
*/
80-
}
81-
if (active_cache_tree)
82-
add_cache_tree(active_cache_tree, revs);
83-
}
84-
8535
/*
8636
* The traversal will have already marked us as SEEN, so we
8737
* only need to handle any progress reporting here.
@@ -213,7 +163,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
213163
revs->tree_objects = 1;
214164

215165
/* Add all refs from the index file */
216-
add_cache_refs(revs);
166+
add_index_objects_to_pending(revs, 0);
217167

218168
/* Add all external refs */
219169
for_each_ref(add_one_ref, revs);

0 commit comments

Comments
 (0)