Skip to contentSkip to conversation

basic revision cache system, no integration or features

PATCH In review Nick Edelen 3 participants 9 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 2/6 basic revision cache system, no integration or features

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
 Makefile                  |    2 +
 builtin-rev-cache.c       |  206 ++++++++
 builtin.h                 |    1 +
 commit.c                  |    2 +
 git.c                     |    1 +
 rev-cache.c               | 1169 +++++++++++++++++++++++++++++++++++++++++++++
 rev-cache.h               |  107 ++++
 revision.c                |    2 +-
 revision.h                |   26 +-
 t/t6015-rev-cache-list.sh |  104 ++++
 10 files changed, 1618 insertions(+), 2 deletions(-)
Makefile +2 -0
index e6df8ec..1ceb514 100644
@@ -537,6 +537,7 @@ LIB_OBJS += reflog-walk.o
 LIB_OBJS += refs.o
 LIB_OBJS += remote.o
 LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
 LIB_OBJS += revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += server-info.o
@@ -627,6 +628,7 @@ BUILTIN_OBJS += builtin-reflog.o
 BUILTIN_OBJS += builtin-remote.o
 BUILTIN_OBJS += builtin-rerere.o
 BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-cache.o
 BUILTIN_OBJS += builtin-rev-list.o
 BUILTIN_OBJS += builtin-rev-parse.o
 BUILTIN_OBJS += builtin-revert.o
builtin-rev-cache.c new file +206 -0

206 lines not on this page · raw message

builtin.h +1 -0
index 20427d2..00ecc9c 100644
@@ -87,6 +87,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);
 extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_rerere(int argc, const char **argv, const char *prefix);
 extern int cmd_reset(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
 extern int cmd_revert(int argc, const char **argv, const char *prefix);
commit.c +2 -0
index e2bcbe8..682e7a7 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 	item->tree = lookup_tree(parent);
 	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
 	pptr = &item->parents;
+	while (pop_commit(pptr))
+		; /* clear anything from cache */
 
 	graft = lookup_commit_graft(item->object.sha1);
 	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +1 -0
index 4588a8b..7105c74 100644
@@ -342,6 +342,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "repo-config", cmd_config },
 		{ "rerere", cmd_rerere, RUN_SETUP },
 		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse },
 		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1169 -0

1,169 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +1 -1
index 9f5dac5..485bf72 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	commit->object.flags |= TREESAME;
 }
 
-static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+void insert_by_date_cached(struct commit *p, struct commit_list **head,
 		    struct commit_list *cached_base, struct commit_list **cache)
 {
 	struct commit_list *new_entry;
revision.h +25 -1
index fb74492..e767a43 100644
@@ -13,11 +13,25 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define FACE_VALUE	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 struct rev_info;
 struct log_info;
 
+struct rev_cache_info {
+	/* generation flags */
+	unsigned objects : 1,
+		legs : 1,
+		make_index : 1;
+
+	/* traversal flags */
+	unsigned add_to_pending : 1;
+
+	/* fuse options */
+	unsigned int ignore_size;
+};
+
 struct rev_info {
 	/* Starting list */
 	struct commit_list *commits;
@@ -73,6 +87,10 @@ struct rev_info {
 			dense_combined_merges:1,
 			always_show_header:1;
 
+	/* rev-cache flags */
+	unsigned int for_pack:1,
+		dont_cache_me:1;
+
 	/* Format info */
 	unsigned int	shown_one:1,
 			show_merge:1,
@@ -116,6 +134,9 @@ struct rev_info {
 	struct reflog_walk_info *reflog_info;
 	struct decoration children;
 	struct decoration merge_simplification;
+
+	/* caching info, used ONLY by traverse_cache_slice */
+	struct rev_cache_info rev_cache_info;
 };
 
 #define REV_TREE_SAME		0
@@ -167,4 +188,7 @@ enum commit_action {
 
 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+		    struct commit_list *cached_base, struct commit_list **cache);
+
 #endif
t/t6015-rev-cache-list.sh new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
tg: (64d5fe0..) t/revcache/basic (depends on: master)
#1 lore raw

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
 Makefile                  |    2 +
 builtin-rev-cache.c       |  207 ++++++++
 builtin.h                 |    1 +
 commit.c                  |    2 +
 git.c                     |    1 +
 rev-cache.c               | 1171 +++++++++++++++++++++++++++++++++++++++++++++
 rev-cache.h               |  107 ++++
 revision.c                |    2 +-
 revision.h                |   26 +-
 t/t6015-rev-cache-list.sh |  104 ++++
 10 files changed, 1621 insertions(+), 2 deletions(-)
Makefile +2 -0
index e6df8ec..1ceb514 100644
@@ -537,6 +537,7 @@ LIB_OBJS += reflog-walk.o
 LIB_OBJS += refs.o
 LIB_OBJS += remote.o
 LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
 LIB_OBJS += revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += server-info.o
@@ -627,6 +628,7 @@ BUILTIN_OBJS += builtin-reflog.o
 BUILTIN_OBJS += builtin-remote.o
 BUILTIN_OBJS += builtin-rerere.o
 BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-cache.o
 BUILTIN_OBJS += builtin-rev-list.o
 BUILTIN_OBJS += builtin-rev-parse.o
 BUILTIN_OBJS += builtin-revert.o
builtin-rev-cache.c new file +207 -0

207 lines not on this page · raw message

builtin.h +1 -0
index 20427d2..00ecc9c 100644
@@ -87,6 +87,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);
 extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_rerere(int argc, const char **argv, const char *prefix);
 extern int cmd_reset(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
 extern int cmd_revert(int argc, const char **argv, const char *prefix);
commit.c +2 -0
index e2bcbe8..682e7a7 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 	item->tree = lookup_tree(parent);
 	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
 	pptr = &item->parents;
+	while (pop_commit(pptr))
+		; /* clear anything from cache */
 
 	graft = lookup_commit_graft(item->object.sha1);
 	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +1 -0
index 4588a8b..7105c74 100644
@@ -342,6 +342,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "repo-config", cmd_config },
 		{ "rerere", cmd_rerere, RUN_SETUP },
 		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse },
 		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1171 -0

1,171 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +1 -1
index 9f5dac5..485bf72 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	commit->object.flags |= TREESAME;
 }
 
