Skip to contentSkip to conversation

full integration of rev-cache into git's revision walker, completed test suite

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

lore
Share & tools
lore
#0 lore raw

PATCH 5/6 full integration of rev-cache into git's revision walker, completed test suite

This patch provides a working integration of rev-cache into the revision walker, along with some touch-ups:
- integration into revision walker and list-objects
- addition of 'unique' field to commit objects, optionally initialized in rev-cache with the objects introduced in that commit
- tweak of object generation to take advantage of the 'unique' field
- more fluid handling of damaged cache slices
- numerous tests for both features from the previous patch, and the
integration's integrity

'Integration' is rather broad -- a more detailed description follows for each aspect:
- rev-cache
the traversal mechanism is updated to handle many of the non-prune options rev-list does (date limiting, slop-handling, etc.), and is adjusted to allow for non-fatal cache-traversal failures.

- revision walker
both limited and unlimited traversal attempt to use the cache when possible, smoothly falling back if it's not.

- list-objects
object listing does not recurse into cached trees, and has been adjusted to guarantee commit-tag-tree-blob ordering.

---
5/5 in previous. I decided to not split this up, as Sam suggested, largely because the changesets, while seemingly numerous, are actually rather small, and very connected with each other. Tests for --ignore-size are also added.

 builtin-rev-cache.c       |   46 +++++++-
 commit.c                  |    2 +-
 commit.h                  |    1 +
 list-objects.c            |   49 ++++++-
 rev-cache.c               |  303 ++++++++++++++++++++++++++++++++++++++------
 revision.c                |   87 +++++++++++---
 t/t6015-rev-cache-list.sh |  152 +++++++++++++++++++++--
 7 files changed, 562 insertions(+), 78 deletions(-)
builtin-rev-cache.c +43 -3
index 532ec9f..4a02af6 100755
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "diff.h"
 #include "revision.h"
+#include "list-objects.h"
 
 #define DEFAULT_IGNORE_SLICE_SIZE		"30mb"
 
@@ -69,6 +70,43 @@ static int handle_add(int argc, const char *argv[]) /* args beyond this command
 	return 0;
 }
 
+static void show_commit(struct commit *commit, void *data)
+{
+	printf("%s\n", sha1_to_hex(commit->object.sha1));
+}
+
+static void show_object(struct object *obj, const struct name_path *path, const char *last)
+{
+	printf("%s\n", sha1_to_hex(obj->sha1));
+}
+
+static int test_rev_list(int argc, const char *argv[])
+{
+	struct rev_info revs;
+	unsigned int flags = 0;
+	int i;
+	
+	init_revisions(&revs, 0);
+	
+	for (i = 0; i < argc; i++) {
+		if (!strcmp(argv[i], "--not"))
+			flags ^= UNINTERESTING;
+		else if (!strcmp(argv[i], "--objects"))
+			revs.tree_objects = revs.blob_objects = 1;
+		else
+			handle_revision_arg(argv[i], &revs, flags, 1);
+	}
+	
+	setup_revisions(0, 0, &revs, 0);
+	revs.topo_order = 1;
+	revs.lifo = 1;
+	prepare_revision_walk(&revs);
+	
+	traverse_commit_list(&revs, show_commit, show_object, 0);
+	
+	return 0;
+}
+
 static int handle_walk(int argc, const char *argv[])
 {
 	struct commit *commit;
@@ -117,17 +155,17 @@ static int handle_walk(int argc, const char *argv[])
 	if (retval < 0)
 		return retval;
 	
-	printf("queue:\n");
+	fprintf(stderr, "queue:\n");
 	while ((commit = pop_commit(&queue)) != 0) {
 		printf("%s\n", sha1_to_hex(commit->object.sha1));
 	}
 	
-	printf("work:\n");
+	fprintf(stderr, "work:\n");
 	while ((commit = pop_commit(&work)) != 0) {
 		printf("%s\n", sha1_to_hex(commit->object.sha1));
 	}
 	
-	printf("pending:\n");
+	fprintf(stderr, "pending:\n");
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object *obj = revs.pending.objects[i].item;
 		
@@ -259,6 +297,8 @@ int cmd_rev_cache(int argc, const char *argv[], const char *prefix)
 		r = handle_walk(argc, argv);
 	else if (!strcmp(arg, "index"))
 		r = handle_index(argc, argv);
+	else if (!strcmp(arg, "test"))
+		r = test_rev_list(argc, argv);
 	else
 		return handle_help();
 	
commit.c +1 -1
index afe504f..1b710c2 100644
@@ -252,7 +252,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
 			     sha1_to_hex(item->object.sha1));
 	item->tree = lookup_tree(parent);
 	bufptr += 46; /* "tree " + "hex sha1" + "\n" */
- 	pptr = &item->parents;
+	pptr = &item->parents;
 	while (pop_commit(pptr))
 		; /* clear anything from cache */
 
commit.h +1 -0
index 0529fcf..7c50a7f 100644
@@ -20,6 +20,7 @@ struct commit {
 	struct tree *tree;
 	char *buffer;
 	unsigned long size;
+	struct object_list *unique;
 };
 
 extern int save_commit_buffer;
