{"thread":{"id":"48894","subject":"[PATCH v3 3/5] ref-filter: initialize eaten variable","startedAt":"2018-07-17T08:23:00Z","lastAt":"2018-07-17T08:23:05Z","messageCount":5,"participants":["Olga Telezhnaya"],"isPatch":true,"patchVersion":3,"patchTotal":5},"messages":[{"id":"352747","messageId":"01020164a755d3de-ac85c59f-6a13-4601-b529-9957d9e8b05f-000000@eu-west-1.amazonses.com","threadId":"48894","inReplyTo":"01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 3/5] ref-filter: initialize eaten variable","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2018-07-17T08:22:57Z","receivedAt":"2018-07-17T08:23:00Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Initialize variable `eaten` before its using. We may initialize it in\nparse_object_buffer(), but there are cases when we do not reach this\ninvocation.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n---\n ref-filter.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 27733ef013bed..8db7ca95b12c0 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1439,7 +1439,8 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re\n static int get_object(struct ref_array_item *ref, const struct object_id *oid,\n \t\t       int deref, struct object **obj, struct strbuf *err)\n {\n-\tint eaten;\n+\t/* parse_object_buffer() will set eaten to 0 if free() will be needed */\n+\tint eaten = 1;\n \tint ret = 0;\n \tunsigned long size;\n \tvoid *buf = get_obj(oid, obj, &size, &eaten);\n\n--\nhttps://github.com/git/git/pull/520\n"},{"id":"352748","messageId":"01020164a755d3c7-816ad44e-37cf-4b30-9d02-65e3d31c06f3-000000@eu-west-1.amazonses.com","threadId":"48894","inReplyTo":"01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 2/5] ref-filter: fill empty fields with empty values","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2018-07-17T08:22:57Z","receivedAt":"2018-07-17T08:23:00Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Atoms like \"align\" or \"end\" do not have string representation.\nEarlier we had to go and parse whole object with a hope that we\ncould fill their string representations. It's easier to fill them\nwith an empty string before we start to work with whole object.\n\nIt is important to mention that we fill only these atoms that must\ncontain nothing. So, if we could not fill the atom because, for example,\nthe object is missing, we leave it with NULL.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n---\n ref-filter.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 8611c24fd57d1..27733ef013bed 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1497,6 +1497,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \t\t\trefname = get_symref(atom, ref);\n \t\telse if (starts_with(name, \"upstream\")) {\n \t\t\tconst char *branch_name;\n+\t\t\tv->s = \"\";\n \t\t\t/* only local branches may have an upstream */\n \t\t\tif (!skip_prefix(ref->refname, \"refs/heads/\",\n \t\t\t\t\t &branch_name))\n@@ -1509,6 +1510,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \t\t\tcontinue;\n \t\t} else if (atom->u.remote_ref.push) {\n \t\t\tconst char *branch_name;\n+\t\t\tv->s = \"\";\n \t\t\tif (!skip_prefix(ref->refname, \"refs/heads/\",\n \t\t\t\t\t &branch_name))\n \t\t\t\tcontinue;\n@@ -1549,22 +1551,26 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \t\t\tcontinue;\n \t\t} else if (starts_with(name, \"align\")) {\n \t\t\tv->handler = align_atom_handler;\n+\t\t\tv->s = \"\";\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"end\")) {\n \t\t\tv->handler = end_atom_handler;\n+\t\t\tv->s = \"\";\n \t\t\tcontinue;\n \t\t} else if (starts_with(name, \"if\")) {\n \t\t\tconst char *s;\n-\n+\t\t\tv->s = \"\";\n \t\t\tif (skip_prefix(name, \"if:\", &s))\n \t\t\t\tv->s = xstrdup(s);\n \t\t\tv->handler = if_atom_handler;\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"then\")) {\n \t\t\tv->handler = then_atom_handler;\n+\t\t\tv->s = \"\";\n \t\t\tcontinue;\n \t\t} else if (!strcmp(name, \"else\")) {\n \t\t\tv->handler = else_atom_handler;\n+\t\t\tv->s = \"\";\n \t\t\tcontinue;\n \t\t} else\n \t\t\tcontinue;\n\n--\nhttps://github.com/git/git/pull/520\n"},{"id":"352749","messageId":"01020164a755d51f-f455f25d-713e-4e31-98d4-a45df1905de6-000000@eu-west-1.amazonses.com","threadId":"48894","inReplyTo":"01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 5/5] ref-filter: use oid_object_info() to get object","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2018-07-17T08:22:57Z","receivedAt":"2018-07-17T08:23:02Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Use oid_object_info_extended() to get object info instead of\nread_object_file().\nIt will help to handle some requests faster (e.g., we do not need to\nparse whole object if we need to know %(objectsize)).\nIt could also help us to add new atoms such as %(objectsize:disk)\nand %(deltabase).\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n---\n ref-filter.c | 120 +++++++++++++++++++++++++++++++++++++++++++----------------\n 1 file changed, 87 insertions(+), 33 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 2b401a17c4689..112955f006648 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -61,6 +61,17 @@ struct refname_atom {\n \tint lstrip, rstrip;\n };\n \n+static struct expand_data {\n+\tstruct object_id oid;\n+\tenum object_type type;\n+\tunsigned long size;\n+\toff_t disk_size;\n+\tstruct object_id delta_base_oid;\n+\tvoid *content;\n+\n+\tstruct object_info info;\n+} oi, oi_deref;\n+\n /*\n  * An atom is a valid field atom listed below, possibly prefixed with\n  * a \"*\" to denote deref_tag().\n@@ -202,6 +213,30 @@ static int remote_ref_atom_parser(const struct ref_format *format, struct used_a\n \treturn 0;\n }\n \n+static int objecttype_atom_parser(const struct ref_format *format, struct used_atom *atom,\n+\t\t\t\t  const char *arg, struct strbuf *err)\n+{\n+\tif (arg)\n+\t\treturn strbuf_addf_ret(err, -1, _(\"%%(objecttype) does not take arguments\"));\n+\tif (*atom->name == '*')\n+\t\toi_deref.info.typep = &oi_deref.type;\n+\telse\n+\t\toi.info.typep = &oi.type;\n+\treturn 0;\n+}\n+\n+static int objectsize_atom_parser(const struct ref_format *format, struct used_atom *atom,\n+\t\t\t\t  const char *arg, struct strbuf *err)\n+{\n+\tif (arg)\n+\t\treturn strbuf_addf_ret(err, -1, _(\"%%(objectsize) does not take arguments\"));\n+\tif (*atom->name == '*')\n+\t\toi_deref.info.sizep = &oi_deref.size;\n+\telse\n+\t\toi.info.sizep = &oi.size;\n+\treturn 0;\n+}\n+\n static int body_atom_parser(const struct ref_format *format, struct used_atom *atom,\n \t\t\t    const char *arg, struct strbuf *err)\n {\n@@ -388,8 +423,8 @@ static struct {\n \t\t      const char *arg, struct strbuf *err);\n } valid_atom[] = {\n \t{ \"refname\", SOURCE_NONE, FIELD_STR, refname_atom_parser },\n-\t{ \"objecttype\", SOURCE_OTHER },\n-\t{ \"objectsize\", SOURCE_OTHER, FIELD_ULONG },\n+\t{ \"objecttype\", SOURCE_OTHER, FIELD_STR, objecttype_atom_parser },\n+\t{ \"objectsize\", SOURCE_OTHER, FIELD_ULONG, objectsize_atom_parser },\n \t{ \"objectname\", SOURCE_OTHER, FIELD_STR, objectname_atom_parser },\n \t{ \"tree\", SOURCE_OBJ },\n \t{ \"parent\", SOURCE_OBJ },\n@@ -502,6 +537,12 @@ static int parse_ref_filter_atom(const struct ref_format *format,\n \tused_atom[at].name = xmemdupz(atom, ep - atom);\n \tused_atom[at].type = valid_atom[i].cmp_type;\n \tused_atom[at].source = valid_atom[i].source;\n+\tif (used_atom[at].source == SOURCE_OBJ) {\n+\t\tif (*atom == '*')\n+\t\t\toi_deref.info.contentp = &oi_deref.content;\n+\t\telse\n+\t\t\toi.info.contentp = &oi.content;\n+\t}\n \tif (arg) {\n \t\targ = used_atom[at].name + (arg - atom) + 1;\n \t\tif (!*arg) {\n@@ -817,7 +858,7 @@ static int grab_objectname(const char *name, const struct object_id *oid,\n }\n \n /* See grab_values */\n-static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_common_values(struct atom_value *val, int deref, struct expand_data *oi)\n {\n \tint i;\n \n@@ -829,13 +870,13 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\tif (deref)\n \t\t\tname++;\n \t\tif (!strcmp(name, \"objecttype\"))\n-\t\t\tv->s = type_name(obj->type);\n+\t\t\tv->s = type_name(oi->type);\n \t\telse if (!strcmp(name, \"objectsize\")) {\n-\t\t\tv->value = sz;\n-\t\t\tv->s = xstrfmt(\"%lu\", sz);\n+\t\t\tv->value = oi->size;\n+\t\t\tv->s = xstrfmt(\"%lu\", oi->size);\n \t\t}\n \t\telse if (deref)\n-\t\t\tgrab_objectname(name, &obj->oid, v, &used_atom[i]);\n+\t\t\tgrab_objectname(name, &oi->oid, v, &used_atom[i]);\n \t}\n }\n \n@@ -1194,7 +1235,6 @@ static void fill_missing_values(struct atom_value *val)\n  */\n static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n {\n-\tgrab_common_values(val, deref, obj, buf, sz);\n \tswitch (obj->type) {\n \tcase OBJ_TAG:\n \t\tgrab_tag_values(val, deref, obj, buf, sz);\n@@ -1418,29 +1458,36 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re\n \treturn show_ref(&atom->u.refname, ref->refname);\n }\n \n-static int get_object(struct ref_array_item *ref, const struct object_id *oid,\n-\t\t      int deref, struct object **obj, struct strbuf *err)\n+static int get_object(struct ref_array_item *ref, int deref, struct object **obj,\n+\t\t      struct expand_data *oi, struct strbuf *err)\n {\n \t/* parse_object_buffer() will set eaten to 0 if free() will be needed */\n \tint eaten = 1;\n-\tint ret = 0;\n-\tunsigned long size;\n-\tenum object_type type;\n-\tvoid *buf = read_object_file(oid, &type, &size);\n-\tif (!buf)\n-\t\tret = strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n-\t\t\t\t      oid_to_hex(oid), ref->refname);\n-\telse {\n-\t\t*obj = parse_object_buffer(oid, type, size, buf, &eaten);\n-\t\tif (!*obj)\n-\t\t\tret = strbuf_addf_ret(err, -1, _(\"parse_object_buffer failed on %s for %s\"),\n-\t\t\t\t\t      oid_to_hex(oid), ref->refname);\n-\t\telse\n-\t\t\tgrab_values(ref->value, deref, *obj, buf, size);\n+\tif (oi->info.contentp) {\n+\t\t/* We need to know that to use parse_object_buffer properly */\n+\t\toi->info.sizep = &oi->size;\n+\t\toi->info.typep = &oi->type;\n \t}\n+\tif (oid_object_info_extended(the_repository, &oi->oid, &oi->info,\n+\t\t\t\t     OBJECT_INFO_LOOKUP_REPLACE))\n+\t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n+\t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n+\n+\tif (oi->info.contentp) {\n+\t\t*obj = parse_object_buffer(&oi->oid, oi->type, oi->size, oi->content, &eaten);\n+\t\tif (!obj) {\n+\t\t\tif (!eaten)\n+\t\t\t\tfree(oi->content);\n+\t\t\treturn strbuf_addf_ret(err, -1, _(\"parse_object_buffer failed on %s for %s\"),\n+\t\t\t\t\t       oid_to_hex(&oi->oid), ref->refname);\n+\t\t}\n+\t\tgrab_values(ref->value, deref, *obj, oi->content, oi->size);\n+\t}\n+\n+\tgrab_common_values(ref->value, deref, oi);\n \tif (!eaten)\n-\t\tfree(buf);\n-\treturn ret;\n+\t\tfree(oi->content);\n+\treturn 0;\n }\n \n /*\n@@ -1450,7 +1497,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n {\n \tstruct object *obj;\n \tint i;\n-\tconst struct object_id *tagged;\n+\tstruct object_info empty = OBJECT_INFO_INIT;\n \n \tref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));\n \n@@ -1570,13 +1617,20 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct atom_value *v = &ref->value[i];\n-\t\tif (v->s == NULL)\n-\t\t\tbreak;\n+\t\tif (v->s == NULL && used_atom[i].source == SOURCE_NONE)\n+\t\t\treturn strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n+\t\t\t\t\t       oid_to_hex(&ref->objectname), ref->refname);\n \t}\n-\tif (used_atom_cnt <= i)\n+\n+\tif (need_tagged)\n+\t\toi.info.contentp = &oi.content;\n+\tif (!memcmp(&oi.info, &empty, sizeof(empty)) &&\n+\t    !memcmp(&oi_deref.info, &empty, sizeof(empty)))\n \t\treturn 0;\n \n-\tif (get_object(ref, &ref->objectname, 0, &obj, err))\n+\n+\toi.oid = ref->objectname;\n+\tif (get_object(ref, 0, &obj, &oi, err))\n \t\treturn -1;\n \n \t/*\n@@ -1590,7 +1644,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \t * If it is a tag object, see if we use a value that derefs\n \t * the object, and if we do grab the object it refers to.\n \t */\n-\ttagged = &((struct tag *)obj)->tagged->oid;\n+\toi_deref.oid = ((struct tag *)obj)->tagged->oid;\n \n \t/*\n \t * NEEDSWORK: This derefs tag only once, which\n@@ -1598,7 +1652,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)\n \t * is not consistent with what deref_tag() does\n \t * which peels the onion to the core.\n \t */\n-\treturn get_object(ref, tagged, 1, &obj, err);\n+\treturn get_object(ref, 1, &obj, &oi_deref, err);\n }\n \n /*\n\n--\nhttps://github.com/git/git/pull/520\n"},{"id":"352751","messageId":"01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com","threadId":"48894","inReplyTo":"0102016493ab5347-c0429041-6e66-4550-894c-2d500cb2ed8e-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 1/5] ref-filter: add info_source to valid_atom","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2018-07-17T08:22:57Z","receivedAt":"2018-07-17T08:23:03Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Add the source of object data to prevent parsing of unneeded data.\nThe goal is to improve performance by avoiding calling expensive\nfunctions when we don't need the information they provide\nor when we could get it by using a cheaper function.\n\nIt is stored in valid_atoms because it depends on the atoms we are\ninterested in.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n---\n ref-filter.c | 82 +++++++++++++++++++++++++++++++-----------------------------\n 1 file changed, 43 insertions(+), 39 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex fa3685d91f046..8611c24fd57d1 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -41,6 +41,7 @@ void setup_ref_filter_porcelain_msg(void)\n \n typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;\n typedef enum { COMPARE_EQUAL, COMPARE_UNEQUAL, COMPARE_NONE } cmp_status;\n+typedef enum { SOURCE_NONE = 0, SOURCE_OBJ, SOURCE_OTHER } info_source;\n \n struct align {\n \talign_type position;\n@@ -73,6 +74,7 @@ struct refname_atom {\n static struct used_atom {\n \tconst char *name;\n \tcmp_type type;\n+\tinfo_source source;\n \tunion {\n \t\tchar color[COLOR_MAXLEN];\n \t\tstruct align align;\n@@ -380,49 +382,50 @@ static int head_atom_parser(const struct ref_format *format, struct used_atom *a\n \n static struct {\n \tconst char *name;\n+\tinfo_source source;\n \tcmp_type cmp_type;\n \tint (*parser)(const struct ref_format *format, struct used_atom *atom,\n \t\t      const char *arg, struct strbuf *err);\n } valid_atom[] = {\n-\t{ \"refname\" , FIELD_STR, refname_atom_parser },\n-\t{ \"objecttype\" },\n-\t{ \"objectsize\", FIELD_ULONG },\n-\t{ \"objectname\", FIELD_STR, objectname_atom_parser },\n-\t{ \"tree\" },\n-\t{ \"parent\" },\n-\t{ \"numparent\", FIELD_ULONG },\n-\t{ \"object\" },\n-\t{ \"type\" },\n-\t{ \"tag\" },\n-\t{ \"author\" },\n-\t{ \"authorname\" },\n-\t{ \"authoremail\" },\n-\t{ \"authordate\", FIELD_TIME },\n-\t{ \"committer\" },\n-\t{ \"committername\" },\n-\t{ \"committeremail\" },\n-\t{ \"committerdate\", FIELD_TIME },\n-\t{ \"tagger\" },\n-\t{ \"taggername\" },\n-\t{ \"taggeremail\" },\n-\t{ \"taggerdate\", FIELD_TIME },\n-\t{ \"creator\" },\n-\t{ \"creatordate\", FIELD_TIME },\n-\t{ \"subject\", FIELD_STR, subject_atom_parser },\n-\t{ \"body\", FIELD_STR, body_atom_parser },\n-\t{ \"trailers\", FIELD_STR, trailers_atom_parser },\n-\t{ \"contents\", FIELD_STR, contents_atom_parser },\n-\t{ \"upstream\", FIELD_STR, remote_ref_atom_parser },\n-\t{ \"push\", FIELD_STR, remote_ref_atom_parser },\n-\t{ \"symref\", FIELD_STR, refname_atom_parser },\n-\t{ \"flag\" },\n-\t{ \"HEAD\", FIELD_STR, head_atom_parser },\n-\t{ \"color\", FIELD_STR, color_atom_parser },\n-\t{ \"align\", FIELD_STR, align_atom_parser },\n-\t{ \"end\" },\n-\t{ \"if\", FIELD_STR, if_atom_parser },\n-\t{ \"then\" },\n-\t{ \"else\" },\n+\t{ \"refname\", SOURCE_NONE, FIELD_STR, refname_atom_parser },\n+\t{ \"objecttype\", SOURCE_OTHER },\n+\t{ \"objectsize\", SOURCE_OTHER, FIELD_ULONG },\n+\t{ \"objectname\", SOURCE_OTHER, FIELD_STR, objectname_atom_parser },\n+\t{ \"tree\", SOURCE_OBJ },\n+\t{ \"parent\", SOURCE_OBJ },\n+\t{ \"numparent\", SOURCE_OBJ, FIELD_ULONG },\n+\t{ \"object\", SOURCE_OBJ },\n+\t{ \"type\", SOURCE_OBJ },\n+\t{ \"tag\", SOURCE_OBJ },\n+\t{ \"author\", SOURCE_OBJ },\n+\t{ \"authorname\", SOURCE_OBJ },\n+\t{ \"authoremail\", SOURCE_OBJ },\n+\t{ \"authordate\", SOURCE_OBJ, FIELD_TIME },\n+\t{ \"committer\", SOURCE_OBJ },\n+\t{ \"committername\", SOURCE_OBJ },\n+\t{ \"committeremail\", SOURCE_OBJ },\n+\t{ \"committerdate\", SOURCE_OBJ, FIELD_TIME },\n+\t{ \"tagger\", SOURCE_OBJ },\n+\t{ \"taggername\", SOURCE_OBJ },\n+\t{ \"taggeremail\", SOURCE_OBJ },\n+\t{ \"taggerdate\", SOURCE_OBJ, FIELD_TIME },\n+\t{ \"creator\", SOURCE_OBJ },\n+\t{ \"creatordate\", SOURCE_OBJ, FIELD_TIME },\n+\t{ \"subject\", SOURCE_OBJ, FIELD_STR, subject_atom_parser },\n+\t{ \"body\", SOURCE_OBJ, FIELD_STR, body_atom_parser },\n+\t{ \"trailers\", SOURCE_OBJ, FIELD_STR, trailers_atom_parser },\n+\t{ \"contents\", SOURCE_OBJ, FIELD_STR, contents_atom_parser },\n+\t{ \"upstream\", SOURCE_NONE, FIELD_STR, remote_ref_atom_parser },\n+\t{ \"push\", SOURCE_NONE, FIELD_STR, remote_ref_atom_parser },\n+\t{ \"symref\", SOURCE_NONE, FIELD_STR, refname_atom_parser },\n+\t{ \"flag\", SOURCE_NONE },\n+\t{ \"HEAD\", SOURCE_NONE, FIELD_STR, head_atom_parser },\n+\t{ \"color\", SOURCE_NONE, FIELD_STR, color_atom_parser },\n+\t{ \"align\", SOURCE_NONE, FIELD_STR, align_atom_parser },\n+\t{ \"end\", SOURCE_NONE },\n+\t{ \"if\", SOURCE_NONE, FIELD_STR, if_atom_parser },\n+\t{ \"then\", SOURCE_NONE },\n+\t{ \"else\", SOURCE_NONE },\n };\n \n #define REF_FORMATTING_STATE_INIT  { 0, NULL }\n@@ -498,6 +501,7 @@ static int parse_ref_filter_atom(const struct ref_format *format,\n \tREALLOC_ARRAY(used_atom, used_atom_cnt);\n \tused_atom[at].name = xmemdupz(atom, ep - atom);\n \tused_atom[at].type = valid_atom[i].cmp_type;\n+\tused_atom[at].source = valid_atom[i].source;\n \tif (arg) {\n \t\targ = used_atom[at].name + (arg - atom) + 1;\n \t\tif (!*arg) {\n\n--\nhttps://github.com/git/git/pull/520\n"},{"id":"352750","messageId":"01020164a755d424-fc32ede3-5629-40f6-8b1d-12f306c0fe12-000000@eu-west-1.amazonses.com","threadId":"48894","inReplyTo":"01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 4/5] ref-filter: merge get_obj and get_object","fromName":"Olga Telezhnaya","fromEmail":"olyatelezhnaya@gmail.com","sentAt":"2018-07-17T08:22:57Z","receivedAt":"2018-07-17T08:23:05Z","isPatch":true,"sender":{"key":"olyatelezhnaya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11246099?v=4"},"body":"Inline get_obj(): it would be easier to edit the code\nwithout this split.\n\nSigned-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>\n---\n ref-filter.c | 36 +++++++++++-------------------------\n 1 file changed, 11 insertions(+), 25 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 8db7ca95b12c0..2b401a17c4689 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -797,24 +797,6 @@ int verify_ref_format(struct ref_format *format)\n \treturn 0;\n }\n \n-/*\n- * Given an object name, read the object data and size, and return a\n- * \"struct object\".  If the object data we are returning is also borrowed\n- * by the \"struct object\" representation, set *eaten as well---it is a\n- * signal from parse_object_buffer to us not to free the buffer.\n- */\n-static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)\n-{\n-\tenum object_type type;\n-\tvoid *buf = read_object_file(oid, &type, sz);\n-\n-\tif (buf)\n-\t\t*obj = parse_object_buffer(oid, type, *sz, buf, eaten);\n-\telse\n-\t\t*obj = NULL;\n-\treturn buf;\n-}\n-\n static int grab_objectname(const char *name, const struct object_id *oid,\n \t\t\t   struct atom_value *v, struct used_atom *atom)\n {\n@@ -1437,21 +1419,25 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re\n }\n \n static int get_object(struct ref_array_item *ref, const struct object_id *oid,\n-\t\t       int deref, struct object **obj, struct strbuf *err)\n+\t\t      int deref, struct object **obj, struct strbuf *err)\n {\n \t/* parse_object_buffer() will set eaten to 0 if free() will be needed */\n \tint eaten = 1;\n \tint ret = 0;\n \tunsigned long size;\n-\tvoid *buf = get_obj(oid, obj, &size, &eaten);\n+\tenum object_type type;\n+\tvoid *buf = read_object_file(oid, &type, &size);\n \tif (!buf)\n \t\tret = strbuf_addf_ret(err, -1, _(\"missing object %s for %s\"),\n \t\t\t\t      oid_to_hex(oid), ref->refname);\n-\telse if (!*obj)\n-\t\tret = strbuf_addf_ret(err, -1, _(\"parse_object_buffer failed on %s for %s\"),\n-\t\t\t\t      oid_to_hex(oid), ref->refname);\n-\telse\n-\t\tgrab_values(ref->value, deref, *obj, buf, size);\n+\telse {\n+\t\t*obj = parse_object_buffer(oid, type, size, buf, &eaten);\n+\t\tif (!*obj)\n+\t\t\tret = strbuf_addf_ret(err, -1, _(\"parse_object_buffer failed on %s for %s\"),\n+\t\t\t\t\t      oid_to_hex(oid), ref->refname);\n+\t\telse\n+\t\t\tgrab_values(ref->value, deref, *obj, buf, size);\n+\t}\n \tif (!eaten)\n \t\tfree(buf);\n \treturn ret;\n\n--\nhttps://github.com/git/git/pull/520\n"}]}