Skip to content

Commit 9ce43d1

Browse files
author
Linus Torvalds
committed
Ooh. Make git-rev-list --object associate a name with objects.
The name isn't unique, it's just the first name that object is reached through, so it's really nothing more than a hint.
1 parent 521a4f4 commit 9ce43d1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
struct object_list {
55
struct object *item;
66
struct object_list *next;
7+
const char *name;
78
};
89

910
struct object {

rev-list.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ static int process_commit(struct commit * commit)
9898
return CONTINUE;
9999
}
100100

101-
static struct object_list **add_object(struct object *obj, struct object_list **p)
101+
static struct object_list **add_object(struct object *obj, struct object_list **p, const char *name)
102102
{
103103
struct object_list *entry = xmalloc(sizeof(*entry));
104104
entry->item = obj;
105105
entry->next = NULL;
106+
entry->name = name;
106107
*p = entry;
107108
return &entry->next;
108109
}
109110

110-
static struct object_list **process_blob(struct blob *blob, struct object_list **p)
111+
static struct object_list **process_blob(struct blob *blob, struct object_list **p, const char *name)
111112
{
112113
struct object *obj = &blob->object;
113114

@@ -116,10 +117,10 @@ static struct object_list **process_blob(struct blob *blob, struct object_list *
116117
if (obj->flags & (UNINTERESTING | SEEN))
117118
return p;
118119
obj->flags |= SEEN;
119-
return add_object(obj, p);
120+
return add_object(obj, p, name);
120121
}
121122

122-
static struct object_list **process_tree(struct tree *tree, struct object_list **p)
123+
static struct object_list **process_tree(struct tree *tree, struct object_list **p, const char *name)
123124
{
124125
struct object *obj = &tree->object;
125126
struct tree_entry_list *entry;
@@ -131,12 +132,12 @@ static struct object_list **process_tree(struct tree *tree, struct object_list *
131132
if (parse_tree(tree) < 0)
132133
die("bad tree object %s", sha1_to_hex(obj->sha1));
133134
obj->flags |= SEEN;
134-
p = add_object(obj, p);
135+
p = add_object(obj, p, name);
135136
for (entry = tree->entries ; entry ; entry = entry->next) {
136137
if (entry->directory)
137-
p = process_tree(entry->item.tree, p);
138+
p = process_tree(entry->item.tree, p, entry->name);
138139
else
139-
p = process_blob(entry->item.blob, p);
140+
p = process_blob(entry->item.blob, p, entry->name);
140141
}
141142
return p;
142143
}
@@ -147,12 +148,12 @@ static void show_commit_list(struct commit_list *list)
147148
while (list) {
148149
struct commit *commit = pop_most_recent_commit(&list, SEEN);
149150

150-
p = process_tree(commit->tree, p);
151+
p = process_tree(commit->tree, p, "");
151152
if (process_commit(commit) == STOP)
152153
break;
153154
}
154155
while (objects) {
155-
puts(sha1_to_hex(objects->item->sha1));
156+
printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
156157
objects = objects->next;
157158
}
158159
}

0 commit comments

Comments
 (0)