basic api and porcelain
PATCH 2/7 basic api and porcelain
Provides:
- minimal API: caching only commit topo data
- minimal porcelain: add and walk cache slices
- appropriate tests
---
Makefile | 2 + builtin.h | 1 + builtin/rev-cache.c | 210 ++++++++ commit.c | 2 + git.c | 1 + rev-cache.c | 1273 +++++++++++++++++++++++++++++++++++++++++++++ rev-cache.h | 105 ++++ revision.c | 2 +- revision.h | 26 +- t/t6019-rev-cache-list.sh | 106 ++++ 10 files changed, 1726 insertions(+), 2 deletions(-)
Makefile +0 -0
@@ -597,6 +597,7 @@ LIB_OBJS += refs.o
LIB_OBJS += remote.oLIB_OBJS += replace_object.oLIB_OBJS += rerere.o
+LIB_OBJS += rev-cache.oLIB_OBJS += resolve-undo.oLIB_OBJS += revision.oLIB_OBJS += run-command.o
@@ -697,6 +698,7 @@ BUILTIN_OBJS += builtin/reflog.o BUILTIN_OBJS += builtin/remote.o BUILTIN_OBJS += builtin/replace.o BUILTIN_OBJS += builtin/rerere.o +BUILTIN_OBJS += builtin/rev-cache.o BUILTIN_OBJS += builtin/reset.oBUILTIN_OBJS += builtin/rev-list.o BUILTIN_OBJS += builtin/rev-parse.o
builtin.h +0 -0
@@ -112,6 +112,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);
builtin/rev-cache.c new file +210 -0
210 lines not on this page · raw message
commit.c +0 -0
@@ -251,6 +251,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
@@ -363,6 +363,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 +1273 -0
1,273 lines not on this page · raw message
rev-cache.h new file +105 -0
105 lines not on this page · raw message
revision.c +0 -0
@@ -444,7 +444,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
@@ -14,7 +14,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
@@ -23,6 +24,19 @@ struct rev_info;
struct log_info;
struct string_list;
+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;
@@ -79,6 +93,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,
@@ -131,6 +149,9 @@ struct rev_info {
/* notes-specific options: which refs to show */ struct display_notes_opt notes_opt;
+
+ /* caching info, used ONLY by traverse_cache_slice */
+ struct rev_cache_info rev_cache_info;
};
#define REV_TREE_SAME 0
@@ -186,4 +207,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/t6019-rev-cache-list.sh new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
tg: (bac39ea..) t/rc/basic (depends on: t/rc/docs)
rev-cache.c line 1026
Quoted 2 lines · Nick Edelen
rev-cache.c new file +2
-0+/* initialize header */ +strcpy (head.signature,"REVCACHE" );
head.signature is 8 characters (see below), and so is "REVCACHE". Surely either
head.signature needs to be 9 characters, or you shouldn't use strcpy. Indeed, mostly you do seem to be using memcpy ...
This is in a couple of other places too, with both rc_index_header, and rc_slice_header.
Quoted 24 lines
rev-cache.h new file +23
-0+/* single index maps objects to cache files */ +struct rc_index_header { +char signature[8 ];/* REVINDEX */ +unsigned char version; +uint32_t ofs_objects; + +uint32_t object_nr; +unsigned char cache_nr; + +uint32_t max_date; +}; +/* structure for actual cache file */ +struct rc_slice_header { +char signature[8 ];/* REVCACHE */ +unsigned char version; +uint32_t ofs_objects; + +uint32_t object_nr; +uint16_t path_nr; +uint32_t size; + +unsigned char sha1[20 ]; +};
Signature · 1 line
Julian
Quoted 4 lines
head.signature is 8 characters (see below), and so is "REVCACHE". Surely either
head.signature needs to be 9 characters, or you shouldn't use strcpy. Indeed, mostly you do seem to be using memcpy ...
aw shit, don't know how those slipped in there... managed to do that with slice pointer initialization too. looks like I might have to do another submission later.