bare minimum revision cache system, no integration with git
PATCH 2/5 bare minimum revision cache system, no integration with git
Second in the revision cache series, this particular patch provides (only):
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests
Signed-off-by Nick Edelen <[email protected]>
--- Makefile | 2 + builtin-rev-cache.c | 197 ++++++++ builtin.h | 1 + commit.c | 4 +- git.c | 1 + rev-cache.c | 1145 +++++++++++++++++++++++++++++++++++++++++++++ revision.c | 2 +- revision.h | 44 ++- t/t6015-rev-cache-list.sh | 100 ++++ t/t6015-sha1-dump-diff.py | 36 ++ 10 files changed, 1529 insertions(+), 3 deletions(-)
Makefile +2 -0
@@ -533,6 +533,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
@@ -623,6 +624,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 +197 -0
197 lines not on this page · raw message
builtin.h +1 -0
@@ -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 +3 -1
@@ -251,7 +251,9 @@ 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 */ graft =lookup_commit_graft (item->object.sha1);while (bufptr +48 < tail && !memcmp (bufptr,"parent " ,7 )) {
git.c +1 -0
@@ -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 +1145 -0
1,145 lines not on this page · raw message
revision.c +1 -1
@@ -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 +43 -1
70 lines not on this page · raw message
t/t6015-rev-cache-list.sh new file +100 -0
100 lines not on this page · raw message
t/t6015-sha1-dump-diff.py new file +36 -0
@@ -0,0 +1,36 @@ + +import sys, re + +if len(sys.argv) < 3 : + sys.exit(0) + +f = open(sys.argv[1], 'r') +dict = {} +for line in f : + if len(line) >= 40 and re.match(r'^[0-9a-fA-F]{40}', line[:40]) != None : + dict[line[:40]] = 1 + +f.close() + +f = open(sys.argv[2], 'r') +for line in f : + if len(line) < 40 : + continue + + hash = line[:40] + if re.match(r'^[0-9a-fA-F]{40}', hash) == None : + continue + + if hash in dict : + dict[hash] -= 1 + else : + dict[hash] = -1 + +f.close() + +for k in dict.keys() : + if dict[k] == 0 : + del dict[k] + +if len(dict) : + print dict