Skip to content

Commit

Permalink
Make "fsck-cache" print out all the root commits it finds.
Browse files Browse the repository at this point in the history
Once I do the reference tracking, I'll also make it print out all the
HEAD commits it finds, which is even more interesting.
  • Loading branch information
Linus Torvalds committed Apr 9, 2005
1 parent 9174026 commit 16d4d1b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fsck-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static int fsck_tree(unsigned char *sha1, void *data, unsigned long size)

static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
{
int parents;
unsigned char tree_sha1[20];
unsigned char parent_sha1[20];

Expand All @@ -44,12 +45,16 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
return -1;
mark_needs_sha1(sha1, "tree", tree_sha1);
data += 5 + 40 + 1; /* "tree " + <hex sha1> + '\n' */
parents = 0;
while (!memcmp(data, "parent ", 7)) {
if (get_sha1_hex(data + 7, parent_sha1) < 0)
return -1;
mark_needs_sha1(sha1, "commit", parent_sha1);
data += 7 + 40 + 1; /* "parent " + <hex sha1> + '\n' */
parents++;
}
if (!parents)
printf("root: %s\n", sha1_to_hex(sha1));
return 0;
}

Expand Down

0 comments on commit 16d4d1b

Please sign in to comment.