{"thread":{"id":"39687","subject":"[PATCH v4 00/11] add options to for-each-ref","startedAt":"2015-06-21T20:45:52Z","lastAt":"2015-06-23T11:05:38Z","messageCount":37,"participants":["Karthik Nayak","Junio C Hamano","Matthieu Moy","Eric Sunshine"],"isPatch":true,"patchVersion":4,"patchTotal":11},"messages":[{"id":"264458","messageId":"CAOLa=ZS_vn8ZNrb7mtqZKU4Y3RCZojcbeMYfbx=3X-aVjhdpSA@mail.gmail.com","threadId":"39687","inReplyTo":null,"subject":"[PATCH v4 00/11] add options to for-each-ref","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:45:52Z","receivedAt":"2015-06-21T20:45:52Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The previous version of the patch series can be found here :\nthread.gmane.org/gmane.comp.version-control.git/271754\n\nChanges in this version :\n*   01/11: Remove unnecessary tests and add signed tag.\n*   04/11: Grammatical change.\n*   06/11: Introduce a comment to explain code.\n*   11/11: Grammatical change.\n\nThanks to Matthieu for suggestions on the previous version\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264461","messageId":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"CAOLa=ZS_vn8ZNrb7mtqZKU4Y3RCZojcbeMYfbx=3X-aVjhdpSA@mail.gmail.com","subject":"[PATCH v4 01/19] t6301: for-each-ref tests for ref-filter APIs","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:15Z","receivedAt":"2015-06-21T20:48:15Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add a test suite for testing the ref-filter APIs used\nby for-each-ref. We just intialize the test suite for now.\nMore tests will be added in the following patches as more\noptions are added to for-each-ref.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n t/t6301-for-each-ref-filter.sh | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n create mode 100755 t/t6301-for-each-ref-filter.sh\n\ndiff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\nnew file mode 100755\nindex 0000000..b1fa8d4\n--- /dev/null\n+++ b/t/t6301-for-each-ref-filter.sh\n@@ -0,0 +1,19 @@\n+#!/bin/sh\n+\n+test_description='test for-each-refs usage of ref-filter APIs'\n+\n+. ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-gpg.sh\n+\n+test_expect_success 'setup some history and refs' '\n+\ttest_commit one &&\n+\ttest_commit two &&\n+\ttest_commit three &&\n+\tgit checkout -b side &&\n+\ttest_commit four &&\n+\tgit tag -s -m \"A signed tag message\" signed-tag &&\n+\tgit checkout master &&\n+\tgit update-ref refs/odd/spot master\n+'\n+\n+test_done\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264460","messageId":"1434919705-4884-2-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 02/19] tag: libify parse_opt_points_at()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:16Z","receivedAt":"2015-06-21T20:48:16Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Rename 'parse_opt_points_at()' to 'parse_opt_object_name()' and\nmove it from 'tag.c' to 'parse-options'. This now acts as a common\nparse_opt function which accepts an objectname and stores it into\na sha1_array.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/tag.c      | 21 ++-------------------\n parse-options-cb.c | 17 +++++++++++++++++\n parse-options.h    |  1 +\n 3 files changed, 20 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 5f6cdc5..e36c43e 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -546,23 +546,6 @@ static int strbuf_check_tag_ref(struct strbuf *sb, const char *name)\n \treturn check_refname_format(sb->buf, 0);\n }\n \n-static int parse_opt_points_at(const struct option *opt __attribute__((unused)),\n-\t\t\tconst char *arg, int unset)\n-{\n-\tunsigned char sha1[20];\n-\n-\tif (unset) {\n-\t\tsha1_array_clear(&points_at);\n-\t\treturn 0;\n-\t}\n-\tif (!arg)\n-\t\treturn error(_(\"switch 'points-at' requires an object\"));\n-\tif (get_sha1(arg, sha1))\n-\t\treturn error(_(\"malformed object name '%s'\"), arg);\n-\tsha1_array_append(&points_at, sha1);\n-\treturn 0;\n-}\n-\n static int parse_opt_sort(const struct option *opt, const char *arg, int unset)\n {\n \tint *sort = opt->value;\n@@ -625,8 +608,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n \t\t},\n \t\t{\n-\t\t\tOPTION_CALLBACK, 0, \"points-at\", NULL, N_(\"object\"),\n-\t\t\tN_(\"print only tags of the object\"), 0, parse_opt_points_at\n+\t\t\tOPTION_CALLBACK, 0, \"points-at\", &points_at, N_(\"object\"),\n+\t\t\tN_(\"print only tags of the object\"), 0, parse_opt_object_name\n \t\t},\n \t\tOPT_END()\n \t};\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex be8c413..de75411 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -4,6 +4,7 @@\n #include \"commit.h\"\n #include \"color.h\"\n #include \"string-list.h\"\n+#include \"sha1-array.h\"\n \n /*----- some often used options -----*/\n \n@@ -92,6 +93,22 @@ int parse_opt_with_commit(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n+int parse_opt_object_name(const struct option *opt, const char *arg, int unset)\n+{\n+\tunsigned char sha1[20];\n+\n+\tif (unset) {\n+\t\tsha1_array_clear(opt->value);\n+\t\treturn 0;\n+\t}\n+\tif (!arg)\n+\t\treturn -1;\n+\tif (get_sha1(arg, sha1))\n+\t\treturn error(_(\"malformed object name '%s'\"), arg);\n+\tsha1_array_append(opt->value, sha1);\n+\treturn 0;\n+}\n+\n int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)\n {\n \tint *target = opt->value;\ndiff --git a/parse-options.h b/parse-options.h\nindex c71e9da..36c71fe 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -220,6 +220,7 @@ extern int parse_opt_approxidate_cb(const struct option *, const char *, int);\n extern int parse_opt_expiry_date_cb(const struct option *, const char *, int);\n extern int parse_opt_color_flag_cb(const struct option *, const char *, int);\n extern int parse_opt_verbosity_cb(const struct option *, const char *, int);\n+extern int parse_opt_object_name(const struct option *, const char *, int);\n extern int parse_opt_with_commit(const struct option *, const char *, int);\n extern int parse_opt_tertiary(const struct option *, const char *, int);\n extern int parse_opt_string_list(const struct option *, const char *, int);\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264462","messageId":"1434919705-4884-3-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 03/19] ref-filter: implement '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:17Z","receivedAt":"2015-06-21T20:48:17Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 'tag -l' we have '--points-at' option which lets users\nlist only tags which point to a particular commit. Implement\nthis option in 'ref-filter.{c,h}' so that other commands can\nbenefit from this.\n\nThis is duplicated from tag.c, we will eventually remove that\nwhen we port tag.c to use ref-filter APIs.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/tag.c |  4 ++++\n ref-filter.c  | 26 ++++++++++++++++++++++++++\n ref-filter.h  |  1 +\n 3 files changed, 31 insertions(+)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex e36c43e..280981f 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -56,6 +56,10 @@ static int match_pattern(const char **patterns, const char *ref)\n \treturn 0;\n }\n \n+/*\n+ * This is currently duplicated in ref-filter.c, and will eventually be\n+ * removed as we port tag.c to use the ref-filter APIs.\n+ */\n static const unsigned char *match_points_at(const char *refname,\n \t\t\t\t\t    const unsigned char *sha1)\n {\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 43502a4..591e281 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -842,6 +842,29 @@ static int match_name_as_path(const char **pattern, const char *refname)\n \treturn 0;\n }\n \n+/*\n+ * Given a ref (sha1, refname) see if it points to a one of the sha1s\n+ * in a sha1_array.\n+ */\n+static int match_points_at(struct sha1_array *points_at, const unsigned char *sha1,\n+\t\t\t   const char *refname)\n+{\n+\tstruct object *obj;\n+\n+\tif (!points_at || !points_at->nr)\n+\t\treturn 1;\n+\n+\tif (sha1_array_lookup(points_at, sha1) >= 0)\n+\t\treturn 1;\n+\n+\tobj = parse_object_or_die(sha1, refname);\n+\tif (obj->type == OBJ_TAG &&\n+\t    sha1_array_lookup(points_at, ((struct tag *)obj)->tagged->sha1) >= 0)\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n /* Allocate space for a new ref_array_item and copy the objectname and flag to it */\n static struct ref_array_item *new_ref_array_item(const char *refname,\n \t\t\t\t\t\t const unsigned char *objectname,\n@@ -875,6 +898,9 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \tif (*filter->name_patterns && !match_name_as_path(filter->name_patterns, refname))\n \t\treturn 0;\n \n+\tif (!match_points_at(&filter->points_at, oid->hash, refname))\n+\t\treturn 0;\n+\n \t/*\n \t * We do not open the object yet; sort may only need refname\n \t * to do its job and the resulting list may yet to be pruned\ndiff --git a/ref-filter.h b/ref-filter.h\nindex 6997984..c2856b8 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -42,6 +42,7 @@ struct ref_array {\n \n struct ref_filter {\n \tconst char **name_patterns;\n+\tstruct sha1_array points_at;\n };\n \n struct ref_filter_cbdata {\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264464","messageId":"1434919705-4884-4-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:18Z","receivedAt":"2015-06-21T20:48:18Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add the '--points-at' option provided by 'ref-filter'. The\noption lets the user to pick only refs which point to a particular\ncommit.\n\nAdd documentation and tests for the same.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.txt |  3 +++\n builtin/for-each-ref.c             |  9 +++++++--\n t/t6301-for-each-ref-filter.sh     | 20 ++++++++++++++++++++\n 3 files changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex 7f8d9a5..0ede41d 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -10,6 +10,7 @@ SYNOPSIS\n [verse]\n 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n \t\t   [(--sort=<key>)...] [--format=<format>] [<pattern>...]\n+\t\t   [--points-at <object>]\n \n DESCRIPTION\n -----------\n@@ -62,6 +63,8 @@ OPTIONS\n \tthe specified host language.  This is meant to produce\n \ta scriptlet that can directly be `eval`ed.\n \n+--points-at <object>::\n+\tOnly list refs pointing to the given object.\n \n FIELD NAMES\n -----------\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 7919206..46f9b05 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -7,6 +7,7 @@\n \n static char const * const for_each_ref_usage[] = {\n \tN_(\"git for-each-ref [<options>] [<pattern>]\"),\n+\tN_(\"git for-each-ref [--points-at <object>]\"),\n \tNULL\n };\n \n@@ -34,9 +35,15 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(  0 , \"format\", &format, N_(\"format\"), N_(\"format to use for the output\")),\n \t\tOPT_CALLBACK(0 , \"sort\", sorting_tail, N_(\"key\"),\n \t\t\t    N_(\"field name to sort on\"), &parse_opt_ref_sorting),\n+\t\tOPT_CALLBACK(0, \"points-at\", &filter.points_at,\n+\t\t\t     N_(\"object\"), N_(\"print only refs pointing to the given object\"),\n+\t\t\t     parse_opt_object_name),\n \t\tOPT_END(),\n \t};\n \n+\tmemset(&array, 0, sizeof(array));\n+\tmemset(&filter, 0, sizeof(filter));\n+\n \tparse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);\n \tif (maxcount < 0) {\n \t\terror(\"invalid --count argument: `%d'\", maxcount);\n@@ -55,8 +62,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t/* for warn_ambiguous_refs */\n \tgit_config(git_default_config, NULL);\n \n-\tmemset(&array, 0, sizeof(array));\n-\tmemset(&filter, 0, sizeof(filter));\n \tfilter.name_patterns = argv;\n \tfilter_refs(&array, &filter, FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN);\n \tref_array_sort(sorting, &array);\ndiff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\nindex b1fa8d4..67de3a7 100755\n--- a/t/t6301-for-each-ref-filter.sh\n+++ b/t/t6301-for-each-ref-filter.sh\n@@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '\n \tgit update-ref refs/odd/spot master\n '\n \n+test_expect_success 'filtering with --points-at' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/heads/master\n+\trefs/odd/spot\n+\trefs/tags/three\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --points-at=master >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'check signed tags with --points-at' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/heads/side \n+\trefs/tags/four \n+\trefs/tags/signed-tag four\n+\tEOF\n+\tgit for-each-ref  --format=\"%(refname) %(*subject)\" --points-at=side >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264463","messageId":"1434919705-4884-5-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 05/19] ref-filter: add parse_opt_merge_filter()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:19Z","receivedAt":"2015-06-21T20:48:19Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add 'parse_opt_merge_filter()' to parse '--merged' and '--no-merged'\noptions and write MACROS for the same.\n\nThis is copied from 'builtin/branch.c' which will eventually be removed\nwhen we port 'branch.c' to use ref-filter APIs.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/branch.c |  4 ++++\n ref-filter.c     | 21 +++++++++++++++++++++\n ref-filter.h     | 11 +++++++++++\n 3 files changed, 36 insertions(+)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex b42e5b6..ddd90e6 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -745,6 +745,10 @@ static void rename_branch(const char *oldname, const char *newname, int force)\n \tstrbuf_release(&newsection);\n }\n \n+/*\n+ * This function is duplicated in ref-filter. It will eventually be removed\n+ * when we port branch.c to use ref-filter APIs.\n+ */\n static int opt_parse_merge_filter(const struct option *opt, const char *arg, int unset)\n {\n \tmerge_filter = ((opt->long_name[0] == 'n')\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 591e281..6502179 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1125,3 +1125,24 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)\n \ts->atom = parse_ref_filter_atom(arg, arg+len);\n \treturn 0;\n }\n+\n+int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n+{\n+\tstruct ref_filter *rf = opt->value;\n+\tunsigned char sha1[20];\n+\n+\trf->merge = starts_with(opt->long_name, \"no\")\n+\t\t? REF_FILTER_MERGED_OMIT\n+\t\t: REF_FILTER_MERGED_INCLUDE;\n+\n+\tif (!arg)\n+\t\targ = \"HEAD\";\n+\tif (get_sha1(arg, sha1))\n+\t\tdie(_(\"malformed object name %s\"), arg);\n+\n+\trf->merge_commit = lookup_commit_reference_gently(sha1, 0);\n+\tif (!rf->merge_commit)\n+\t\treturn opterror(opt, \"must point to a commit\", 0);\n+\n+\treturn 0;\n+}\ndiff --git a/ref-filter.h b/ref-filter.h\nindex c2856b8..ad2902b 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -50,6 +50,15 @@ struct ref_filter_cbdata {\n \tstruct ref_filter *filter;\n };\n \n+/*  Macros for checking --merged and --no-merged options */\n+#define _OPT_MERGED_NO_MERGED(option, filter, h)\t\t\t\t\\\n+\t{ OPTION_CALLBACK, 0, option, (filter), N_(\"commit\"), (h), \\\n+\t  PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG, \\\n+\t  parse_opt_merge_filter, (intptr_t) \"HEAD\" \\\n+\t}\n+#define OPT_MERGED(f, h) _OPT_MERGED_NO_MERGED(\"merged\", f, h)\n+#define OPT_NO_MERGED(f, h) _OPT_MERGED_NO_MERGED(\"no-merged\", f, h)\n+\n /*\n  * API for filtering a set of refs. Based on the type of refs the user\n  * has requested, we iterate through those refs and apply filters\n@@ -71,5 +80,7 @@ void show_ref_array_item(struct ref_array_item *info, const char *format, int qu\n int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset);\n /*  Default sort option based on refname */\n struct ref_sorting *ref_default_sorting(void);\n+/*  Function to parse --merged and --no-merged options */\n+int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset);\n \n #endif /*  REF_FILTER_H  */\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264465","messageId":"1434919705-4884-6-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 06/19] ref-filter: implement '--merged' and '--no-merged' options","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:20Z","receivedAt":"2015-06-21T20:48:20Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 'branch -l' we have '--merged' option which only lists refs (branches)\nmerged into the named commit and '--no-merged' option which only lists\nrefs (branches) not merged into the named commit. Implement these two\noptions in ref-filter.{c,h} so that other commands can benefit from this.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n ref-filter.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----\n ref-filter.h |  8 +++++++\n 2 files changed, 77 insertions(+), 4 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 6502179..d62fa63 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -9,6 +9,7 @@\n #include \"tag.h\"\n #include \"quote.h\"\n #include \"ref-filter.h\"\n+#include \"revision.h\"\n \n typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;\n \n@@ -889,6 +890,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \tstruct ref_filter_cbdata *ref_cbdata = cb_data;\n \tstruct ref_filter *filter = ref_cbdata->filter;\n \tstruct ref_array_item *ref;\n+\tstruct commit *commit = NULL;\n \n \tif (flag & REF_BAD_NAME) {\n \t\t  warning(\"ignoring ref with broken name %s\", refname);\n@@ -902,11 +904,23 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \t\treturn 0;\n \n \t/*\n+\t * A merge filter is applied on refs pointing to commits. Hence\n+\t * obtain the commit using the 'oid' available and discard all\n+\t * non-commits early. The actual filtering is done later.\n+\t */\n+\tif (filter->merge_commit) {\n+\t\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n+\t\tif (!commit)\n+\t\t\treturn 0;\n+\t}\n+\n+\t/*\n \t * We do not open the object yet; sort may only need refname\n \t * to do its job and the resulting list may yet to be pruned\n \t * by maxcount logic.\n \t */\n \tref = new_ref_array_item(refname, oid->hash, flag);\n+\tref->commit = commit;\n \n \tREALLOC_ARRAY(ref_cbdata->array->items, ref_cbdata->array->nr + 1);\n \tref_cbdata->array->items[ref_cbdata->array->nr++] = ref;\n@@ -932,6 +946,50 @@ void ref_array_clear(struct ref_array *array)\n \tarray->nr = array->alloc = 0;\n }\n \n+static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)\n+{\n+\tstruct rev_info revs;\n+\tint i, old_nr;\n+\tstruct ref_filter *filter = ref_cbdata->filter;\n+\tstruct ref_array *array = ref_cbdata->array;\n+\tstruct commit_list *p, *to_clear = NULL;\n+\n+\tinit_revisions(&revs, NULL);\n+\n+\tfor (i = 0; i < array->nr; i++) {\n+\t\tstruct ref_array_item *item = array->items[i];\n+\t\tadd_pending_object(&revs, &item->commit->object, item->refname);\n+\t\tcommit_list_insert(item->commit, &to_clear);\n+\t}\n+\n+\tfilter->merge_commit->object.flags |= UNINTERESTING;\n+\tadd_pending_object(&revs, &filter->merge_commit->object, \"\");\n+\n+\trevs.limited = 1;\n+\tif (prepare_revision_walk(&revs))\n+\t\tdie(_(\"revision walk setup failed\"));\n+\n+\told_nr = array->nr;\n+\tarray->nr = 0;\n+\n+\tfor (i = 0; i < old_nr; i++) {\n+\t\tstruct ref_array_item *item = array->items[i];\n+\t\tstruct commit *commit = item->commit;\n+\n+\t\tint is_merged = !!(commit->object.flags & UNINTERESTING);\n+\n+\t\tif (is_merged == (filter->merge == REF_FILTER_MERGED_INCLUDE))\n+\t\t\tarray->items[array->nr++] = array->items[i];\n+\t\telse\n+\t\t\tfree_array_item(item);\n+\t}\n+\n+\tfor (p = to_clear; p; p = p->next)\n+\t\tclear_commit_marks(p->item, ALL_REV_FLAGS);\n+\tclear_commit_marks(filter->merge_commit, ALL_REV_FLAGS);\n+\tfree_commit_list(to_clear);\n+}\n+\n /*\n  * API for filtering a set of refs. Based on the type of refs the user\n  * has requested, we iterate through those refs and apply filters\n@@ -941,17 +999,24 @@ void ref_array_clear(struct ref_array *array)\n int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type)\n {\n \tstruct ref_filter_cbdata ref_cbdata;\n+\tint ret = 0;\n \n \tref_cbdata.array = array;\n \tref_cbdata.filter = filter;\n \n+\t/*  Simple per-ref filtering */\n \tif (type & (FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN))\n-\t\treturn for_each_rawref(ref_filter_handler, &ref_cbdata);\n+\t\tret = for_each_rawref(ref_filter_handler, &ref_cbdata);\n \telse if (type & FILTER_REFS_ALL)\n-\t\treturn for_each_ref(ref_filter_handler, &ref_cbdata);\n-\telse\n+\t\tret = for_each_ref(ref_filter_handler, &ref_cbdata);\n+\telse if (type)\n \t\tdie(\"filter_refs: invalid type\");\n-\treturn 0;\n+\n+\t/*  Filters that need revision walking */\n+\tif (filter->merge_commit)\n+\t\tdo_merge_filter(&ref_cbdata);\n+\n+\treturn ret;\n }\n \n static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, struct ref_array_item *b)\ndiff --git a/ref-filter.h b/ref-filter.h\nindex ad2902b..7241a1d 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -31,6 +31,7 @@ struct ref_array_item {\n \tunsigned char objectname[20];\n \tint flag;\n \tconst char *symref;\n+\tstruct commit *commit;\n \tstruct atom_value *value;\n \tchar refname[FLEX_ARRAY];\n };\n@@ -43,6 +44,13 @@ struct ref_array {\n struct ref_filter {\n \tconst char **name_patterns;\n \tstruct sha1_array points_at;\n+\n+\tenum {\n+\t\tREF_FILTER_MERGED_NONE = 0,\n+\t\tREF_FILTER_MERGED_INCLUDE,\n+\t\tREF_FILTER_MERGED_OMIT\n+\t} merge;\n+\tstruct commit *merge_commit;\n };\n \n struct ref_filter_cbdata {\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264466","messageId":"1434919705-4884-7-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 07/19] for-each-ref: add '--merged' and '--no-merged' options","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:21Z","receivedAt":"2015-06-21T20:48:21Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add the '--merged' and '--no-merged' options provided by 'ref-filter'.\nThe '--merged' option lets the user to only list refs merged into the\nnamed commit. The '--no-merged' option lets the user to only list refs\nnot merged into the named commit.\n\nAdd documentation and tests for the same.\n\nBased-on-patch-by: Jeff King <peff@peff.net>\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.txt | 10 +++++++++-\n builtin/for-each-ref.c             |  3 +++\n t/t6301-for-each-ref-filter.sh     | 22 +++++++++++++++++-----\n 3 files changed, 29 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex 0ede41d..c6dcd99 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n [verse]\n 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n \t\t   [(--sort=<key>)...] [--format=<format>] [<pattern>...]\n-\t\t   [--points-at <object>]\n+\t\t   [--points-at <object>] [(--merged | --no-merged) <object>]\n \n DESCRIPTION\n -----------\n@@ -66,6 +66,14 @@ OPTIONS\n --points-at <object>::\n \tOnly list refs pointing to the given object.\n \n+--merged [<commit>]::\n+\tOnly list refs whose tips are reachable from the\n+\tspecified commit (HEAD if not specified).\n+\n+--no-merged [<commit>]::\n+\tOnly list refs whose tips are not reachable from the\n+\tspecified commit (HEAD if not specified).\n+\n FIELD NAMES\n -----------\n \ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 46f9b05..09d48da 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -8,6 +8,7 @@\n static char const * const for_each_ref_usage[] = {\n \tN_(\"git for-each-ref [<options>] [<pattern>]\"),\n \tN_(\"git for-each-ref [--points-at <object>]\"),\n+\tN_(\"git for-each-ref [(--merged | --no-merged) <object>]\"),\n \tNULL\n };\n \n@@ -38,6 +39,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\tOPT_CALLBACK(0, \"points-at\", &filter.points_at,\n \t\t\t     N_(\"object\"), N_(\"print only refs pointing to the given object\"),\n \t\t\t     parse_opt_object_name),\n+\t\tOPT_MERGED(&filter, N_(\"print only refs that are merged\")),\n+\t\tOPT_NO_MERGED(&filter, N_(\"print only refs that are not merged\")),\n \t\tOPT_END(),\n \t};\n \ndiff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\nindex 67de3a7..5b5cf04 100755\n--- a/t/t6301-for-each-ref-filter.sh\n+++ b/t/t6301-for-each-ref-filter.sh\n@@ -26,13 +26,25 @@ test_expect_success 'filtering with --points-at' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'check signed tags with --points-at' '\n+test_expect_success 'filtering with --merged' '\n \tcat >expect <<-\\EOF &&\n-\trefs/heads/side \n-\trefs/tags/four \n-\trefs/tags/signed-tag four\n+\trefs/heads/master\n+\trefs/odd/spot\n+\trefs/tags/one\n+\trefs/tags/three\n+\trefs/tags/two\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --merged=master >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'filtering with --no-merged' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/heads/side\n+\trefs/tags/four\n+\trefs/tags/signed-tag\n \tEOF\n-\tgit for-each-ref  --format=\"%(refname) %(*subject)\" --points-at=side >actual &&\n+\tgit for-each-ref --format=\"%(refname)\" --no-merged=master >actual &&\n \ttest_cmp expect actual\n '\n \n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264467","messageId":"1434919705-4884-8-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 08/19] parse-option: rename parse_opt_with_commit()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:22Z","receivedAt":"2015-06-21T20:48:22Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Rename parse_opt_with_commit() to parse_opt_commit_object_name()\nto show that it can be used to obtain a list of commits and is\nnot constricted to usage of '--contains' option.\n\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/branch.c   | 4 ++--\n builtin/tag.c      | 4 ++--\n parse-options-cb.c | 2 +-\n parse-options.h    | 2 +-\n 4 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex ddd90e6..ddd728e 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -828,13 +828,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\tOPTION_CALLBACK, 0, \"contains\", &with_commit, N_(\"commit\"),\n \t\t\tN_(\"print only branches that contain the commit\"),\n \t\t\tPARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n+\t\t\tparse_opt_commit_object_name, (intptr_t)\"HEAD\",\n \t\t},\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"with\", &with_commit, N_(\"commit\"),\n \t\t\tN_(\"print only branches that contain the commit\"),\n \t\t\tPARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_with_commit, (intptr_t) \"HEAD\",\n+\t\t\tparse_opt_commit_object_name, (intptr_t) \"HEAD\",\n \t\t},\n \t\tOPT__ABBREV(&abbrev),\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 280981f..2d6610a 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -603,13 +603,13 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\tOPTION_CALLBACK, 0, \"contains\", &with_commit, N_(\"commit\"),\n \t\t\tN_(\"print only tags that contain the commit\"),\n \t\t\tPARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n+\t\t\tparse_opt_commit_object_name, (intptr_t)\"HEAD\",\n \t\t},\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"with\", &with_commit, N_(\"commit\"),\n \t\t\tN_(\"print only tags that contain the commit\"),\n \t\t\tPARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n+\t\t\tparse_opt_commit_object_name, (intptr_t)\"HEAD\",\n \t\t},\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"points-at\", &points_at, N_(\"object\"),\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex de75411..8bec5e4 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -77,7 +77,7 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg,\n \treturn 0;\n }\n \n-int parse_opt_with_commit(const struct option *opt, const char *arg, int unset)\n+int parse_opt_commit_object_name(const struct option *opt, const char *arg, int unset)\n {\n \tunsigned char sha1[20];\n \tstruct commit *commit;\ndiff --git a/parse-options.h b/parse-options.h\nindex 36c71fe..8542d9c 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -221,7 +221,7 @@ extern int parse_opt_expiry_date_cb(const struct option *, const char *, int);\n extern int parse_opt_color_flag_cb(const struct option *, const char *, int);\n extern int parse_opt_verbosity_cb(const struct option *, const char *, int);\n extern int parse_opt_object_name(const struct option *, const char *, int);\n-extern int parse_opt_with_commit(const struct option *, const char *, int);\n+extern int parse_opt_commit_object_name(const struct option *, const char *, int);\n extern int parse_opt_tertiary(const struct option *, const char *, int);\n extern int parse_opt_string_list(const struct option *, const char *, int);\n extern int parse_opt_noop_cb(const struct option *, const char *, int);\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264468","messageId":"1434919705-4884-9-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 09/19] parse-options.h: add macros for '--contains' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:23Z","receivedAt":"2015-06-21T20:48:23Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add a macro for using the '--contains' option in parse-options.h\nalso include an optional '--with' option macro which performs the\nsame action as '--contains'.\n\nMake tag.c use this new macro.\n\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/tag.c   | 14 ++------------\n parse-options.h |  7 +++++++\n 2 files changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 2d6610a..767162e 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -595,23 +595,13 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \n \t\tOPT_GROUP(N_(\"Tag listing options\")),\n \t\tOPT_COLUMN(0, \"column\", &colopts, N_(\"show tag list in columns\")),\n+\t\tOPT_CONTAINS(&with_commit, N_(\"print only tags that contain the commit\")),\n+\t\tOPT_WITH(&with_commit, N_(\"print only tags that contain the commit\")),\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"sort\", &tag_sort, N_(\"type\"), N_(\"sort tags\"),\n \t\t\tPARSE_OPT_NONEG, parse_opt_sort\n \t\t},\n \t\t{\n-\t\t\tOPTION_CALLBACK, 0, \"contains\", &with_commit, N_(\"commit\"),\n-\t\t\tN_(\"print only tags that contain the commit\"),\n-\t\t\tPARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_commit_object_name, (intptr_t)\"HEAD\",\n-\t\t},\n-\t\t{\n-\t\t\tOPTION_CALLBACK, 0, \"with\", &with_commit, N_(\"commit\"),\n-\t\t\tN_(\"print only tags that contain the commit\"),\n-\t\t\tPARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,\n-\t\t\tparse_opt_commit_object_name, (intptr_t)\"HEAD\",\n-\t\t},\n-\t\t{\n \t\t\tOPTION_CALLBACK, 0, \"points-at\", &points_at, N_(\"object\"),\n \t\t\tN_(\"print only tags of the object\"), 0, parse_opt_object_name\n \t\t},\ndiff --git a/parse-options.h b/parse-options.h\nindex 8542d9c..2b555ff 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -243,5 +243,12 @@ extern int parse_opt_noop_cb(const struct option *, const char *, int);\n \tOPT_COLOR_FLAG(0, \"color\", (var), (h))\n #define OPT_COLUMN(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), N_(\"style\"), (h), PARSE_OPT_OPTARG, parseopt_column_callback }\n+#define _OPT_CONTAINS_OR_WITH(name, variable, help, flag)\t\t      \\\n+\t{ OPTION_CALLBACK, 0, name, (variable), N_(\"commit\"), (help), \\\n+\t  PARSE_OPT_LASTARG_DEFAULT | flag, \\\n+\t  parse_opt_commit_object_name, (intptr_t) \"HEAD\" \\\n+\t}\n+#define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, 0)\n+#define OPT_WITH(v, h) _OPT_CONTAINS_OR_WITH(\"with\", v, h, PARSE_OPT_HIDDEN)\n \n #endif\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264469","messageId":"1434919705-4884-10-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 10/19] ref-filter: implement '--contains' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:24Z","receivedAt":"2015-06-21T20:48:24Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"'tag -l' and 'branch -l' have two different ways of finding\nout if a certain ref contains a commit. Implement both these\nmethods in ref-filter and give the caller of ref-filter API\nthe option to pick which implementation to be used.\n\n'branch -l' uses 'is_descendant_of()' from commit.c which is\nleft as the default implementation to be used.\n\n'tag -l' uses a more specific algorithm since ffc4b80. This\nimplementation is used whenever the 'with_commit_tag_algo' bit\nis set in 'struct ref_filter'.\n\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n ref-filter.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n ref-filter.h |   3 ++\n 2 files changed, 116 insertions(+), 1 deletion(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex d62fa63..06f598b 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -818,6 +818,114 @@ static void get_ref_atom_value(struct ref_array_item *ref, int atom, struct atom\n \t*v = &ref->value[atom];\n }\n \n+enum contains_result {\n+\tCONTAINS_UNKNOWN = -1,\n+\tCONTAINS_NO = 0,\n+\tCONTAINS_YES = 1\n+};\n+\n+/*\n+ * Mimicking the real stack, this stack lives on the heap, avoiding stack\n+ * overflows.\n+ *\n+ * At each recursion step, the stack items points to the commits whose\n+ * ancestors are to be inspected.\n+ */\n+struct contains_stack {\n+\tint nr, alloc;\n+\tstruct contains_stack_entry {\n+\t\tstruct commit *commit;\n+\t\tstruct commit_list *parents;\n+\t} *contains_stack;\n+};\n+\n+static int in_commit_list(const struct commit_list *want, struct commit *c)\n+{\n+\tfor (; want; want = want->next)\n+\t\tif (!hashcmp(want->item->object.sha1, c->object.sha1))\n+\t\t\treturn 1;\n+\treturn 0;\n+}\n+\n+/*\n+ * Test whether the candidate or one of its parents is contained in the list.\n+ * Do not recurse to find out, though, but return -1 if inconclusive.\n+ */\n+static enum contains_result contains_test(struct commit *candidate,\n+\t\t\t    const struct commit_list *want)\n+{\n+\t/* was it previously marked as containing a want commit? */\n+\tif (candidate->object.flags & TMP_MARK)\n+\t\treturn 1;\n+\t/* or marked as not possibly containing a want commit? */\n+\tif (candidate->object.flags & UNINTERESTING)\n+\t\treturn 0;\n+\t/* or are we it? */\n+\tif (in_commit_list(want, candidate)) {\n+\t\tcandidate->object.flags |= TMP_MARK;\n+\t\treturn 1;\n+\t}\n+\n+\tif (parse_commit(candidate) < 0)\n+\t\treturn 0;\n+\n+\treturn -1;\n+}\n+\n+static void push_to_contains_stack(struct commit *candidate, struct contains_stack *contains_stack)\n+{\n+\tALLOC_GROW(contains_stack->contains_stack, contains_stack->nr + 1, contains_stack->alloc);\n+\tcontains_stack->contains_stack[contains_stack->nr].commit = candidate;\n+\tcontains_stack->contains_stack[contains_stack->nr++].parents = candidate->parents;\n+}\n+\n+static enum contains_result contains_tag_algo(struct commit *candidate,\n+\t\tconst struct commit_list *want)\n+{\n+\tstruct contains_stack contains_stack = { 0, 0, NULL };\n+\tint result = contains_test(candidate, want);\n+\n+\tif (result != CONTAINS_UNKNOWN)\n+\t\treturn result;\n+\n+\tpush_to_contains_stack(candidate, &contains_stack);\n+\twhile (contains_stack.nr) {\n+\t\tstruct contains_stack_entry *entry = &contains_stack.contains_stack[contains_stack.nr - 1];\n+\t\tstruct commit *commit = entry->commit;\n+\t\tstruct commit_list *parents = entry->parents;\n+\n+\t\tif (!parents) {\n+\t\t\tcommit->object.flags |= UNINTERESTING;\n+\t\t\tcontains_stack.nr--;\n+\t\t}\n+\t\t/*\n+\t\t * If we just popped the stack, parents->item has been marked,\n+\t\t * therefore contains_test will return a meaningful 0 or 1.\n+\t\t */\n+\t\telse switch (contains_test(parents->item, want)) {\n+\t\tcase CONTAINS_YES:\n+\t\t\tcommit->object.flags |= TMP_MARK;\n+\t\t\tcontains_stack.nr--;\n+\t\t\tbreak;\n+\t\tcase CONTAINS_NO:\n+\t\t\tentry->parents = parents->next;\n+\t\t\tbreak;\n+\t\tcase CONTAINS_UNKNOWN:\n+\t\t\tpush_to_contains_stack(parents->item, &contains_stack);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tfree(contains_stack.contains_stack);\n+\treturn contains_test(candidate, want);\n+}\n+\n+static int commit_contains(struct ref_filter *filter, struct commit *commit)\n+{\n+\tif (filter->with_commit_tag_algo)\n+\t\treturn contains_tag_algo(commit, filter->with_commit);\n+\treturn is_descendant_of(commit, filter->with_commit);\n+}\n+\n /*\n  * Return 1 if the refname matches one of the patterns, otherwise 0.\n  * A pattern can be path prefix (e.g. a refname \"refs/heads/master\"\n@@ -908,10 +1016,14 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,\n \t * obtain the commit using the 'oid' available and discard all\n \t * non-commits early. The actual filtering is done later.\n \t */\n-\tif (filter->merge_commit) {\n+\tif (filter->merge_commit || filter->with_commit) {\n \t\tcommit = lookup_commit_reference_gently(oid->hash, 1);\n \t\tif (!commit)\n \t\t\treturn 0;\n+\t\t/* We perform the filtering for the '--contains' option */\n+\t\tif (filter->with_commit &&\n+\t\t    !commit_contains(filter, commit))\n+\t\t\treturn 0;\n \t}\n \n \t/*\ndiff --git a/ref-filter.h b/ref-filter.h\nindex 7241a1d..3c59431 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -44,6 +44,7 @@ struct ref_array {\n struct ref_filter {\n \tconst char **name_patterns;\n \tstruct sha1_array points_at;\n+\tstruct commit_list *with_commit;\n \n \tenum {\n \t\tREF_FILTER_MERGED_NONE = 0,\n@@ -51,6 +52,8 @@ struct ref_filter {\n \t\tREF_FILTER_MERGED_OMIT\n \t} merge;\n \tstruct commit *merge_commit;\n+\n+\tunsigned int with_commit_tag_algo: 1;\n };\n \n struct ref_filter_cbdata {\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264470","messageId":"1434919705-4884-11-git-send-email-karthik.188@gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-1-git-send-email-karthik.188@gmail.com","subject":"[PATCH v4 11/19] for-each-ref: add '--contains' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:48:25Z","receivedAt":"2015-06-21T20:48:25Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add the '--contains' option provided by 'ref-filter'. The '--contains'\noption lists only refs which contain the mentioned commit (HEAD if no\ncommit is explicitly given).\n\nAdd documentation and tests for the same.\n\nMentored-by: Christian Couder <christian.couder@gmail.com>\nMentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/git-for-each-ref.txt |  5 +++++\n builtin/for-each-ref.c             |  2 ++\n t/t6301-for-each-ref-filter.sh     | 14 ++++++++++++++\n 3 files changed, 21 insertions(+)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex c6dcd99..42d53fc 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -11,6 +11,7 @@ SYNOPSIS\n 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n \t\t   [(--sort=<key>)...] [--format=<format>] [<pattern>...]\n \t\t   [--points-at <object>] [(--merged | --no-merged) <object>]\n+\t\t   [--contains <object>]\n \n DESCRIPTION\n -----------\n@@ -74,6 +75,10 @@ OPTIONS\n \tOnly list refs whose tips are not reachable from the\n \tspecified commit (HEAD if not specified).\n \n+--contains [<commit>]::\n+\tOnly list tags which contain the specified commit (HEAD if not\n+\tspecified).\n+\n FIELD NAMES\n -----------\n \ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 09d48da..6819f39 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -9,6 +9,7 @@ static char const * const for_each_ref_usage[] = {\n \tN_(\"git for-each-ref [<options>] [<pattern>]\"),\n \tN_(\"git for-each-ref [--points-at <object>]\"),\n \tN_(\"git for-each-ref [(--merged | --no-merged) <object>]\"),\n+\tN_(\"git for-each-ref [--contains <object>]\"),\n \tNULL\n };\n \n@@ -41,6 +42,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\t\t     parse_opt_object_name),\n \t\tOPT_MERGED(&filter, N_(\"print only refs that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only refs that are not merged\")),\n+\t\tOPT_CONTAINS(&filter.with_commit, N_(\"print only refs which contain the commit\")),\n \t\tOPT_END(),\n \t};\n \ndiff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\nindex 5b5cf04..d143fba 100755\n--- a/t/t6301-for-each-ref-filter.sh\n+++ b/t/t6301-for-each-ref-filter.sh\n@@ -48,4 +48,18 @@ test_expect_success 'filtering with --no-merged' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'filtering with --contains' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/heads/master\n+\trefs/heads/side\n+\trefs/odd/spot\n+\trefs/tags/four\n+\trefs/tags/signed-tag\n+\trefs/tags/three\n+\trefs/tags/two\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --contains=two >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.4.3.439.gfea0c2a.dirty\n"},{"id":"264471","messageId":"CAOLa=ZRLzTm1nW+JMUTqGgZ_H25A53NyHNVnH-Fd7GuBgrH+vA@mail.gmail.com","threadId":"39687","inReplyTo":"CAOLa=ZS_vn8ZNrb7mtqZKU4Y3RCZojcbeMYfbx=3X-aVjhdpSA@mail.gmail.com","subject":"Re: [PATCH v4 00/11] add options to for-each-ref","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-21T20:51:48Z","receivedAt":"2015-06-21T20:51:48Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 2:15 AM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> The previous version of the patch series can be found here :\n> thread.gmane.org/gmane.comp.version-control.git/271754\n>\n> Changes in this version :\n> *   01/11: Remove unnecessary tests and add signed tag.\n> *   04/11: Grammatical change.\n> *   06/11: Introduce a comment to explain code.\n> *   11/11: Grammatical change.\n>\n> Thanks to Matthieu for suggestions on the previous version\n>\n\nThe patches end at No 11. Even though they show XY/19.\nI have more uncooked patches on my branch, which I'll eventually send\nto the list.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264482","messageId":"CAPc5daX6=LugA6n9DFWXxfJG-K_js73JSON7S6xbDrKWNA6Vvg@mail.gmail.com","threadId":"39687","inReplyTo":"CAOLa=ZRLzTm1nW+JMUTqGgZ_H25A53NyHNVnH-Fd7GuBgrH+vA@mail.gmail.com","subject":"Re: [PATCH v4 00/11] add options to for-each-ref","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T00:41:38Z","receivedAt":"2015-06-22T00:41:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Sun, Jun 21, 2015 at 1:51 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> On Mon, Jun 22, 2015 at 2:15 AM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>> The previous version of the patch series can be found here :\n>> thread.gmane.org/gmane.comp.version-control.git/271754\n>>\n>> Changes in this version :\n>> *   01/11: Remove unnecessary tests and add signed tag.\n>> *   04/11: Grammatical change.\n>> *   06/11: Introduce a comment to explain code.\n>> *   11/11: Grammatical change.\n>>\n>> Thanks to Matthieu for suggestions on the previous version\n>>\n>\n> The patches end at No 11. Even though they show XY/19.\n> I have more uncooked patches on my branch, which I'll eventually send\n> to the list.\n\nJust FYI, you can \"git format-patch -11 my-work~8\" or something like that\nand get 01/11 to 11/11 even if you have more commits that are not yet ready\nnear the tip.\n"},{"id":"264483","messageId":"CAPc5daVNapbjAHwiUq5PXfCnWii4Cs1v6dvDAGFfnVkAJhFZnA@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-4-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T00:45:56Z","receivedAt":"2015-06-22T00:45:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":" 3 & 4 as a single patch may make more sense, if we were to tolerate the\n\"let's copy & paste first and then later remove the duplicate\" as a way to\npostpone touching \"tag.c\" side in order to first concentrate on for-each-ref.\n\nI have not formed a firm opinion on what the right split of the series is, but\nso far (assuming that the temporary duplication is the best we can do) what\nI am seeing in this series makes sense to me.\n\nThanks.\n"},{"id":"264484","messageId":"CAPc5daUkHb5sQ_d-g0EeFwXTkFUf4=PVV=QcV-nekObKSJL27g@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-5-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 05/19] ref-filter: add parse_opt_merge_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T00:55:01Z","receivedAt":"2015-06-22T00:55:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> Add 'parse_opt_merge_filter()' to parse '--merged' and '--no-merged'\n> options and write MACROS for the same.\n\nWhy SHOUT here?\n\n>\n> This is copied from 'builtin/branch.c' which will eventually be removed\n> when we port 'branch.c' to use ref-filter APIs.\n\nHmph. I somehow thought Matthieu's instruction was to finish tag.c\nside first and then\ndo branch (i.e. with 3 and 4 you brought things from tag to\nfor-each-ref, now it is a time\nto rewrite tag by using what you wrote for for-each-ref with 3 and 4,\nbefore moving to\nthis patch)? Was that plan scrapped or found inappropriate or something?\n\n> +int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)\n> +{\n> +       struct ref_filter *rf = opt->value;\n> +       unsigned char sha1[20];\n> +\n> +       rf->merge = starts_with(opt->long_name, \"no\")\n> +               ? REF_FILTER_MERGED_OMIT\n> +               : REF_FILTER_MERGED_INCLUDE;\n> +\n> +       if (!arg)\n> +               arg = \"HEAD\";\n\nWhen does this trigger? You have lastarg-default with \"HEAD\", and I am\nhaving trouble guessing when \"arg\" upon entry to this function can ever\nbe NULL.\n\n> +       if (get_sha1(arg, sha1))\n> +               die(_(\"malformed object name %s\"), arg);\n> +\n> +       rf->merge_commit = lookup_commit_reference_gently(sha1, 0);\n\nCan --merged (or --no-merged) be given more than once? Is the rule\n\"the last one wins\"?\nDoes the old value of rf->merge_commit leak (no, it does not, but I am\njust asking for\ncompleteness)?\n"},{"id":"264485","messageId":"CAPc5daVtMjv=shHhnnR=_p37ND9-64MV-wrsfQA9p2OQ0DbZUA@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-6-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 06/19] ref-filter: implement '--merged' and '--no-merged' options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T01:00:52Z","receivedAt":"2015-06-22T01:00:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> +static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)\n> +{\n> +       struct rev_info revs;\n> +       int i, old_nr;\n> +       struct ref_filter *filter = ref_cbdata->filter;\n> +       struct ref_array *array = ref_cbdata->array;\n> +       struct commit_list *p, *to_clear = NULL;\n> +\n> +       init_revisions(&revs, NULL);\n> +\n> +       for (i = 0; i < array->nr; i++) {\n> +               struct ref_array_item *item = array->items[i];\n> +               add_pending_object(&revs, &item->commit->object, item->refname);\n> +               commit_list_insert(item->commit, &to_clear);\n\nUse of commit_list for an array of known number of commits feels somewhat\nwasteful. Couldn't to_clear be\n\n    struct commit **to_clear = xcalloc(sizeof(struct commit *), array->nr);\n\ninstread?\n"},{"id":"264486","messageId":"CAPc5daVpqDC4K6ne=E_cdzG0NhfEYLucWdxVwKMf9WtDxzPUnA@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-8-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 08/19] parse-option: rename parse_opt_with_commit()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T01:04:52Z","receivedAt":"2015-06-22T01:04:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> Rename parse_opt_with_commit() to parse_opt_commit_object_name()\n> to show that it can be used to obtain a list of commits and is\n> not constricted to usage of '--contains' option.\n\nI think that is a brilliant idea, but unlike the other function you\nadded earlier\nthat can do only one object and adopts \"last one wins\" rule, this is cumulative,\nand that fact should be made clear to the developers in some way, no?\n"},{"id":"264505","messageId":"vpq381kc7y6.fsf@anie.imag.fr","threadId":"39687","inReplyTo":"CAPc5daUkHb5sQ_d-g0EeFwXTkFUf4=PVV=QcV-nekObKSJL27g@mail.gmail.com","subject":"Re: [PATCH v4 05/19] ref-filter: add parse_opt_merge_filter()","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-22T11:13:05Z","receivedAt":"2015-06-22T11:13:05Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> This is copied from 'builtin/branch.c' which will eventually be removed\n>> when we port 'branch.c' to use ref-filter APIs.\n>\n> Hmph. I somehow thought Matthieu's instruction was to finish tag.c\n> side first\n\nI would call in \"advice\" rather than \"instruction\". I still think we\nshould prioritize the tag.c side, but if this patch is ready, it makes\nsense to keep it in the series.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"264540","messageId":"CAOLa=ZSCTMoEwL8GmUn4fRygpfA6_gNKE0K7pTbiy4++saQrDw@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daX6=LugA6n9DFWXxfJG-K_js73JSON7S6xbDrKWNA6Vvg@mail.gmail.com","subject":"Re: [PATCH v4 00/11] add options to for-each-ref","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T14:48:29Z","receivedAt":"2015-06-22T14:48:29Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":">\n> Just FYI, you can \"git format-patch -11 my-work~8\" or something like that\n> and get 01/11 to 11/11 even if you have more commits that are not yet ready\n> near the tip.\n\nI usually do a `git format-patch a..b` but I missed out the b it seems ;-)\nThanks!\n\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264542","messageId":"CAOLa=ZR3jyxTTKJ=cCWGhW80WHqcHx3Z2bBunzpUbhug-E1oew@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daVtMjv=shHhnnR=_p37ND9-64MV-wrsfQA9p2OQ0DbZUA@mail.gmail.com","subject":"Re: [PATCH v4 06/19] ref-filter: implement '--merged' and '--no-merged' options","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T15:11:52Z","receivedAt":"2015-06-22T15:11:52Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 6:30 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>> +static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)\n>> +{\n>> +       struct rev_info revs;\n>> +       int i, old_nr;\n>> +       struct ref_filter *filter = ref_cbdata->filter;\n>> +       struct ref_array *array = ref_cbdata->array;\n>> +       struct commit_list *p, *to_clear = NULL;\n>> +\n>> +       init_revisions(&revs, NULL);\n>> +\n>> +       for (i = 0; i < array->nr; i++) {\n>> +               struct ref_array_item *item = array->items[i];\n>> +               add_pending_object(&revs, &item->commit->object, item->refname);\n>> +               commit_list_insert(item->commit, &to_clear);\n>\n> Use of commit_list for an array of known number of commits feels somewhat\n> wasteful. Couldn't to_clear be\n>\n>     struct commit **to_clear = xcalloc(sizeof(struct commit *), array->nr);\n>\n> instread?\n\nAwesome! you're right, will drop the commit_list.\n"},{"id":"264564","messageId":"CAOLa=ZQZ763F9AFpkGZ-ay2_q_3YCYXMuf_gYg-sQd=N-kyebA@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daVpqDC4K6ne=E_cdzG0NhfEYLucWdxVwKMf9WtDxzPUnA@mail.gmail.com","subject":"Re: [PATCH v4 08/19] parse-option: rename parse_opt_with_commit()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T15:38:41Z","receivedAt":"2015-06-22T15:38:41Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 6:34 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>> Rename parse_opt_with_commit() to parse_opt_commit_object_name()\n>> to show that it can be used to obtain a list of commits and is\n>> not constricted to usage of '--contains' option.\n>\n> I think that is a brilliant idea, but unlike the other function you\n> added earlier\n> that can do only one object and adopts \"last one wins\" rule, this is cumulative,\n> and that fact should be made clear to the developers in some way, no?\n\nWill add a comment :) Thanks!\n\n\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264568","messageId":"xmqqmvzriusp.fsf@gitster.dls.corp.google.com","threadId":"39687","inReplyTo":"vpq381kc7y6.fsf@anie.imag.fr","subject":"Re: [PATCH v4 05/19] ref-filter: add parse_opt_merge_filter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T16:15:18Z","receivedAt":"2015-06-22T16:15:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>>> This is copied from 'builtin/branch.c' which will eventually be removed\n>>> when we port 'branch.c' to use ref-filter APIs.\n>>\n>> Hmph. I somehow thought Matthieu's instruction was to finish tag.c\n>> side first\n>\n> I would call in \"advice\" rather than \"instruction\". \n\nHmph, the choice of the word came from my understanding that a\n\"mentor\" is like a \"teacher\", but \"advice\" is fine by me ;-)\n\n> I still think we\n> should prioritize the tag.c side, but if this patch is ready, it makes\n> sense to keep it in the series.\n\nOK.\n"},{"id":"264569","messageId":"CAPc5daUWFx0YDHfRJynCiw7cBwDrDzyrY_TNDDBaDCVCDJb3ag@mail.gmail.com","threadId":"39687","inReplyTo":"CAOLa=ZQZ763F9AFpkGZ-ay2_q_3YCYXMuf_gYg-sQd=N-kyebA@mail.gmail.com","subject":"Re: [PATCH v4 08/19] parse-option: rename parse_opt_with_commit()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T16:27:02Z","receivedAt":"2015-06-22T16:27:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Mon, Jun 22, 2015 at 8:38 AM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> On Mon, Jun 22, 2015 at 6:34 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>>> Rename parse_opt_with_commit() to parse_opt_commit_object_name()\n>>> to show that it can be used to obtain a list of commits and is\n>>> not constricted to usage of '--contains' option.\n>>\n>> I think that is a brilliant idea, but unlike the other function you\n>> added earlier\n>> that can do only one object and adopts \"last one wins\" rule, this is cumulative,\n>> and that fact should be made clear to the developers in some way, no?\n>\n> Will add a comment\n\nI didn't mean that. Can't we indicate this with plural somewhere in the name?\nparse_opt_commits(), parse_opt_commit_into_list(), etc.?\n"},{"id":"264570","messageId":"CAOLa=ZQ1s01vzwwSToocr1-SBESTv1zYAVB=BKWdqz6SF7fSeA@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daUWFx0YDHfRJynCiw7cBwDrDzyrY_TNDDBaDCVCDJb3ag@mail.gmail.com","subject":"Re: [PATCH v4 08/19] parse-option: rename parse_opt_with_commit()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T16:37:41Z","receivedAt":"2015-06-22T16:37:41Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 9:57 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> On Mon, Jun 22, 2015 at 8:38 AM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>> On Mon, Jun 22, 2015 at 6:34 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> On Sun, Jun 21, 2015 at 1:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>>>> Rename parse_opt_with_commit() to parse_opt_commit_object_name()\n>>>> to show that it can be used to obtain a list of commits and is\n>>>> not constricted to usage of '--contains' option.\n>>>\n>>> I think that is a brilliant idea, but unlike the other function you\n>>> added earlier\n>>> that can do only one object and adopts \"last one wins\" rule, this is cumulative,\n>>> and that fact should be made clear to the developers in some way, no?\n>>\n>> Will add a comment\n>\n> I didn't mean that. Can't we indicate this with plural somewhere in the name?\n> parse_opt_commits(), parse_opt_commit_into_list(), etc.?\n\nDefinitely! thanks :)\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264575","messageId":"CAOLa=ZR9=2RUhtN=mC2u78vin0hGcmD8fL450ygAX6N9A4Yq8A@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daUkHb5sQ_d-g0EeFwXTkFUf4=PVV=QcV-nekObKSJL27g@mail.gmail.com","subject":"Re: [PATCH v4 05/19] ref-filter: add parse_opt_merge_filter()","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T19:00:30Z","receivedAt":"2015-06-22T19:00:30Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 6:25 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Why SHOUT here?\n>\n\nJust used to typing \"macros\" in caps. Will change!\n\n>> This is copied from 'builtin/branch.c' which will eventually be removed\n>> when we port 'branch.c' to use ref-filter APIs.\n>\n> Hmph. I somehow thought Matthieu's instruction was to finish tag.c\n> side first and then\n> do branch (i.e. with 3 and 4 you brought things from tag to\n> for-each-ref, now it is a time\n> to rewrite tag by using what you wrote for for-each-ref with 3 and 4,\n> before moving to\n> this patch)? Was that plan scrapped or found inappropriate or something?\n>\n\n> I would call in \"advice\" rather than \"instruction\". I still think we\n> should prioritize the tag.c side, but if this patch is ready, it makes\n> sense to keep it in the series.\n\nYes, Matthieu did advice that.\nBut I had already started working on this. But if you guys think thats\na better option\nI can do that also, as I already have tag.c ported over to use\nref-filter on my local branch.\nBut that'll include a lot of changes.\n\nAlso I found this more systematic as we will have a complete\nref-filter library ready and\nonly porting of tag.c and branch.c would be left.\n\n>\n> When does this trigger? You have lastarg-default with \"HEAD\", and I am\n> having trouble guessing when \"arg\" upon entry to this function can ever\n> be NULL.\n>\n\nThis is redundant. will remove.\n\n>\n> Can --merged (or --no-merged) be given more than once? Is the rule\n> \"the last one wins\"?\n> Does the old value of rf->merge_commit leak (no, it does not, but I am\n> just asking for\n> completeness)?\n\nYes! currently for e.g. `git for-each-ref --merged master --merged ref_filter`\nwould mean that ref_filter would be considered for the --merge option.\n\n\"Does the old value of rf->merge_commit leak\" From my understanding of\nobject.c/commit.c, It just points to an object in the obj_hash array, so when\nmultiple options are given the pointer just points to another part of obj_hash,\nI'm sure there's more to it. This is what I gathered from an over the top view.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264576","messageId":"CAOLa=ZSd8KftLrRHBXY7Ch2KpVuFSb2DzCq0eLibAx1+bR9M1Q@mail.gmail.com","threadId":"39687","inReplyTo":"CAPc5daVNapbjAHwiUq5PXfCnWii4Cs1v6dvDAGFfnVkAJhFZnA@mail.gmail.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T19:03:40Z","receivedAt":"2015-06-22T19:03:40Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>  3 & 4 as a single patch may make more sense, if we were to tolerate the\n> \"let's copy & paste first and then later remove the duplicate\" as a way to\n> postpone touching \"tag.c\" side in order to first concentrate on for-each-ref.\n>\n> I have not formed a firm opinion on what the right split of the series is, but\n> so far (assuming that the temporary duplication is the best we can do) what\n> I am seeing in this series makes sense to me.\n>\n> Thanks.\n\nThat would mean squashing 3&4, 6&7 and 10&11 also on similar lines.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264577","messageId":"vpqpp4nblc2.fsf@anie.imag.fr","threadId":"39687","inReplyTo":"CAOLa=ZSd8KftLrRHBXY7Ch2KpVuFSb2DzCq0eLibAx1+bR9M1Q@mail.gmail.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-22T19:21:33Z","receivedAt":"2015-06-22T19:21:33Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>  3 & 4 as a single patch may make more sense, if we were to tolerate the\n>> \"let's copy & paste first and then later remove the duplicate\" as a way to\n>> postpone touching \"tag.c\" side in order to first concentrate on for-each-ref.\n>>\n>> I have not formed a firm opinion on what the right split of the series is, but\n>> so far (assuming that the temporary duplication is the best we can do) what\n>> I am seeing in this series makes sense to me.\n>>\n>> Thanks.\n>\n> That would mean squashing 3&4, 6&7 and 10&11 also on similar lines.\n\nI have a slight preference for keeping the pairs not squashed. This way,\nwe have a clear separation \"write reusable library code\" / \"use it\". But\nI'm fine with squashing if others prefer.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"264578","messageId":"xmqq7fqvh7g6.fsf@gitster.dls.corp.google.com","threadId":"39687","inReplyTo":"vpqpp4nblc2.fsf@anie.imag.fr","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T19:24:57Z","receivedAt":"2015-06-22T19:24:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>  3 & 4 as a single patch may make more sense, if we were to tolerate the\n>>> \"let's copy & paste first and then later remove the duplicate\" as a way to\n>>> postpone touching \"tag.c\" side in order to first concentrate on for-each-ref.\n>>>\n>>> I have not formed a firm opinion on what the right split of the series is, but\n>>> so far (assuming that the temporary duplication is the best we can do) what\n>>> I am seeing in this series makes sense to me.\n>>>\n>>> Thanks.\n>>\n>> That would mean squashing 3&4, 6&7 and 10&11 also on similar lines.\n>\n> I have a slight preference for keeping the pairs not squashed. This way,\n> we have a clear separation \"write reusable library code\" / \"use it\". But\n> I'm fine with squashing if others prefer.\n\nAs I cannot firmly say that \"copy & paste first and then later\nclean-up\" is bad and we should split them in different way, I\nam fine with leaving them separate as they are.\n"},{"id":"264579","messageId":"CAOLa=ZRTn34K8j5dVKm1szfc6UBUvjR-a9f9cQSc25KnUMZ39Q@mail.gmail.com","threadId":"39687","inReplyTo":"xmqq7fqvh7g6.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-22T19:27:10Z","receivedAt":"2015-06-22T19:27:10Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Tue, Jun 23, 2015 at 12:54 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> Karthik Nayak <karthik.188@gmail.com> writes:\n>>\n>>> On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>>  3 & 4 as a single patch may make more sense, if we were to tolerate the\n>>>> \"let's copy & paste first and then later remove the duplicate\" as a way to\n>>>> postpone touching \"tag.c\" side in order to first concentrate on for-each-ref.\n>>>>\n>>>> I have not formed a firm opinion on what the right split of the series is, but\n>>>> so far (assuming that the temporary duplication is the best we can do) what\n>>>> I am seeing in this series makes sense to me.\n>>>>\n>>>> Thanks.\n>>>\n>>> That would mean squashing 3&4, 6&7 and 10&11 also on similar lines.\n>>\n>> I have a slight preference for keeping the pairs not squashed. This way,\n>> we have a clear separation \"write reusable library code\" / \"use it\". But\n>> I'm fine with squashing if others prefer.\n>\n> As I cannot firmly say that \"copy & paste first and then later\n> clean-up\" is bad and we should split them in different way, I\n> am fine with leaving them separate as they are.\n\nEven I think it's better to leave them separate, on the lines of what\nMatthieu said.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264581","messageId":"xmqqy4jbfrmr.fsf@gitster.dls.corp.google.com","threadId":"39687","inReplyTo":"xmqq7fqvh7g6.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-22T19:51:56Z","receivedAt":"2015-06-22T19:51:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> I have a slight preference for keeping the pairs not squashed. This way,\n>> we have a clear separation \"write reusable library code\" / \"use it\". But\n>> I'm fine with squashing if others prefer.\n>\n> As I cannot firmly say that \"copy & paste first and then later\n> clean-up\" is bad and we should split them in different way, I\n> am fine with leaving them separate as they are.\n\nHaving said that, I have a slight preference that a split does not\nbreak my build in the middle of the series by introducing an\nunused function, which is noticed by the compiler as a warning, and\nturned into an error with -Werror.\n"},{"id":"264602","messageId":"CAPig+cRGWG=L0JmSEtnxAyV=NTsq281Ot7E85HB4buDnMPHc1Q@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-3-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 03/19] ref-filter: implement '--points-at' option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-22T22:36:27Z","receivedAt":"2015-06-22T22:36:27Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> In 'tag -l' we have '--points-at' option which lets users\n> list only tags which point to a particular commit. Implement\n> this option in 'ref-filter.{c,h}' so that other commands can\n> benefit from this.\n>\n> This is duplicated from tag.c, we will eventually remove that\n> when we port tag.c to use ref-filter APIs.\n>\n> Based-on-patch-by: Jeff King <peff@peff.net>\n> Mentored-by: Christian Couder <christian.couder@gmail.com>\n> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n> diff --git a/builtin/tag.c b/builtin/tag.c\n> index e36c43e..280981f 100644\n> --- a/builtin/tag.c\n> +++ b/builtin/tag.c\n> @@ -56,6 +56,10 @@ static int match_pattern(const char **patterns, const char *ref)\n>         return 0;\n>  }\n>\n> +/*\n> + * This is currently duplicated in ref-filter.c, and will eventually be\n> + * removed as we port tag.c to use the ref-filter APIs.\n> + */\n>  static const unsigned char *match_points_at(const char *refname,\n>                                             const unsigned char *sha1)\n>  {\n> diff --git a/ref-filter.c b/ref-filter.c\n> index 43502a4..591e281 100644\n> --- a/ref-filter.c\n> +++ b/ref-filter.c\n> @@ -842,6 +842,29 @@ static int match_name_as_path(const char **pattern, const char *refname)\n>         return 0;\n>  }\n>\n> +/*\n> + * Given a ref (sha1, refname) see if it points to a one of the sha1s\n\ns/a one/one/\n\n> + * in a sha1_array.\n> + */\n> +static int match_points_at(struct sha1_array *points_at, const unsigned char *sha1,\n> +                          const char *refname)\n> +{\n> +       struct object *obj;\n> +\n> +       if (!points_at || !points_at->nr)\n> +               return 1;\n> +\n> +       if (sha1_array_lookup(points_at, sha1) >= 0)\n> +               return 1;\n> +\n> +       obj = parse_object_or_die(sha1, refname);\n> +       if (obj->type == OBJ_TAG &&\n> +           sha1_array_lookup(points_at, ((struct tag *)obj)->tagged->sha1) >= 0)\n> +               return 1;\n> +\n> +       return 0;\n> +}\n"},{"id":"264603","messageId":"CAPig+cRzZDa4LyEpzVcODYCdwxoHPRJ3hqjEvSWdBsKi3Ti7nA@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-4-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-22T22:38:18Z","receivedAt":"2015-06-22T22:38:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> Add the '--points-at' option provided by 'ref-filter'. The\n> option lets the user to pick only refs which point to a particular\n> commit.\n>\n> Add documentation and tests for the same.\n>\n> Based-on-patch-by: Jeff King <peff@peff.net>\n> Mentored-by: Christian Couder <christian.couder@gmail.com>\n> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n> diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\n> index b1fa8d4..67de3a7 100755\n> --- a/t/t6301-for-each-ref-filter.sh\n> +++ b/t/t6301-for-each-ref-filter.sh\n> @@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '\n>         git update-ref refs/odd/spot master\n>  '\n>\n> +test_expect_success 'filtering with --points-at' '\n> +       cat >expect <<-\\EOF &&\n> +       refs/heads/master\n> +       refs/odd/spot\n> +       refs/tags/three\n> +       EOF\n> +       git for-each-ref --format=\"%(refname)\" --points-at=master >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success 'check signed tags with --points-at' '\n> +       cat >expect <<-\\EOF &&\n> +       refs/heads/side\n> +       refs/tags/four\n> +       refs/tags/signed-tag four\n> +       EOF\n> +       git for-each-ref  --format=\"%(refname) %(*subject)\" --points-at=side >actual &&\n\ns/for-each-ref\\s+/for-each-ref /\n\n> +       test_cmp expect actual\n> +'\n> +\n>  test_done\n> --\n> 2.4.3.439.gfea0c2a.dirty\n"},{"id":"264604","messageId":"CAPig+cQLHX2spg00Zn1J=PMg_cuy2ARuWPOQQXLT1yLoQZ_SFg@mail.gmail.com","threadId":"39687","inReplyTo":"1434919705-4884-7-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v4 07/19] for-each-ref: add '--merged' and '--no-merged' options","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-22T22:41:39Z","receivedAt":"2015-06-22T22:41:39Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n> Add the '--merged' and '--no-merged' options provided by 'ref-filter'.\n> The '--merged' option lets the user to only list refs merged into the\n> named commit. The '--no-merged' option lets the user to only list refs\n> not merged into the named commit.\n>\n> Add documentation and tests for the same.\n>\n> Based-on-patch-by: Jeff King <peff@peff.net>\n> Mentored-by: Christian Couder <christian.couder@gmail.com>\n> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n> diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\n> index 0ede41d..c6dcd99 100644\n> --- a/Documentation/git-for-each-ref.txt\n> +++ b/Documentation/git-for-each-ref.txt\n> @@ -10,7 +10,7 @@ SYNOPSIS\n>  [verse]\n>  'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n>                    [(--sort=<key>)...] [--format=<format>] [<pattern>...]\n> -                  [--points-at <object>]\n> +                  [--points-at <object>] [(--merged | --no-merged) <object>]\n\nAccording to the documentation you added to the OPTIONS section, the\nobject following --merged and --no-merged is optional. Therefore,\nshouldn't this be s/<object>/[<object>]/ ?\n\nAlso, in the OPTIONS section, you spelled it \"commit\" rather than \"object\".\n\n>  DESCRIPTION\n>  -----------\n> @@ -66,6 +66,14 @@ OPTIONS\n>  --points-at <object>::\n>         Only list refs pointing to the given object.\n>\n> +--merged [<commit>]::\n> +       Only list refs whose tips are reachable from the\n> +       specified commit (HEAD if not specified).\n> +\n> +--no-merged [<commit>]::\n> +       Only list refs whose tips are not reachable from the\n> +       specified commit (HEAD if not specified).\n> +\n>  FIELD NAMES\n>  -----------\n>\n> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\n> index 46f9b05..09d48da 100644\n> --- a/builtin/for-each-ref.c\n> +++ b/builtin/for-each-ref.c\n> @@ -8,6 +8,7 @@\n>  static char const * const for_each_ref_usage[] = {\n>         N_(\"git for-each-ref [<options>] [<pattern>]\"),\n>         N_(\"git for-each-ref [--points-at <object>]\"),\n> +       N_(\"git for-each-ref [(--merged | --no-merged) <object>]\"),\n\nDitto: s/<object>/[<object>]/\n\n>         NULL\n>  };\n"},{"id":"264619","messageId":"CAOLa=ZTsD1MssMG0yz5GN1wU+hsDr4z4iXWBYmFOUTnzW1h+Og@mail.gmail.com","threadId":"39687","inReplyTo":"CAPig+cRGWG=L0JmSEtnxAyV=NTsq281Ot7E85HB4buDnMPHc1Q@mail.gmail.com","subject":"Re: [PATCH v4 03/19] ref-filter: implement '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-23T10:49:22Z","receivedAt":"2015-06-23T10:49:22Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Tue, Jun 23, 2015 at 4:06 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> s/a one/one/\n>\n\nNoted! Thanks\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264621","messageId":"CAOLa=ZR_54yxEnhr_dyB0pwNbfTUhoh48bn7h3QjA5H5BzWPuA@mail.gmail.com","threadId":"39687","inReplyTo":"CAPig+cRzZDa4LyEpzVcODYCdwxoHPRJ3hqjEvSWdBsKi3Ti7nA@mail.gmail.com","subject":"Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-23T10:52:35Z","receivedAt":"2015-06-23T10:52:35Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Tue, Jun 23, 2015 at 4:08 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak <karthik.188@gmail.com> wrote:\n>> Add the '--points-at' option provided by 'ref-filter'. The\n>> option lets the user to pick only refs which point to a particular\n>> commit.\n>>\n>> Add documentation and tests for the same.\n>>\n>> Based-on-patch-by: Jeff King <peff@peff.net>\n>> Mentored-by: Christian Couder <christian.couder@gmail.com>\n>> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n>> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n>> ---\n>> diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh\n>> index b1fa8d4..67de3a7 100755\n>> --- a/t/t6301-for-each-ref-filter.sh\n>> +++ b/t/t6301-for-each-ref-filter.sh\n>> @@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '\n>>         git update-ref refs/odd/spot master\n>>  '\n>>\n>> +test_expect_success 'filtering with --points-at' '\n>> +       cat >expect <<-\\EOF &&\n>> +       refs/heads/master\n>> +       refs/odd/spot\n>> +       refs/tags/three\n>> +       EOF\n>> +       git for-each-ref --format=\"%(refname)\" --points-at=master >actual &&\n>> +       test_cmp expect actual\n>> +'\n>> +\n>> +test_expect_success 'check signed tags with --points-at' '\n>> +       cat >expect <<-\\EOF &&\n>> +       refs/heads/side\n>> +       refs/tags/four\n>> +       refs/tags/signed-tag four\n>> +       EOF\n>> +       git for-each-ref  --format=\"%(refname) %(*subject)\" --points-at=side >actual &&\n>\n> s/for-each-ref\\s+/for-each-ref /\n>\n\nWill change! thanks :)\n\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"264624","messageId":"CAOLa=ZRUuRM8jofM6As_=F5Lbpb2LBq=X4pTbmDfufntYeWnmg@mail.gmail.com","threadId":"39687","inReplyTo":"CAPig+cQLHX2spg00Zn1J=PMg_cuy2ARuWPOQQXLT1yLoQZ_SFg@mail.gmail.com","subject":"Re: [PATCH v4 07/19] for-each-ref: add '--merged' and '--no-merged' options","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-06-23T11:05:38Z","receivedAt":"2015-06-23T11:05:38Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Tue, Jun 23, 2015 at 4:11 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> According to the documentation you added to the OPTIONS section, the\n> object following --merged and --no-merged is optional. Therefore,\n> shouldn't this be s/<object>/[<object>]/ ?\n>\n> Also, in the OPTIONS section, you spelled it \"commit\" rather than \"object\".\n>\n\n>\n> Ditto: s/<object>/[<object>]/\n>\n\nNoted and changed, this would apply to --contains also :)\n\n-- \nRegards,\nKarthik Nayak\n"}]}