Skip to content

Commit

Permalink
Make "parse_object()" also fill in commit message buffer data.
Browse files Browse the repository at this point in the history
And teach fsck to free it to save memory.
  • Loading branch information
Linus Torvalds committed May 26, 2005
1 parent a6f68d4 commit bd1e17e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commit.h
Expand Up @@ -14,7 +14,7 @@ struct commit {
unsigned long date;
struct commit_list *parents;
struct tree *tree;
const char *buffer;
char *buffer;
};

extern const char *commit_type;
Expand Down
2 changes: 2 additions & 0 deletions fsck-cache.c
Expand Up @@ -203,6 +203,8 @@ static int fsck_tree(struct tree *item)

static int fsck_commit(struct commit *commit)
{
free(commit->buffer);
commit->buffer = NULL;
if (!commit->tree)
return -1;
if (!commit->parents && show_root)
Expand Down
4 changes: 4 additions & 0 deletions object.c
Expand Up @@ -129,6 +129,10 @@ struct object *parse_object(unsigned char *sha1)
} else if (!strcmp(type, "commit")) {
struct commit *commit = lookup_commit(sha1);
parse_commit_buffer(commit, buffer, size);
if (!commit->buffer) {
commit->buffer = buffer;
buffer = NULL;
}
obj = &commit->object;
} else if (!strcmp(type, "tag")) {
struct tag *tag = lookup_tag(sha1);
Expand Down

0 comments on commit bd1e17e

Please sign in to comment.