Skip to contentSkip to conversation

rev-cache: misc features + slight refactor

PATCH In review Nick Edelen 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 rev-cache: misc features + slight refactor

Several miscellaneous features of rev-cache are introduced, and the non-commit object generation is refactored. Cache coagulation and index regeneration are added, allowing for cache slice maintenance and garbage collection. Commit and blob objects are modified to store object size, as the tree object does, and this parameter is instated upon parsing. Object enumeration makes use of this addition and more fluidly generates its list.

Tests for coagulation and index generation are added in the integration patch, as the former in its proper incarnation makes use of rev-cache's influence on the revision walker.

---
 blob.c              |    1 +
 blob.h              |    1 +
 builtin-rev-cache.c |   49 ++++++-
 commit.c            |    1 +
 commit.h            |    1 +
 rev-cache.c         |  415 ++++++++++++++++++++++++++++++++++++++++++---------
 revision.h          |    4 +-
 7 files changed, 397 insertions(+), 75 deletions(-)

Several miscellaneous features of rev-cache are introduced, and the non-commit object generation is refactored. Cache coagulation and index regeneration are added, allowing for cache slice maintenance and garbage collection. Commit and blob objects are modified to store object size, as the tree object does, and this parameter is instated upon parsing. Object enumeration makes use of this addition and more fluidly generates its list.

Tests for coagulation and index generation are added in the integration patch, as the former in its proper incarnation makes use of rev-cache's influence on the revision walker.

---
 blob.c              |    1 +
 blob.h              |    1 +
 builtin-rev-cache.c |   49 ++++++-
 commit.c            |    1 +
 commit.h            |    1 +
 rev-cache.c         |  415 ++++++++++++++++++++++++++++++++++++++++++---------
 revision.h          |    4 +-
 7 files changed, 397 insertions(+), 75 deletions(-)
blob.c +1 -0
index bd7d078..e1bab3f 100644
@@ -21,6 +21,7 @@ struct blob *lookup_blob(const unsigned char *sha1)
 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
 {
 	item->object.parsed = 1;
+	item->size = size;
 	return 0;
 }
 
blob.h +1 -0
index ea5d9e9..d8db96a 100644
@@ -7,6 +7,7 @@ extern const char *blob_type;
 
 struct blob {
 	struct object object;
+	unsigned long size;
 };
 
 struct blob *lookup_blob(const unsigned char *sha1);
builtin-rev-cache.c +48 -1

75 lines not on this page · raw message

commit.c +1 -0
index b45a991..d9778ba 100644
@@ -247,6 +247,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 	if (item->object.parsed)
 		return 0;
 	item->object.parsed = 1;
+	item->size = size;
 	tail += size;
 	if (tail <= bufptr + 46 || memcmp(bufptr, "tree ", 5) || bufptr[45] != '\n')
 		return error("bogus commit object %s", sha1_to_hex(item->object.sha1));
commit.h +1 -0
index ba9f638..0529fcf 100644
@@ -19,6 +19,7 @@ struct commit {
 	struct commit_list *parents;
 	struct tree *tree;
 	char *buffer;
+	unsigned long size;
 };
 
 extern int save_commit_buffer;
rev-cache.c +342 -73

588 lines not on this page · raw message

revision.h +3 -1
index e87f41d..5269602 100644
@@ -204,6 +204,8 @@ extern int make_cache_slice(struct rev_cache_info *rci,
 extern int make_cache_index(struct rev_cache_info *rci, unsigned char *cache_sha1, 
 	int fd, unsigned int size);
 
-extern void ends_from_slices(struct rev_info *revs, unsigned int flags);
+extern void ends_from_slices(struct rev_info *revs, unsigned int flags, unsigned char *which, int n);
+extern int coagulate_cache_slices(struct rev_cache_info *rci, struct rev_info *revs);
+extern int regenerate_cache_index(struct rev_cache_info *rci);
 
 #endif
Signature · 1 line
tg: (3e132f7..) t/revcache/misc (depends on: t/revcache/objects)