99
}
100
}
101
102
-static struct object_list **process_blob(struct blob *blob,
103
- struct object_list **p,
104
- struct name_path *path,
105
- const char *name)
102
+static void process_blob(struct blob *blob,
103
+ struct object_array *p,
104
+ struct name_path *path,
105
+ const char *name)
106
{
107
struct object *obj = &blob->object;
108
109
if (!revs.blob_objects)
110
- return p;
110
+ return;
111
if (obj->flags & (UNINTERESTING | SEEN))
112
- return p;
112
+ return;
113
obj->flags |= SEEN;
114
name = strdup(name);
115
- return add_object(obj, p, path, name);
115
+ add_object(obj, p, path, name);
116
}
117
118
-static struct object_list **process_tree(struct tree *tree,
119
- struct object_list **p,
120
- struct name_path *path,
121
- const char *name)
118
+static void process_tree(struct tree *tree,
119
+ struct object_array *p,
120
+ struct name_path *path,
121
+ const char *name)
122
{
123
struct object *obj = &tree->object;
124
struct tree_desc desc;
126
struct name_path me;
127
128
if (!revs.tree_objects)
129
- return p;
129
+ return;
130
if (obj->flags & (UNINTERESTING | SEEN))
131
- return p;
131
+ return;
132
if (parse_tree(tree) < 0)
133
die("bad tree object %s", sha1_to_hex(obj->sha1));
134
obj->flags |= SEEN;
135
name = strdup(name);
136
- p = add_object(obj, p, path, name);
136
+ add_object(obj, p, path, name);
137
me.up = path;
138
me.elem = name;
139
me.elem_len = strlen(name);
143
144
while (tree_entry(&desc, &entry)) {
145
if (S_ISDIR(entry.mode))
146
- p = process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
146
+ process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
147
else
148
- p = process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
148
+ process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
149
}
150
free(tree->buffer);
151
tree->buffer = NULL;
152
- return p;
152
}
153
154
static void show_commit_list(struct rev_info *revs)
155
{
156
+ int i;
157
struct commit *commit;
158
- struct object_list *objects = NULL, **p = &objects, *pending;
158
+ struct object_array objects = { 0, 0, NULL };
159
160
while ((commit = get_revision(revs)) != NULL) {
161
- p = process_tree(commit->tree, p, NULL, "");
161
+ process_tree(commit->tree, &objects, NULL, "");
162
show_commit(commit);
163
}
164
- for (pending = revs->pending_objects; pending; pending = pending->next) {
164
+ for (i = 0; i < revs->pending.nr; i++) {
165
+ struct object_array_entry *pending = revs->pending.objects + i;
166
struct object *obj = pending->item;
167
const char *name = pending->name;
168
if (obj->flags & (UNINTERESTING | SEEN))
169
continue;
170
if (obj->type == TYPE_TAG) {
171
obj->flags |= SEEN;
171
- p = add_object(obj, p, NULL, name);
172
+ add_object_array(obj, name, &objects);
173
continue;
174
}
175
if (obj->type == TYPE_TREE) {
175
- p = process_tree((struct tree *)obj, p, NULL, name);
176
+ process_tree((struct tree *)obj, &objects, NULL, name);
177
continue;
178
}
179
if (obj->type == TYPE_BLOB) {
179
- p = process_blob((struct blob *)obj, p, NULL, name);
180
+ process_blob((struct blob *)obj, &objects, NULL, name);
181
continue;
182
}
183
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
184
}
184
- while (objects) {
185
+ for (i = 0; i < objects.nr; i++) {
186
+ struct object_array_entry *p = objects.objects + i;
187
+
188
/* An object with name "foo\n0000000..." can be used to
189
* confuse downstream git-pack-objects very badly.
190
*/
188
- const char *ep = strchr(objects->name, '\n');
191
+ const char *ep = strchr(p->name, '\n');
192
if (ep) {
190
- printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
191
- (int) (ep - objects->name),
192
- objects->name);
193
+ printf("%s %.*s\n", sha1_to_hex(p->item->sha1),
194
+ (int) (ep - p->name),
195
+ p->name);
196
}
197
else
195
- printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
196
- objects = objects->next;
198
+ printf("%s %s\n", sha1_to_hex(p->item->sha1), p->name);
199
}
200
}
201
350
351
if ((!list &&
352
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
351
- !revs.pending_objects)) ||
353
+ !revs.pending.nr)) ||
354
revs.diff)
355
usage(rev_list_usage);
356