git/rev-list.c
Linus Torvalds 3c249c9506 Add "get_sha1()" helper function.
This allows the programs to use various simplified versions of
the SHA1 names, eg just say "HEAD" for the SHA1 pointed to by
the .git/HEAD file etc.

For example, this commit has been done with

	git-commit-tree $(git-write-tree) -p HEAD

instead of the traditional "$(cat .git/HEAD)" syntax.
2005-05-01 16:36:56 -07:00

24 lines
523 B
C

#include "cache.h"
#include "commit.h"
int main(int argc, char **argv)
{
unsigned char sha1[20];
struct commit_list *list = NULL;
struct commit *commit;
if (argc != 2 || get_sha1(argv[1], sha1))
usage("rev-list <commit-id>");
commit = lookup_commit(sha1);
if (!commit || parse_commit(commit) < 0)
die("bad commit object");
commit_list_insert(commit, &list);
do {
struct commit *commit = pop_most_recent_commit(&list, 0x1);
printf("%s\n", sha1_to_hex(commit->object.sha1));
} while (list);
return 0;
}