-static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+void insert_by_date_cached(struct commit *p, struct commit_list **head,
 		    struct commit_list *cached_base, struct commit_list **cache)
 {
 	struct commit_list *new_entry;
revision.h +25 -1
index fb74492..e767a43 100644
@@ -13,11 +13,25 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define FACE_VALUE	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 struct rev_info;
 struct log_info;
 
+struct rev_cache_info {
+	/* generation flags */
+	unsigned objects : 1,
+		legs : 1,
+		make_index : 1;
+
+	/* traversal flags */
+	unsigned add_to_pending : 1;
+
+	/* fuse options */
+	unsigned int ignore_size;
+};
+
 struct rev_info {
 	/* Starting list */
 	struct commit_list *commits;
@@ -73,6 +87,10 @@ struct rev_info {
 			dense_combined_merges:1,
 			always_show_header:1;
 
+	/* rev-cache flags */
+	unsigned int for_pack:1,
+		dont_cache_me:1;
+
 	/* Format info */
 	unsigned int	shown_one:1,
 			show_merge:1,
@@ -116,6 +134,9 @@ struct rev_info {
 	struct reflog_walk_info *reflog_info;
 	struct decoration children;
 	struct decoration merge_simplification;
+
+	/* caching info, used ONLY by traverse_cache_slice */
+	struct rev_cache_info rev_cache_info;
 };
 
 #define REV_TREE_SAME		0
@@ -167,4 +188,7 @@ enum commit_action {
 
 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+		    struct commit_list *cached_base, struct commit_list **cache);
+
 #endif
t/t6015-rev-cache-list.sh new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
tg: (64d5fe0..) t/revcache/basic (depends on: master)
#2 lore raw

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
fixed a whitespace error.

 Makefile                  |    2 +
 builtin-rev-cache.c       |  207 ++++++++
 builtin.h                 |    1 +
 commit.c                  |    2 +
 git.c                     |    1 +
 rev-cache.c               | 1171 +++++++++++++++++++++++++++++++++++++++++++++
 rev-cache.h               |  107 ++++
 revision.c                |    2 +-
 revision.h                |   26 +-
 t/t6015-rev-cache-list.sh |  104 ++++
 10 files changed, 1621 insertions(+), 2 deletions(-)
Makefile +2 -0
index e6df8ec..1ceb514 100644
@@ -537,6 +537,7 @@ LIB_OBJS += reflog-walk.o
 LIB_OBJS += refs.o
 LIB_OBJS += remote.o
 LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
 LIB_OBJS += revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += server-info.o
@@ -627,6 +628,7 @@ BUILTIN_OBJS += builtin-reflog.o
 BUILTIN_OBJS += builtin-remote.o
 BUILTIN_OBJS += builtin-rerere.o
 BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-cache.o
 BUILTIN_OBJS += builtin-rev-list.o
 BUILTIN_OBJS += builtin-rev-parse.o
 BUILTIN_OBJS += builtin-revert.o
builtin-rev-cache.c new file +207 -0

207 lines not on this page · raw message

builtin.h +1 -0
index 20427d2..00ecc9c 100644
@@ -87,6 +87,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);
 extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_rerere(int argc, const char **argv, const char *prefix);
 extern int cmd_reset(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
 extern int cmd_revert(int argc, const char **argv, const char *prefix);
commit.c +2 -0
index e2bcbe8..682e7a7 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 	item->tree = lookup_tree(parent);
 	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
 	pptr = &item->parents;
+	while (pop_commit(pptr))
+		; /* clear anything from cache */
 
 	graft = lookup_commit_graft(item->object.sha1);
 	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +1 -0
index 4588a8b..7105c74 100644
@@ -342,6 +342,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "repo-config", cmd_config },
 		{ "rerere", cmd_rerere, RUN_SETUP },
 		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse },
 		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1171 -0

1,171 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +1 -1
index 9f5dac5..485bf72 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	commit->object.flags |= TREESAME;
 }
 
