Make "parse_object()" also fill in commit message buffer data.
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 26 May 2005 02:26:28 +0000 (19:26 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 26 May 2005 02:26:28 +0000 (19:26 -0700)
And teach fsck to free it to save memory.

commit.h
fsck-cache.c
object.c

index 0bb8779..f7a2cb8 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -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;
index 6ac122b..4050c17 100644 (file)
@@ -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)
index d093e17..5e72a78 100644 (file)
--- a/object.c
+++ b/object.c
@@ -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);