Skip to content

Commit

Permalink
Ooh. Make git-rev-list --object associate a name with objects.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Linus Torvalds committed Jun 26, 2005
1 parent 521a4f4 commit 9ce43d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions object.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
struct object_list {
struct object *item;
struct object_list *next;
const char *name;
};

struct object {
Expand Down
19 changes: 10 additions & 9 deletions rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,17 @@ static int process_commit(struct commit * commit)
return CONTINUE;
}

static struct object_list **add_object(struct object *obj, struct object_list **p)
static struct object_list **add_object(struct object *obj, struct object_list **p, const char *name)
{
struct object_list *entry = xmalloc(sizeof(*entry));
entry->item = obj;
entry->next = NULL;
entry->name = name;
*p = entry;
return &entry->next;
}

static struct object_list **process_blob(struct blob *blob, struct object_list **p)
static struct object_list **process_blob(struct blob *blob, struct object_list **p, const char *name)
{
struct object *obj = &blob->object;

Expand All @@ -116,10 +117,10 @@ static struct object_list **process_blob(struct blob *blob, struct object_list *
if (obj->flags & (UNINTERESTING | SEEN))
return p;
obj->flags |= SEEN;
return add_object(obj, p);
return add_object(obj, p, name);
}

static struct object_list **process_tree(struct tree *tree, struct object_list **p)
static struct object_list **process_tree(struct tree *tree, struct object_list **p, const char *name)
{
struct object *obj = &tree->object;
struct tree_entry_list *entry;
Expand All @@ -131,12 +132,12 @@ static struct object_list **process_tree(struct tree *tree, struct object_list *
if (parse_tree(tree) < 0)
die("bad tree object %s", sha1_to_hex(obj->sha1));
obj->flags |= SEEN;
p = add_object(obj, p);
p = add_object(obj, p, name);
for (entry = tree->entries ; entry ; entry = entry->next) {
if (entry->directory)
p = process_tree(entry->item.tree, p);
p = process_tree(entry->item.tree, p, entry->name);
else
p = process_blob(entry->item.blob, p);
p = process_blob(entry->item.blob, p, entry->name);
}
return p;
}
Expand All @@ -147,12 +148,12 @@ static void show_commit_list(struct commit_list *list)
while (list) {
struct commit *commit = pop_most_recent_commit(&list, SEEN);

p = process_tree(commit->tree, p);
p = process_tree(commit->tree, p, "");
if (process_commit(commit) == STOP)
break;
}
while (objects) {
puts(sha1_to_hex(objects->item->sha1));
printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
objects = objects->next;
}
}
Expand Down

0 comments on commit 9ce43d1

Please sign in to comment.