diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-26 15:26:05 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-26 15:26:05 -0700 |
commit | 9ce43d1c90dc199bf8ced85fa5fdadc152753022 (patch) | |
tree | 8f26a6eaea74c60b22896b4976533082998a5d84 /rev-list.c | |
parent | 521a4f4cf4bb2d59a51a5355bfb6b148c4aa31ed (diff) | |
download | git-9ce43d1c90dc199bf8ced85fa5fdadc152753022.tar.gz git-9ce43d1c90dc199bf8ced85fa5fdadc152753022.tar.xz |
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.
Diffstat (limited to 'rev-list.c')
-rw-r--r-- | rev-list.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/rev-list.c b/rev-list.c index 6b35b61ec..6a383f853 100644 --- a/rev-list.c +++ b/rev-list.c @@ -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; @@ -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; @@ -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; } @@ -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; } } |