-static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+void insert_by_date_cached(struct commit *p, struct commit_list **head,
 		    struct commit_list *cached_base, struct commit_list **cache)
 {
 	struct commit_list *new_entry;
revision.h +25 -1
index fb74492..e767a43 100644
@@ -13,11 +13,25 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define FACE_VALUE	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 struct rev_info;
 struct log_info;
 
+struct rev_cache_info {
+	/* generation flags */
+	unsigned objects : 1,
+		legs : 1,
+		make_index : 1;
+
+	/* traversal flags */
+	unsigned add_to_pending : 1;
+
+	/* fuse options */
+	unsigned int ignore_size;
+};
+
 struct rev_info {
 	/* Starting list */
 	struct commit_list *commits;
@@ -73,6 +87,10 @@ struct rev_info {
 			dense_combined_merges:1,
 			always_show_header:1;
 
+	/* rev-cache flags */
+	unsigned int for_pack:1,
+		dont_cache_me:1;
+
 	/* Format info */
 	unsigned int	shown_one:1,
 			show_merge:1,
@@ -116,6 +134,9 @@ struct rev_info {
 	struct reflog_walk_info *reflog_info;
 	struct decoration children;
 	struct decoration merge_simplification;
+
+	/* caching info, used ONLY by traverse_cache_slice */
+	struct rev_cache_info rev_cache_info;
 };
 
 #define REV_TREE_SAME		0
@@ -167,4 +188,7 @@ enum commit_action {
 
 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+		    struct commit_list *cached_base, struct commit_list **cache);
+
 #endif
t/t6015-rev-cache-list.sh new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
tg: (64d5fe0..) t/revcache/basic (depends on: master)
#3 lore raw

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
Renamed test file to t6017-... to avoid conflict with newly-introduced t6015-rev-list-show-all-parents.

 Makefile                  |    2 +
 builtin-rev-cache.c       |  207 ++++++++
 builtin.h                 |    1 +
 commit.c                  |    2 +
 git.c                     |    1 +
 rev-cache.c               | 1171 +++++++++++++++++++++++++++++++++++++++++++++
 rev-cache.h               |  107 ++++
 revision.c                |    2 +-
 revision.h                |   26 +-
 t/t6017-rev-cache-list.sh |  112 +++++
 10 files changed, 1629 insertions(+), 2 deletions(-)
Makefile +2 -0
index a614347..242e2af 100644
@@ -529,6 +529,7 @@ LIB_OBJS += refs.o
 LIB_OBJS += remote.o
 LIB_OBJS += replace_object.o
 LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
 LIB_OBJS += revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += server-info.o
@@ -620,6 +621,7 @@ BUILTIN_OBJS += builtin-remote.o
 BUILTIN_OBJS += builtin-replace.o
 BUILTIN_OBJS += builtin-rerere.o
 BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-cache.o
 BUILTIN_OBJS += builtin-rev-list.o
 BUILTIN_OBJS += builtin-rev-parse.o
 BUILTIN_OBJS += builtin-revert.o
builtin-rev-cache.c new file +207 -0

207 lines not on this page · raw message

builtin.h +1 -0
index a2174dc..2f89feb 100644
@@ -86,6 +86,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);
 extern int cmd_config(int argc, const char **argv, const char *prefix);
 extern int cmd_rerere(int argc, const char **argv, const char *prefix);
 extern int cmd_reset(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_cache(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
 extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
 extern int cmd_revert(int argc, const char **argv, const char *prefix);
commit.c +2 -0
index a6c6f70..b7485c4 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 	item->tree = lookup_tree(parent);
 	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
 	pptr = &item->parents;
+	while (pop_commit(pptr))
+		; /* clear anything from cache */
 
 	graft = lookup_commit_graft(item->object.sha1);
 	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +1 -0
index 0b22595..3cfde66 100644
@@ -343,6 +343,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "repo-config", cmd_config },
 		{ "rerere", cmd_rerere, RUN_SETUP },
 		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse },
 		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1171 -0

1,171 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +1 -1
index 35eca4a..c7fd35f 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 	commit->object.flags |= TREESAME;
 }
 
-static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+void insert_by_date_cached(struct commit *p, struct commit_list **head,
 		    struct commit_list *cached_base, struct commit_list **cache)
 {
 	struct commit_list *new_entry;
revision.h +25 -1
index 9d0dddb..7db4b9e 100644
@@ -13,7 +13,8 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define FACE_VALUE	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 #define DECORATE_SHORT_REFS	1
 #define DECORATE_FULL_REFS	2
@@ -21,6 +22,19 @@
 struct rev_info;
 struct log_info;
 
+struct rev_cache_info {
+	/* generation flags */
+	unsigned objects : 1,
+		legs : 1,
+		make_index : 1;
+
+	/* traversal flags */
+	unsigned add_to_pending : 1;
+
+	/* fuse options */
+	unsigned int ignore_size;
+};
+
 struct rev_info {
 	/* Starting list */
 	struct commit_list *commits;
@@ -76,6 +90,10 @@ struct rev_info {
 			dense_combined_merges:1,
 			always_show_header:1;
 
+	/* rev-cache flags */
+	unsigned int for_pack:1,
+		dont_cache_me:1;
+
 	/* Format info */
 	unsigned int	shown_one:1,
 			show_merge:1,
@@ -119,6 +137,9 @@ struct rev_info {
 	struct reflog_walk_info *reflog_info;
 	struct decoration children;
 	struct decoration merge_simplification;
+
+	/* caching info, used ONLY by traverse_cache_slice */
+	struct rev_cache_info rev_cache_info;
 };
 
 #define REV_TREE_SAME		0
@@ -171,4 +192,7 @@ enum commit_action {
 extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+		    struct commit_list *cached_base, struct commit_list **cache);
+
 #endif
t/t6017-rev-cache-list.sh new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
tg: (6ea71fe..) t/revcache/basic (depends on: master)
#4 lore raw
In reply to Nick Edelen

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
removed useless test.

  Makefile                  |    2 +
  builtin-rev-cache.c       |  207 ++++++++
  builtin.h                 |    1 +
  commit.c                  |    2 +
  git.c                     |    1 +
  rev-cache.c               | 1171 +++++++++++++++++++++++++++++++++++++++++++++
  rev-cache.h               |  107 ++++
  revision.c                |    2 +-
  revision.h                |   26 +-
  t/t6017-rev-cache-list.sh |  106 ++++
  10 files changed, 1623 insertions(+), 2 deletions(-)
Makefile +2 -0
index 12defd4..3098cc7 100644
@@ -534,6 +534,7 @@ LIB_OBJS += refs.o
  LIB_OBJS += remote.o
  LIB_OBJS += replace_object.o
  LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
  LIB_OBJS += revision.o
  LIB_OBJS += run-command.o
  LIB_OBJS += server-info.o
@@ -626,6 +627,7 @@ BUILTIN_OBJS += builtin-remote.o
  BUILTIN_OBJS += builtin-replace.o
  BUILTIN_OBJS += builtin-rerere.o
  BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-cache.o
  BUILTIN_OBJS += builtin-rev-list.o
  BUILTIN_OBJS += builtin-rev-parse.o
  BUILTIN_OBJS += builtin-revert.o
builtin-rev-cache.c new file +207 -0

207 lines not on this page · raw message

builtin.h +1 -0
index a2174dc..2f89feb 100644
@@ -86,6 +86,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);
  extern int cmd_config(int argc, const char **argv, const char *prefix);
  extern int cmd_rerere(int argc, const char **argv, const char *prefix);
  extern int cmd_reset(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_cache(int argc, const char **argv, const char *prefix);
  extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
  extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
  extern int cmd_revert(int argc, const char **argv, const char *prefix);
commit.c +2 -0
index fedbd5e..61d83c6 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
  	item->tree = lookup_tree(parent);
  	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
  	pptr = &item->parents;
+	while (pop_commit(pptr))
+		; /* clear anything from cache */
 
  	graft = lookup_commit_graft(item->object.sha1);
  	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +1 -0
index 9883009..dfaa07f 100644
@@ -343,6 +343,7 @@ static void handle_internal_command(int argc, const char **argv)
  		{ "repo-config", cmd_config },
  		{ "rerere", cmd_rerere, RUN_SETUP },
  		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
  		{ "rev-list", cmd_rev_list, RUN_SETUP },
  		{ "rev-parse", cmd_rev_parse },
  		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1171 -0

1,171 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +1 -1
index 35eca4a..c7fd35f 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
  	commit->object.flags |= TREESAME;
  }
 
-static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+void insert_by_date_cached(struct commit *p, struct commit_list **head,
  		    struct commit_list *cached_base, struct commit_list **cache)
  {
  	struct commit_list *new_entry;
revision.h +25 -1
index 9d0dddb..7db4b9e 100644
@@ -13,7 +13,8 @@
  #define CHILD_SHOWN	(1u<<6)
  #define ADDED		(1u<<7)	/* Parents already parsed and added? */
  #define SYMMETRIC_LEFT	(1u<<8)
-#define ALL_REV_FLAGS	((1u<<9)-1)
+#define FACE_VALUE	(1u<<9)
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
  #define DECORATE_SHORT_REFS	1
  #define DECORATE_FULL_REFS	2
@@ -21,6 +22,19 @@
  struct rev_info;
  struct log_info;
 
+struct rev_cache_info {
+	/* generation flags */
+	unsigned objects : 1,
+		legs : 1,
+		make_index : 1;
+
+	/* traversal flags */
+	unsigned add_to_pending : 1;
+
+	/* fuse options */
+	unsigned int ignore_size;
+};
+
  struct rev_info {
  	/* Starting list */
  	struct commit_list *commits;
@@ -76,6 +90,10 @@ struct rev_info {
  			dense_combined_merges:1,
  			always_show_header:1;
 
+	/* rev-cache flags */
+	unsigned int for_pack:1,
+		dont_cache_me:1;
+
  	/* Format info */
  	unsigned int	shown_one:1,
  			show_merge:1,
@@ -119,6 +137,9 @@ struct rev_info {
  	struct reflog_walk_info *reflog_info;
  	struct decoration children;
  	struct decoration merge_simplification;
+
+	/* caching info, used ONLY by traverse_cache_slice */
+	struct rev_cache_info rev_cache_info;
  };
 
  #define REV_TREE_SAME		0
@@ -171,4 +192,7 @@ enum commit_action {
  extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
  extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
 
+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+		    struct commit_list *cached_base, struct commit_list **cache);
+
  #endif
t/t6017-rev-cache-list.sh new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
tg: (a6dbf88..) t/revcache/basic (depends on: master)
#6 lore raw
Quoted 1 line

The entire series is unusable due to whitespace breakage.

Shit sorry about that. I think my mail client reset some settings when I upgraded. Will resend.

I feel like such a klutz...

#8 lore raw
In reply to Nick Edelen

Second in the revision cache series, this particular patch provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests

---
removed useless test. sorry about large size: this is less of a patch and more an addition of two files.

Makefile                  |    2 +
builtin-rev-cache.c       |  207 ++++++++
builtin.h                 |    1 +
commit.c                  |    2 +
git.c                     |    1 +
rev-cache.c               | 1171 +++++++++++++++++++++++++++++++++++++++++++++
rev-cache.h               |  107 ++++
revision.c                |    2 +-
revision.h                |   26 +-
t/t6017-rev-cache-list.sh |  106 ++++
10 files changed, 1623 insertions(+), 2 deletions(-)
Makefile +0 -0
index 42b7d60..93e20ab 100644
@@ -538,6 +538,7 @@ LIB_OBJS += refs.o

LIB_OBJS += remote.o
LIB_OBJS += replace_object.o
LIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.o
LIB_OBJS += revision.o
LIB_OBJS += run-command.o
LIB_OBJS += server-info.o
@@ -630,6 +631,7 @@ BUILTIN_OBJS += builtin-remote.o BUILTIN_OBJS += builtin-replace.o BUILTIN_OBJS += builtin-rerere.o BUILTIN_OBJS += builtin-reset.o +BUILTIN_OBJS += builtin-rev-cache.o BUILTIN_OBJS += builtin-rev-list.o BUILTIN_OBJS += builtin-rev-parse.o BUILTIN_OBJS += builtin-revert.o

builtin-rev-cache.c new file +207 -0

207 lines not on this page · raw message

builtin.h +0 -0
index a2174dc..2f89feb 100644
@@ -86,6 +86,7 @@ extern int cmd_remote(int argc, const char **argv, const char *prefix);

extern int cmd_config(int argc, const char **argv, const char *prefix); extern int cmd_rerere(int argc, const char **argv, const char *prefix); extern int cmd_reset(int argc, const char **argv, const char *prefix); +extern int cmd_rev_cache(int argc, const char **argv, const char *prefix); extern int cmd_rev_list(int argc, const char **argv, const char *prefix); extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); extern int cmd_revert(int argc, const char **argv, const char *prefix);

commit.c +0 -0
index fedbd5e..61d83c6 100644
@@ -252,6 +252,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
	item->tree = lookup_tree(parent);
	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
	pptr = &item->parents;

+ while (pop_commit(pptr))
+ ; /* clear anything from cache */

	graft = lookup_commit_graft(item->object.sha1);
	while (bufptr + 48 < tail && !memcmp(bufptr, "parent ", 7)) {
git.c +0 -0
index bd2c5fe..c016f50 100644
@@ -345,6 +345,7 @@ static void handle_internal_command(int argc, const char **argv)
		{ "repo-config", cmd_config },
		{ "rerere", cmd_rerere, RUN_SETUP },
		{ "reset", cmd_reset, RUN_SETUP },
+		{ "rev-cache", cmd_rev_cache, RUN_SETUP },
		{ "rev-list", cmd_rev_list, RUN_SETUP },
		{ "rev-parse", cmd_rev_parse },
		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
rev-cache.c new file +1171 -0

1,171 lines not on this page · raw message

rev-cache.h new file +107 -0

107 lines not on this page · raw message

revision.c +0 -0
index 9fc4e8d..de9e2e3 100644
@@ -432,7 +432,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
	commit->object.flags |= TREESAME;
}

-static void insert_by_date_cached(struct commit *p, struct commit_list **head, +void insert_by_date_cached(struct commit *p, struct commit_list **head,
struct commit_list *cached_base, struct commit_list **cache)

{
	struct commit_list *new_entry;
revision.h +0 -0
index b6421a6..1b7b93f 100644
@@ -13,7 +13,8 @@

#define CHILD_SHOWN (1u<<6)
#define ADDED (1u<<7) /* Parents already parsed and added? */
#define SYMMETRIC_LEFT (1u<<8)
-#define ALL_REV_FLAGS ((1u<<9)-1)
+#define FACE_VALUE (1u<<9)
+#define ALL_REV_FLAGS ((1u<<10)-1)

#define DECORATE_SHORT_REFS 1
#define DECORATE_FULL_REFS 2
@@ -21,6 +22,19 @@
struct rev_info;
struct log_info;

+struct rev_cache_info {
+ /* generation flags */
+ unsigned objects : 1,
+ legs : 1,
+ make_index : 1;
+
+ /* traversal flags */
+ unsigned add_to_pending : 1;
+
+ /* fuse options */
+ unsigned int ignore_size;
+};
+

struct rev_info {
	/* Starting list */
	struct commit_list *commits;
@@ -76,6 +90,10 @@ struct rev_info {
			dense_combined_merges:1,
			always_show_header:1;

+ /* rev-cache flags */
+ unsigned int for_pack:1,
+ dont_cache_me:1;
+

	/* Format info */
	unsigned int	shown_one:1,
			show_merge:1,
@@ -120,6 +138,9 @@ struct rev_info {
	struct reflog_walk_info *reflog_info;
	struct decoration children;
	struct decoration merge_simplification;

+
+ /* caching info, used ONLY by traverse_cache_slice */
+ struct rev_cache_info rev_cache_info;
};

#define REV_TREE_SAME 0
@@ -172,4 +193,7 @@ enum commit_action {
extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit); extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);

+extern void insert_by_date_cached(struct commit *p, struct commit_list **head,
+ struct commit_list *cached_base, struct commit_list **cache);
+
#endif

t/t6017-rev-cache-list.sh new file +106 -0

106 lines not on this page · raw message

Signature · 1 line
tg: (e79999b..) t/revcache/basic (depends on: master)