list-objects.c +42 -7

93 lines not on this page · raw message

rev-cache.c +261 -42

525 lines not on this page · raw message

revision.c +71 -16

136 lines not on this page · raw message

t/t6015-rev-cache-list.sh +143 -9

192 lines not on this page · raw message

Signature · 1 line
tg: (c7a46b0..) t/revcache/integration (depends on: t/revcache/misc)
#1 lore raw
Quoted 2 lines · Nick Edelen

This patch provides a working integration of rev-cache into the revision walker, along with some touch-ups:

This message from me is not about the patch 5/6 at all. It is about your earlier patches in the series.

Quoted 6 lines

...

builtin-rev-cache.c +2 -2
-	printf("queue:\n");
+	fprintf(stderr, "queue:\n");
...
-	printf("work:\n");
+	fprintf(stderr, "work:\n");

builtin-rev-cache.c static int handle_walk(int argc, const char *argv[])

Quoted 10 lines
builtin-rev-cache.c +3 -3
...
-	printf("pending:\n");
+	fprintf(stderr, "pending:\n");
...
- 	pptr = &item->parents;
+	pptr = &item->parents;
...
-#define SLOP		5
+#define SLOP			5
...

These are all "Shoot, the mistakes in earlier ones need to be fixed here" changes.

Please fix them in the patch earlier in the series so that you do not have to make, and more importantly, reviewers do not have to get distracted by, these fix-up in a later patch like this.

#2 lore raw
In reply to Nick Edelen

This patch provides a working integration of rev-cache into the revision walker, along with some touch-ups:
- integration into revision walker and list-objects
- tweak of object generation to take advantage of the 'unique' field
- more fluid handling of damaged cache slices
- numerous tests for both features from the previous patch, and the
integration's integrity

'Integration' is rather broad -- a more detailed description follows for each aspect:
- rev-cache
the traversal mechanism is updated to handle many of the non-prune options rev-list does (date limiting, slop-handling, etc.), and is adjusted to allow for non-fatal cache-traversal failures.

- revision walker
both limited and unlimited traversal attempt to use the cache when possible, smoothly falling back if it's not.

- list-objects
object listing does not recurse into cached trees, and has been adjusted to guarantee commit-tag-tree-blob ordering.

---
 builtin-rev-cache.c       |   40 ++++++++
 list-objects.c            |   49 ++++++++--
 rev-cache.c               |  228 +++++++++++++++++++++++++++++++++++++++-----
 revision.c                |   88 ++++++++++++++---
 t/t6015-rev-cache-list.sh |  151 ++++++++++++++++++++++++++++-
 5 files changed, 501 insertions(+), 55 deletions(-)
builtin-rev-cache.c +40 -0
index 7ca39c4..a3489ce 100644
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "revision.h"
 #include "rev-cache.h"
+#include "list-objects.h"
 
 unsigned long default_ignore_size = 50 * 1024 * 1024; /* 50mb */
 
@@ -78,6 +79,43 @@ static int handle_add(int argc, const char *argv[]) /* args beyond this command
 	return 0;
 }
 
+static void show_commit(struct commit *commit, void *data)
+{
+	printf("%s\n", sha1_to_hex(commit->object.sha1));
+}
+
+static void show_object(struct object *obj, const struct name_path *path, const char *last)
+{
+	printf("%s\n", sha1_to_hex(obj->sha1));
+}
+
+static int test_rev_list(int argc, const char *argv[])
+{
+	struct rev_info revs;
+	unsigned int flags = 0;
+	int i;
+
+	init_revisions(&revs, 0);
+
+	for (i = 0; i < argc; i++) {
+		if (!strcmp(argv[i], "--not"))
+			flags ^= UNINTERESTING;
+		else if (!strcmp(argv[i], "--objects"))
+			revs.tree_objects = revs.blob_objects = 1;
+		else
+			handle_revision_arg(argv[i], &revs, flags, 1);
+	}
+
+	setup_revisions(0, 0, &revs, 0);
+	revs.topo_order = 1;
+	revs.lifo = 1;
+	prepare_revision_walk(&revs);
+
+	traverse_commit_list(&revs, show_commit, show_object, 0);
+
+	return 0;
+}
+
 static int handle_walk(int argc, const char *argv[])
 {
 	struct commit *commit;
@@ -270,6 +308,8 @@ int cmd_rev_cache(int argc, const char *argv[], const char *prefix)
 		r = handle_walk(argc, argv);
 	else if (!strcmp(arg, "index"))
 		r = handle_index(argc, argv);
+	else if (!strcmp(arg, "test"))
+		r = test_rev_list(argc, argv);
 	else if (!strcmp(arg, "alt"))
 		r = handle_alt(argc, argv);
 	else
list-objects.c +42 -7

93 lines not on this page · raw message

rev-cache.c +201 -25

382 lines not on this page · raw message

revision.c +72 -16

143 lines not on this page · raw message

t/t6015-rev-cache-list.sh +145 -6

187 lines not on this page · raw message

Signature · 1 line
tg: (04607f1..) t/revcache/integration (depends on: t/revcache/misc)