1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 01:46:14 +02:00

Make "parse_object()" also fill in commit message buffer data.

And teach fsck to free it to save memory.
This commit is contained in:
Linus Torvalds 2005-05-25 19:26:28 -07:00
parent a6f68d4767
commit bd1e17e245
3 changed files with 7 additions and 1 deletions

View File

@ -14,7 +14,7 @@ struct commit {
unsigned long date; unsigned long date;
struct commit_list *parents; struct commit_list *parents;
struct tree *tree; struct tree *tree;
const char *buffer; char *buffer;
}; };
extern const char *commit_type; extern const char *commit_type;

View File

@ -203,6 +203,8 @@ static int fsck_tree(struct tree *item)
static int fsck_commit(struct commit *commit) static int fsck_commit(struct commit *commit)
{ {
free(commit->buffer);
commit->buffer = NULL;
if (!commit->tree) if (!commit->tree)
return -1; return -1;
if (!commit->parents && show_root) if (!commit->parents && show_root)

View File

@ -129,6 +129,10 @@ struct object *parse_object(unsigned char *sha1)
} else if (!strcmp(type, "commit")) { } else if (!strcmp(type, "commit")) {
struct commit *commit = lookup_commit(sha1); struct commit *commit = lookup_commit(sha1);
parse_commit_buffer(commit, buffer, size); parse_commit_buffer(commit, buffer, size);
if (!commit->buffer) {
commit->buffer = buffer;
buffer = NULL;
}
obj = &commit->object; obj = &commit->object;
} else if (!strcmp(type, "tag")) { } else if (!strcmp(type, "tag")) {
struct tag *tag = lookup_tag(sha1); struct tag *tag = lookup_tag(sha1);