rev-cache: tentative integration into rev-list + tests
PATCH 4/4 rev-cache: tentative integration into rev-list + tests
This patch introduces a tentative step towards integrating rev-cache into the internal revision walker. Cache traversal is added to both limited and unlimited revision walks, and FACE_VALUEd objects are handled in list-objects. Furthermore the unique object_list field is added to commit objects, to allow runtime association with a commit's cached 'unique' object list.
The traversal mechanism in rev-cache is updated to reflect the limiting methods used in rev-list. Tests for coagulation and index generation are included, in addition to several verifying the correctness of integration.
--- builtin-rev-cache.c | 44 +++++++- commit.c | 2 +- commit.h | 1 + list-objects.c | 19 +++- rev-cache.c | 299 +++++++++++++++++++++++++++++++++++++++------ revision.c | 91 +++++++++++--- t/t6015-rev-cache-list.sh | 120 +++++++++++++++++-- 7 files changed, 505 insertions(+), 71 deletions(-)
This patch introduces a tentative step towards integrating rev-cache into the internal revision walker. Cache traversal is added to both limited and unlimited revision walks, and FACE_VALUEd objects are handled in list-objects. Furthermore the unique object_list field is added to commit objects, to allow runtime association with a commit's cached 'unique' object list.
The traversal mechanism in rev-cache is updated to reflect the limiting methods used in rev-list. Tests for coagulation and index generation are included, in addition to several verifying the correctness of integration.
--- builtin-rev-cache.c | 44 +++++++- commit.c | 2 +- commit.h | 1 + list-objects.c | 19 +++- rev-cache.c | 299 +++++++++++++++++++++++++++++++++++++++------ revision.c | 91 +++++++++++--- t/t6015-rev-cache-list.sh | 120 +++++++++++++++++-- 7 files changed, 505 insertions(+), 71 deletions(-)
builtin-rev-cache.c +42 -2
@@ -3,6 +3,7 @@#include "commit.h" #include "diff.h" #include "revision.h" +#include "list-objects.h" #define DEFAULT_IGNORE_SLICE_SIZE 5000000/* in bytes */
@@ -69,10 +70,46 @@ static int handle_add(int argc, const char *argv[]) /* args beyond this commandreturn 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 ); +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;struct rev_info revs; +struct rev_cache_info rci;struct commit_list *queue, *work, **qp;unsigned char *sha1p, *sha1pt;unsigned long date =0 ;
@@ -80,6 +117,7 @@ static int handle_walk(int argc, const char *argv[])int retval, slop =5 , i;init_revisions (&revs,0 ); +init_rci (&rci);for (i =0 ; i < argc; i++) {if (!strcmp (argv[i],"--not" ))
@@ -113,7 +151,7 @@ static int handle_walk(int argc, const char *argv[]) queue =0 ; qp = &queue; commit =pop_commit (&work); - retval =traverse_cache_slice (0 , sha1p, &revs, commit, &date, &slop, &qp, &work); + retval =traverse_cache_slice (&rci, sha1p, &revs, commit, &date, &slop, &qp, &work);if (retval <0 )return retval;
@@ -181,7 +219,7 @@ static int handle_fuse(int argc, const char *argv[])static int handle_index (int argc,const char *argv[]) { -return regenerate_cache_index (); +return regenerate_cache_index (0 ); }static int handle_help (void )
@@ -235,6 +273,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
@@ -256,7 +256,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
@@ -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 +15 -4
@@ -78,6 +78,10 @@ static void process_tree(struct rev_info *revs,die ("bad tree object %s" ,sha1_to_hex (obj->sha1)); obj->flags |=SEEN ;show (obj, path, name); + +if (obj->flags &FACE_VALUE ) +return ; + me.up = path; me.elem = name; me.elem_len =strlen (name);
@@ -85,11 +89,16 @@ static void process_tree(struct rev_info *revs,init_tree_desc (&desc, tree->buffer, tree->size);while (tree_entry (&desc, &entry)) { -if (S_ISDIR (entry.mode)) +if (S_ISDIR (entry.mode)) { +struct tree *subtree =lookup_tree (entry.sha1); +if (!subtree) +continue ; + + subtree->object.flags &= ~FACE_VALUE ;process_tree (revs, -lookup_tree (entry.sha1), + subtree, show, &me, entry.path); -else if (S_ISGITLINK (entry.mode)) + }else if (S_ISGITLINK (entry.mode))process_gitlink (revs, entry.sha1, show, &me, entry.path);else
@@ -136,6 +145,7 @@ void mark_edges_uninteresting(struct commit_list *list,static void add_pending_tree (struct rev_info *revs,struct tree *tree) { + tree->object.flags &= ~FACE_VALUE ;add_pending_object (revs, &tree->object,"" ); }
@@ -148,7 +158,8 @@ void traverse_commit_list(struct rev_info *revs,struct commit *commit;while ((commit =get_revision (revs)) !=NULL ) { -add_pending_tree (revs, commit->tree); +if (!(commit->object.flags &FACE_VALUE )) +add_pending_tree (revs, commit->tree);show_commit (commit, data); }for (i =0 ; i < revs->pending.nr; i++) {
rev-cache.c +261 -38
514 lines not on this page · raw message
revision.c +75 -16
135 lines not on this page · raw message
t/t6015-rev-cache-list.sh +110 -10
166 lines not on this page · raw message
Signature · 1 line
tg: (de9a466..) t/revcache/integration (depends on: t/revcache/misc)