{"thread":{"id":"45500","subject":"[PATCH v4 00/16] Various changes to the \"tag\" command & related","startedAt":"2017-03-24T18:41:16Z","lastAt":"2017-03-24T18:42:27Z","messageCount":17,"participants":["Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":4,"patchTotal":16},"messages":[{"id":"315302","messageId":"20170324184059.5374-1-avarab@gmail.com","threadId":"45500","inReplyTo":null,"subject":"[PATCH v4 00/16] Various changes to the \"tag\" command & related","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:43Z","receivedAt":"2017-03-24T18:41:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Hopefully the final version. This is exactly like v3 except for a\ncouple of minor changes (and rebased on the latest upstream master):\n\n\nÆvar Arnfjörð Bjarmason (16):\n  tag doc: move the description of --[no-]merged earlier\n  tag doc: split up the --[no-]merged documentation\n  tag doc: reword --[no-]merged to talk about commits, not tips\n  ref-filter: make combining --merged & --no-merged an error\n  ref-filter: add test for --contains on a non-commit\n  tag: remove a TODO item from the test suite\n  tag tests: fix a typo in a test description\n  for-each-ref: partly change <object> to <commit> in help\n  tag: add more incompatibles mode tests\n\nClarified in the commit message what code in builtin/tag.c we're\ntrying to test here.\n\n  parse-options: add OPT_NONEG to the \"contains\" option\n  tag: change misleading --list <pattern> documentation\n\nUse the same phrasing as Junio's \"branch doc: update description for\n`--list`\" does when describing \"git tag --list\".\n\n  tag: implicitly supply --list given another list-like option\n  tag: change --point-at to default to HEAD\n  ref-filter: add --no-contains option to tag/branch/for-each-ref\n  ref-filter: reflow recently changed branch/tag/for-each-ref docs\n  tag: add tests for --with and --without\n\n Documentation/git-branch.txt           |  33 +++--\n Documentation/git-for-each-ref.txt     |  12 +-\n Documentation/git-tag.txt              |  59 +++++---\n builtin/branch.c                       |   5 +-\n builtin/for-each-ref.c                 |   5 +-\n builtin/tag.c                          |  27 ++--\n contrib/completion/git-completion.bash |   4 +-\n parse-options.h                        |   6 +-\n ref-filter.c                           |  30 +++-\n ref-filter.h                           |   1 +\n t/t3200-branch.sh                      |   4 +\n t/t3201-branch-contains.sh             |  61 +++++++-\n t/t6302-for-each-ref-filter.sh         |  20 +++\n t/t7004-tag.sh                         | 245 +++++++++++++++++++++++++++++++--\n 14 files changed, 440 insertions(+), 72 deletions(-)\n\n-- \n2.11.0\n\n"},{"id":"315303","messageId":"20170324184059.5374-3-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 02/16] tag doc: split up the --[no-]merged documentation","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:45Z","receivedAt":"2017-03-24T18:41:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Split up the --[no-]merged documentation into documentation that\ndocuments each option independently. This is in line with how \"branch\"\nand \"for-each-ref\" are documented, and makes subsequent changes to\ndiscuss the limits & caveats of each option easier to read.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 11 +++++++----\n 1 file changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 33f18ea5fb..68b0ab2410 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -124,10 +124,13 @@ This option is only applicable when listing tags without annotation lines.\n \tOnly list tags which contain the specified commit (HEAD if not\n \tspecified).\n \n---[no-]merged [<commit>]::\n-\tOnly list tags whose tips are reachable, or not reachable\n-\tif `--no-merged` is used, from the specified commit (`HEAD`\n-\tif not specified).\n+--merged [<commit>]::\n+\tOnly list tags whose tips are reachable from the specified commit\n+\t(`HEAD` if not specified).\n+\n+--no-merged [<commit>]::\n+\tOnly list tags whose tips are not reachable from the specified\n+\tcommit (`HEAD` if not specified).\n \n --points-at <object>::\n \tOnly list tags of the given object.\n-- \n2.11.0\n\n"},{"id":"315304","messageId":"20170324184059.5374-5-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 04/16] ref-filter: make combining --merged & --no-merged an error","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:47Z","receivedAt":"2017-03-24T18:41:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the behavior of specifying --merged & --no-merged to be an\nerror, instead of silently picking the option that was provided last.\n\nSubsequent changes of mine add a --no-contains option in addition to\nthe existing --contains. Providing both of those isn't an error, and\nhas actual meaning.\n\nMaking its cousins have different behavior in this regard would be\nconfusing to the user, especially since we'd be silently disregarding\nsome of their command-line input.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-branch.txt       |  6 ++++--\n Documentation/git-for-each-ref.txt |  6 ++++--\n Documentation/git-tag.txt          |  4 ++--\n ref-filter.c                       | 11 ++++++++++-\n t/t3200-branch.sh                  |  4 ++++\n t/t6302-for-each-ref-filter.sh     |  4 ++++\n t/t7004-tag.sh                     |  4 ++++\n 7 files changed, 32 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 092f1bcf9f..e465298571 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -215,11 +215,13 @@ start-point is either a local or remote-tracking branch.\n \n --merged [<commit>]::\n \tOnly list branches whose tips are reachable from the\n-\tspecified commit (HEAD if not specified). Implies `--list`.\n+\tspecified commit (HEAD if not specified). Implies `--list`,\n+\tincompatible with `--no-merged`.\n \n --no-merged [<commit>]::\n \tOnly list branches whose tips are not reachable from the\n-\tspecified commit (HEAD if not specified). Implies `--list`.\n+\tspecified commit (HEAD if not specified). Implies `--list`,\n+\tincompatible with `--merged`.\n \n <branchname>::\n \tThe name of the branch to create or delete.\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex 111e1be6f5..4d55893712 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -69,11 +69,13 @@ OPTIONS\n \n --merged [<object>]::\n \tOnly list refs whose tips are reachable from the\n-\tspecified commit (HEAD if not specified).\n+\tspecified commit (HEAD if not specified),\n+\tincompatible with `--no-merged`.\n \n --no-merged [<object>]::\n \tOnly list refs whose tips are not reachable from the\n-\tspecified commit (HEAD if not specified).\n+\tspecified commit (HEAD if not specified),\n+\tincompatible with `--merged`.\n \n --contains [<object>]::\n \tOnly list refs which contain the specified commit (HEAD if not\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 3abf912782..448fdf3743 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -126,11 +126,11 @@ This option is only applicable when listing tags without annotation lines.\n \n --merged [<commit>]::\n \tOnly list tags whose commits are reachable from the specified\n-\tcommit (`HEAD` if not specified).\n+\tcommit (`HEAD` if not specified), incompatible with `--no-merged`.\n \n --no-merged [<commit>]::\n \tOnly list tags whose commits are not reachable from the specified\n-\tcommit (`HEAD` if not specified).\n+\tcommit (`HEAD` if not specified), incompatible with `--merged`.\n \n --points-at <object>::\n \tOnly list tags of the given object.\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 9c82b5b9d6..d7efae7b53 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -2084,8 +2084,17 @@ 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+\tint no_merged = starts_with(opt->long_name, \"no\");\n \n-\trf->merge = starts_with(opt->long_name, \"no\")\n+\tif (rf->merge) {\n+\t\tif (no_merged) {\n+\t\t\treturn opterror(opt, \"is incompatible with --merged\", 0);\n+\t\t} else {\n+\t\t\treturn opterror(opt, \"is incompatible with --no-merged\", 0);\n+\t\t}\n+\t}\n+\n+\trf->merge = no_merged\n \t\t? REF_FILTER_MERGED_OMIT\n \t\t: REF_FILTER_MERGED_INCLUDE;\n \ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 9f353c0efc..fe62e7c775 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -978,6 +978,10 @@ test_expect_success '--merged catches invalid object names' '\n \ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n '\n \n+test_expect_success '--merged is incompatible with --no-merged' '\n+\ttest_must_fail git branch --merged HEAD --no-merged HEAD\n+'\n+\n test_expect_success 'tracking with unexpected .fetch refspec' '\n \trm -rf a b c d &&\n \tgit init a &&\ndiff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh\nindex a09a1a46ef..d36d5dc124 100755\n--- a/t/t6302-for-each-ref-filter.sh\n+++ b/t/t6302-for-each-ref-filter.sh\n@@ -421,4 +421,8 @@ test_expect_success 'check %(if:notequals=<string>)' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '--merged is incompatible with --no-merged' '\n+\ttest_must_fail git for-each-ref --merged HEAD --no-merged HEAD\n+'\n+\n test_done\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex b4698ab5f5..45790664c1 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1748,6 +1748,10 @@ test_expect_success '--merged cannot be used in non-list mode' '\n \ttest_must_fail git tag --merged=mergetest-2 foo\n '\n \n+test_expect_success '--merged is incompatible with --no-merged' '\n+\ttest_must_fail git tag --merged HEAD --no-merged HEAD\n+'\n+\n test_expect_success '--merged shows merged tags' '\n \tcat >expect <<-\\EOF &&\n \tmergetest-1\n-- \n2.11.0\n\n"},{"id":"315305","messageId":"20170324184059.5374-4-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 03/16] tag doc: reword --[no-]merged to talk about commits, not tips","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:46Z","receivedAt":"2017-03-24T18:41:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wording for the --merged and --no-merged options to talk\nabout \"commits\" instead of \"tips\".\n\nThis phrasing was copied from the \"branch\" documentation in commit\n5242860f54 (\"tag.c: implement '--merged' and '--no-merged' options\",\n2015-09-10). Talking about the \"tip\" is branch nomenclature, not\nsomething usually associated with tags.\n\nThis phrasing might lead the reader to believe that these options\nmight find tags pointing to trees or blobs, let's instead be explicit\nand only talk about commits.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 68b0ab2410..3abf912782 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -125,11 +125,11 @@ This option is only applicable when listing tags without annotation lines.\n \tspecified).\n \n --merged [<commit>]::\n-\tOnly list tags whose tips are reachable from the specified commit\n-\t(`HEAD` if not specified).\n+\tOnly list tags whose commits are reachable from the specified\n+\tcommit (`HEAD` if not specified).\n \n --no-merged [<commit>]::\n-\tOnly list tags whose tips are not reachable from the specified\n+\tOnly list tags whose commits are not reachable from the specified\n \tcommit (`HEAD` if not specified).\n \n --points-at <object>::\n-- \n2.11.0\n\n"},{"id":"315306","messageId":"20170324184059.5374-6-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 05/16] ref-filter: add test for --contains on a non-commit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:48Z","receivedAt":"2017-03-24T18:41:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the tag test suite to test for --contains on a tree & blob. It\nonly accepts commits and will spew out \"<object> is a tree, not a\ncommit\".\n\nIt's sufficient to test this just for the \"tag\" and \"branch\" commands,\nbecause it covers all the machinery shared between \"branch\" and\n\"for-each-ref\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3201-branch-contains.sh | 9 +++++++++\n t/t7004-tag.sh             | 4 +++-\n 2 files changed, 12 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh\nindex 7f3ec47241..daa3ae82b7 100755\n--- a/t/t3201-branch-contains.sh\n+++ b/t/t3201-branch-contains.sh\n@@ -130,6 +130,15 @@ test_expect_success 'implicit --list conflicts with modification options' '\n \n '\n \n+test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '\n+\ttest_must_fail git branch --contains master^{tree} &&\n+\tblob=$(git hash-object -w --stdin <<-\\EOF\n+\tSome blob\n+\tEOF\n+\t) &&\n+\ttest_must_fail git branch --contains $blob\n+'\n+\n # We want to set up a case where the walk for the tracking info\n # of one branch crosses the tip of another branch (and make sure\n # that the latter walk does not mess up our flag to see if it was\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 45790664c1..3439913488 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1461,7 +1461,9 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag -n 100 &&\n \ttest_must_fail git tag -l -m msg &&\n \ttest_must_fail git tag -l -F some file &&\n-\ttest_must_fail git tag -v -s\n+\ttest_must_fail git tag -v -s &&\n+\ttest_must_fail git tag --contains tag-tree &&\n+\ttest_must_fail git tag --contains tag-blob\n '\n \n # check points-at\n-- \n2.11.0\n\n"},{"id":"315307","messageId":"20170324184059.5374-2-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 01/16] tag doc: move the description of --[no-]merged earlier","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:44Z","receivedAt":"2017-03-24T18:41:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the documentation for the --merged & --no-merged options earlier\nin the documentation, to sit along the other switches, and right next\nto the similar --contains and --points-at switches.\n\nIt makes more sense to group the options together, not have some\noptions after the like of <tagname>, <object>, <format> etc.\n\nThis was originally put there when the --merged & --no-merged options\nwere introduced in 5242860f54 (\"tag.c: implement '--merged' and\n'--no-merged' options\", 2015-09-10). It's not apparent from that\ncommit that the documentation is being placed apart from other\noptions, rather than along with them, so this was likely missed in the\ninitial review.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 525737a5d8..33f18ea5fb 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -124,6 +124,11 @@ This option is only applicable when listing tags without annotation lines.\n \tOnly list tags which contain the specified commit (HEAD if not\n \tspecified).\n \n+--[no-]merged [<commit>]::\n+\tOnly list tags whose tips are reachable, or not reachable\n+\tif `--no-merged` is used, from the specified commit (`HEAD`\n+\tif not specified).\n+\n --points-at <object>::\n \tOnly list tags of the given object.\n \n@@ -173,11 +178,6 @@ This option is only applicable when listing tags without annotation lines.\n \tthat of linkgit:git-for-each-ref[1].  When unspecified,\n \tdefaults to `%(refname:strip=2)`.\n \n---[no-]merged [<commit>]::\n-\tOnly list tags whose tips are reachable, or not reachable\n-\tif `--no-merged` is used, from the specified commit (`HEAD`\n-\tif not specified).\n-\n CONFIGURATION\n -------------\n By default, 'git tag' in sign-with-default mode (-s) will use your\n-- \n2.11.0\n\n"},{"id":"315308","messageId":"20170324184059.5374-9-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 08/16] for-each-ref: partly change <object> to <commit> in help","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:51Z","receivedAt":"2017-03-24T18:41:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change mentions of <object> to <commit> in the help output of\nfor-each-ref as appropriate.\n\nBoth --[no-]merged and --contains only take commits, but --points-at\ncan take any object, such as a tag pointing to a tree or blob.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/for-each-ref.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex df41fa0350..1a5ed20f59 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -8,8 +8,8 @@\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-\tN_(\"git for-each-ref [--contains [<object>]]\"),\n+\tN_(\"git for-each-ref [(--merged | --no-merged) [<commit>]]\"),\n+\tN_(\"git for-each-ref [--contains [<commit>]]\"),\n \tNULL\n };\n \n-- \n2.11.0\n\n"},{"id":"315309","messageId":"20170324184059.5374-7-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 06/16] tag: remove a TODO item from the test suite","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:49Z","receivedAt":"2017-03-24T18:41:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test for \"git tag -l\" to not have an associated TODO\ncomment saying that it should return non-zero if there's no tags.\n\nThis was added in commit ef5a6fb597 (\"Add test-script for git-tag\",\n2007-06-28) when the tests for \"tag\" were initially added, but at this\npoint changing this would be inconsistent with how \"git tag\" is a\nsynonym for \"git tag -l\", and would needlessly break external code\nthat relies on this porcelain command.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7004-tag.sh | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 3439913488..830eff948e 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -16,7 +16,6 @@ tag_exists () {\n \tgit show-ref --quiet --verify refs/tags/\"$1\"\n }\n \n-# todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success 'listing all tags in an empty tree should succeed' '\n \tgit tag -l &&\n \tgit tag\n@@ -136,7 +135,6 @@ test_expect_success \\\n \t'listing a tag using a matching pattern should output that tag' \\\n \t'test $(git tag -l mytag) = mytag'\n \n-# todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success \\\n \t'listing tags using a non-matching pattern should suceed' \\\n \t'git tag -l xxx'\n-- \n2.11.0\n\n"},{"id":"315310","messageId":"20170324184059.5374-11-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 10/16] parse-options: add OPT_NONEG to the \"contains\" option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:53Z","receivedAt":"2017-03-24T18:41:59Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add the OPT_NONEG flag to the \"contains\" option and its hidden synonym\n\"with\". Since this was added in commit 694a577519 (\"git-branch\n--contains=commit\", 2007-11-07) giving --no-{contains,with} hasn't\nbeen an error, but has emitted the help output since\nfilter.with_commit wouldn't get set.\n\nNow git will emit \"error: unknown option `no-{contains,with}'\" at the\ntop of the help output.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n parse-options.h | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex dcd8a0926c..9f48f554ba 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -258,7 +258,7 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);\n \t  PARSE_OPT_LASTARG_DEFAULT | flag, \\\n \t  parse_opt_commits, (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+#define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, PARSE_OPT_NONEG)\n+#define OPT_WITH(v, h) _OPT_CONTAINS_OR_WITH(\"with\", v, h, PARSE_OPT_HIDDEN | PARSE_OPT_NONEG)\n \n #endif\n-- \n2.11.0\n\n"},{"id":"315311","messageId":"20170324184059.5374-10-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 09/16] tag: add more incompatibles mode tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:52Z","receivedAt":"2017-03-24T18:42:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Amend the test suite to test for more invalid uses like \"-l -a\"\netc.\n\nThis change tests the code path in builtin/tag.c between lines:\n\n    if (argc == 0 && !cmdmode)\n\nAnd:\n\n    if ((create_tag_object || force) && (cmdmode != 0))\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7004-tag.sh | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 63ee2cf727..92af8bb7e6 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1455,8 +1455,24 @@ test_expect_success 'checking that initial commit is in all tags' \"\n \n test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag -a &&\n+\ttest_must_fail git tag -a -l &&\n+\ttest_must_fail git tag -s &&\n+\ttest_must_fail git tag -s -l &&\n+\ttest_must_fail git tag -m &&\n+\ttest_must_fail git tag -m -l &&\n+\ttest_must_fail git tag -m \"hlagh\" &&\n+\ttest_must_fail git tag -m \"hlagh\" -l &&\n+\ttest_must_fail git tag -F &&\n+\ttest_must_fail git tag -F -l &&\n+\ttest_must_fail git tag -f &&\n+\ttest_must_fail git tag -f -l &&\n+\ttest_must_fail git tag -a -s -m -F &&\n+\ttest_must_fail git tag -a -s -m -F -l &&\n \ttest_must_fail git tag -l -v &&\n+\ttest_must_fail git tag -l -d &&\n+\ttest_must_fail git tag -l -v -d &&\n \ttest_must_fail git tag -n 100 &&\n+\ttest_must_fail git tag -n 100 -v &&\n \ttest_must_fail git tag -l -m msg &&\n \ttest_must_fail git tag -l -F some file &&\n \ttest_must_fail git tag -v -s &&\n-- \n2.11.0\n\n"},{"id":"315312","messageId":"20170324184059.5374-13-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 12/16] tag: implicitly supply --list given another list-like option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:55Z","receivedAt":"2017-03-24T18:42:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the \"tag\" command to implicitly turn on its --list mode when\nprovided with a list-like option such as --contains, --points-at etc.\n\nThis is for consistency with how \"branch\" works. When \"branch\" is\ngiven a list-like option, such as --contains, it implicitly provides\n--list. Before this change \"tag\" would error out on those sorts of\ninvocations. I.e. while both of these worked for \"branch\":\n\n    git branch --contains v2.8.0 <pattern>\n    git branch --list --contains v2.8.0 <pattern>\n\nOnly the latter form worked for \"tag\":\n\n    git tag --contains v2.8.0 '*rc*'\n    git tag --list --contains v2.8.0 '*rc*'\n\nNow \"tag\", like \"branch\", will implicitly supply --list when a\nlist-like option is provided, and no other conflicting non-list\noptions (such as -d) are present on the command-line.\n\nSpelunking through the history via:\n\n    git log --reverse -p -G'only allowed with' -- '*builtin*tag*c'\n\nReveals that there was no good reason for not allowing this in the\nfirst place. The --contains option added in 32c35cfb1e (\"git-tag: Add\n--contains option\", 2009-01-26) made this an error. All the other\nsubsequent list-like options that were added copied its pattern of\nmaking this usage an error.\n\nThe only tests that break as a result of this change are tests that\nwere explicitly checking that this \"branch-like\" usage wasn't\npermitted. Change those failing tests to check that this invocation\nmode is permitted, add extra tests for the list-like options we\nweren't testing, and tests to ensure that e.g. we don't toggle the\nlist mode in the presence of other conflicting non-list options.\n\nWith this change errors messages such as \"--contains option is only\nallowed with -l\" don't make sense anymore, since options like\n--contain turn on -l. Instead we error out when list-like options such\nas --contain are used in conjunction with conflicting options such as\n-d or -v.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 17 +++++++++------\n builtin/tag.c             | 18 ++++++++++------\n t/t7004-tag.sh            | 55 ++++++++++++++++++++++++++++++++++++++++++-----\n 3 files changed, 73 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 47d8733523..4d289f5dd5 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -82,10 +82,11 @@ OPTIONS\n \n -n<num>::\n \t<num> specifies how many lines from the annotation, if any,\n-\tare printed when using -l.\n-\tThe default is not to print any annotation lines.\n-\tIf no number is given to `-n`, only the first line is printed.\n-\tIf the tag is not annotated, the commit message is displayed instead.\n+\tare printed when using -l. Implies `--list`.\n++\n+The default is not to print any annotation lines.\n+If no number is given to `-n`, only the first line is printed.\n+If the tag is not annotated, the commit message is displayed instead.\n \n -l::\n --list::\n@@ -95,6 +96,10 @@ OPTIONS\n Running \"git tag\" without arguments also lists all tags. The pattern\n is a shell wildcard (i.e., matched using fnmatch(3)). Multiple\n patterns may be given; if any of them matches, the tag is shown.\n++\n+This option is implicitly supplied if any other list-like option such\n+as `--contains` is provided. See the documentation for each of those\n+options for details.\n \n --sort=<key>::\n \tSort based on the key given.  Prefix `-` to sort in\n@@ -123,7 +128,7 @@ This option is only applicable when listing tags without annotation lines.\n \n --contains [<commit>]::\n \tOnly list tags which contain the specified commit (HEAD if not\n-\tspecified).\n+\tspecified). Implies `--list`.\n \n --merged [<commit>]::\n \tOnly list tags whose commits are reachable from the specified\n@@ -134,7 +139,7 @@ This option is only applicable when listing tags without annotation lines.\n \tcommit (`HEAD` if not specified), incompatible with `--merged`.\n \n --points-at <object>::\n-\tOnly list tags of the given object.\n+\tOnly list tags of the given object. Implies `--list`.\n \n -m <msg>::\n --message=<msg>::\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex ad29be6923..3c686961db 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -454,8 +454,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t}\n \tcreate_tag_object = (opt.sign || annotate || msg.given || msgfile);\n \n-\tif (argc == 0 && !cmdmode)\n-\t\tcmdmode = 'l';\n+\tif (!cmdmode) {\n+\t\tif (argc == 0)\n+\t\t\tcmdmode = 'l';\n+\t\telse if (filter.with_commit ||\n+\t\t\t filter.points_at.nr || filter.merge_commit ||\n+\t\t\t filter.lines != -1)\n+\t\t\tcmdmode = 'l';\n+\t}\n \n \tif ((create_tag_object || force) && (cmdmode != 0))\n \t\tusage_with_options(git_tag_usage, options);\n@@ -485,13 +491,13 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\treturn ret;\n \t}\n \tif (filter.lines != -1)\n-\t\tdie(_(\"-n option is only allowed with -l.\"));\n+\t\tdie(_(\"-n option is only allowed in list mode\"));\n \tif (filter.with_commit)\n-\t\tdie(_(\"--contains option is only allowed with -l.\"));\n+\t\tdie(_(\"--contains option is only allowed in list mode\"));\n \tif (filter.points_at.nr)\n-\t\tdie(_(\"--points-at option is only allowed with -l.\"));\n+\t\tdie(_(\"--points-at option is only allowed in list mode\"));\n \tif (filter.merge_commit)\n-\t\tdie(_(\"--merged and --no-merged option are only allowed with -l\"));\n+\t\tdie(_(\"--merged and --no-merged options are only allowed in list mode\"));\n \tif (cmdmode == 'd')\n \t\treturn for_each_tag_name(argv, delete_tag, NULL);\n \tif (cmdmode == 'v') {\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 75681b2cad..5823de16aa 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -643,6 +643,11 @@ test_expect_success \\\n \tgit tag -n0 -l tag-one-line >actual &&\n \ttest_cmp expect actual &&\n \n+\tgit tag -n0 | grep \"^tag-one-line\" >actual &&\n+\ttest_cmp expect actual &&\n+\tgit tag -n0 tag-one-line >actual &&\n+\ttest_cmp expect actual &&\n+\n \techo \"tag-one-line    A msg\" >expect &&\n \tgit tag -n1 -l | grep \"^tag-one-line\" >actual &&\n \ttest_cmp expect actual &&\n@@ -656,6 +661,17 @@ test_expect_success \\\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' '\n+\t>expect &&\n+\tgit tag -n 100 >actual &&\n+\ttest_cmp expect actual &&\n+\n+\tgit tag -m \"A msg\" 100 &&\n+\techo \"100             A msg\" >expect &&\n+\tgit tag -n 100 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success \\\n \t'listing the zero-lines message of a non-signed tag should succeed' '\n \tgit tag -m \"\" tag-zero-lines &&\n@@ -1476,6 +1492,11 @@ test_expect_success 'checking that initial commit is in all tags' \"\n \ttest_cmp expected actual\n \"\n \n+test_expect_success 'checking that --contains can be used in non-list mode' '\n+\tgit tag --contains $hash1 v* >actual &&\n+\ttest_cmp expected actual\n+'\n+\n # mixing modes and options:\n \n test_expect_success 'mixing incompatibles modes and options is forbidden' '\n@@ -1496,7 +1517,6 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag -l -v &&\n \ttest_must_fail git tag -l -d &&\n \ttest_must_fail git tag -l -v -d &&\n-\ttest_must_fail git tag -n 100 &&\n \ttest_must_fail git tag -n 100 -v &&\n \ttest_must_fail git tag -l -m msg &&\n \ttest_must_fail git tag -l -F some file &&\n@@ -1505,10 +1525,25 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag --contains tag-blob\n '\n \n+for option in --contains --merged --no-merged --points-at\n+do\n+\ttest_expect_success \"mixing incompatible modes with $option is forbidden\" \"\n+\t\ttest_must_fail git tag -d $option HEAD &&\n+\t\ttest_must_fail git tag -d $option HEAD some-tag &&\n+\t\ttest_must_fail git tag -v $option HEAD\n+\t\"\n+\ttest_expect_success \"Doing 'git tag --list-like $option <commit> <pattern> is permitted\" \"\n+\t\tgit tag -n $option HEAD HEAD &&\n+\t\tgit tag $option HEAD HEAD\n+\t\"\n+done\n+\n # check points-at\n \n-test_expect_success '--points-at cannot be used in non-list mode' '\n-\ttest_must_fail git tag --points-at=v4.0 foo\n+test_expect_success '--points-at can be used in non-list mode' '\n+\techo v4.0 >expect &&\n+\tgit tag --points-at=v4.0 \"v*\" >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success '--points-at finds lightweight tags' '\n@@ -1785,8 +1820,13 @@ test_expect_success 'setup --merged test tags' '\n \tgit tag mergetest-3 HEAD\n '\n \n-test_expect_success '--merged cannot be used in non-list mode' '\n-\ttest_must_fail git tag --merged=mergetest-2 foo\n+test_expect_success '--merged can be used in non-list mode' '\n+\tcat >expect <<-\\EOF &&\n+\tmergetest-1\n+\tmergetest-2\n+\tEOF\n+\tgit tag --merged=mergetest-2 \"mergetest*\" >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success '--merged is incompatible with --no-merged' '\n@@ -1810,6 +1850,11 @@ test_expect_success '--no-merged show unmerged tags' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '--no-merged can be used in non-list mode' '\n+\tgit tag --no-merged=mergetest-2 mergetest-* >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'ambiguous branch/tags not marked' '\n \tgit tag ambiguous &&\n \tgit branch ambiguous &&\n-- \n2.11.0\n\n"},{"id":"315313","messageId":"20170324184059.5374-12-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 11/16] tag: change misleading --list <pattern> documentation","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:54Z","receivedAt":"2017-03-24T18:42:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the documentation for --list so that it's described as a\ntoggle, not as an option that takes a <pattern> as an argument.\n\nJunio initially documented this in b867c7c23a (\"git-tag: -l to list\ntags (usability).\", 2006-02-17), but later Jeff King changed \"tag\" to\naccept multiple patterns in 588d0e834b (\"tag: accept multiple patterns\nfor --list\", 2011-06-20).\n\nHowever, documenting this as \"-l <pattern>\" was never correct, as\nthese both worked before Jeff's change:\n\n    git tag -l 'v*'\n    git tag 'v*' -l\n\nOne would expect an option that was documented like that to only\naccept:\n\n    git tag --list\n    git tag --list 'v*rc*'\n\nAnd after Jeff's change, one that took multiple patterns:\n\n    git tag --list 'v*rc*' --list '*2.8*'\n\nBut since it's actually a toggle all of these work as well, and\nproduce identical output to the last example above:\n\n    git tag --list 'v*rc*' '*2.8*'\n    git tag --list 'v*rc*' '*2.8*' --list --list --list\n    git tag --list 'v*rc*' '*2.8*' --list -l --list -l --list\n\nNow the documentation is more in tune with how the \"branch\" command\ndescribes its --list option since commit cddd127b9a (\"branch:\nintroduce --list option\", 2011-08-28).\n\nChange the test suite to assert that these invocations work for the\ncases that weren't already being tested for.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 15 ++++++++-------\n t/t7004-tag.sh            | 25 +++++++++++++++++++++++++\n 2 files changed, 33 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 448fdf3743..47d8733523 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -87,13 +87,14 @@ OPTIONS\n \tIf no number is given to `-n`, only the first line is printed.\n \tIf the tag is not annotated, the commit message is displayed instead.\n \n--l <pattern>::\n---list <pattern>::\n-\tList tags with names that match the given pattern (or all if no\n-\tpattern is given).  Running \"git tag\" without arguments also\n-\tlists all tags. The pattern is a shell wildcard (i.e., matched\n-\tusing fnmatch(3)).  Multiple patterns may be given; if any of\n-\tthem matches, the tag is shown.\n+-l::\n+--list::\n+\tList tags. With optional `<pattern>...`, e.g. `git tag --list\n+\t'v-*'`, list only the tags that match the pattern(s).\n++\n+Running \"git tag\" without arguments also lists all tags. The pattern\n+is a shell wildcard (i.e., matched using fnmatch(3)). Multiple\n+patterns may be given; if any of them matches, the tag is shown.\n \n --sort=<key>::\n \tSort based on the key given.  Prefix `-` to sort in\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 92af8bb7e6..75681b2cad 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -118,6 +118,18 @@ test_expect_success 'listing all tags if one exists should succeed' '\n \tgit tag\n '\n \n+cat >expect <<EOF\n+mytag\n+EOF\n+test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '\n+\tgit tag -l -l >actual &&\n+\ttest_cmp expect actual &&\n+\tgit tag --list --list >actual &&\n+\ttest_cmp expect actual &&\n+\tgit tag --list -l --list >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'listing all tags if one exists should output that tag' '\n \ttest $(git tag -l) = mytag &&\n \ttest $(git tag) = mytag\n@@ -336,6 +348,19 @@ test_expect_success 'tag -l can accept multiple patterns' '\n \ttest_cmp expect actual\n '\n \n+# Between v1.7.7 & v2.13.0 a fair reading of the git-tag documentation\n+# could leave you with the impression that \"-l <pattern> -l <pattern>\"\n+# was how we wanted to accept multiple patterns.\n+#\n+# This test should not imply that this is a sane thing to support. but\n+# since the documentation was worded like it was let's at least find\n+# out if we're going to break this long-documented form of taking\n+# multiple patterns.\n+test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' '\n+\tgit tag -l \"v1*\" -l \"v0*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'listing tags in column' '\n \tCOLUMNS=40 git tag -l --column=row >actual &&\n \tcat >expected <<\\EOF &&\n-- \n2.11.0\n\n"},{"id":"315314","messageId":"20170324184059.5374-15-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 14/16] ref-filter: add --no-contains option to tag/branch/for-each-ref","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:57Z","receivedAt":"2017-03-24T18:42:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the tag, branch & for-each-ref commands to have a --no-contains\noption in addition to their longstanding --contains options.\n\nThis allows for finding the last-good rollout tag given a known-bad\n<commit>. Given a hypothetically bad commit cf5c7253e0, the git\nversion to revert to can be found with this hacky two-liner:\n\n    (git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |\n        sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10\n\nWith this new --no-contains option the same can be achieved with:\n\n    git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10\n\nAs the filtering machinery is shared between the tag, branch &\nfor-each-ref commands, implement this for those commands too. A\npractical use for this with \"branch\" is e.g. finding branches which\nwere branched off between v2.8.0 and v2.10.0:\n\n    git branch --contains v2.8.0 --no-contains v2.10.0\n\nThe \"describe\" command also has a --contains option, but its semantics\nare unrelated to what tag/branch/for-each-ref use --contains for. A\n--no-contains option for \"describe\" wouldn't make any sense, other\nthan being exactly equivalent to not supplying --contains at all,\nwhich would be confusing at best.\n\nAdd a --without option to \"tag\" as an alias for --no-contains, for\nconsistency with --with and --contains.  The --with option is\nundocumented, and possibly the only user of it is\nJunio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's\ntrivial to support, so let's do that.\n\nThe additions to the the test suite are inverse copies of the\ncorresponding --contains tests. With this change --no-contains for\ntag, branch & for-each-ref is just as well tested as the existing\n--contains option.\n\nIn addition to those tests, add a test for \"tag\" which asserts that\n--no-contains won't find tree/blob tags, which is slightly\nunintuitive, but consistent with how --contains works & is documented.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-branch.txt           |  16 +++-\n Documentation/git-for-each-ref.txt     |   6 +-\n Documentation/git-tag.txt              |   6 +-\n builtin/branch.c                       |   5 +-\n builtin/for-each-ref.c                 |   3 +-\n builtin/tag.c                          |   8 +-\n contrib/completion/git-completion.bash |   4 +-\n parse-options.h                        |   2 +\n ref-filter.c                           |  19 +++--\n ref-filter.h                           |   1 +\n t/t3201-branch-contains.sh             |  54 +++++++++++++-\n t/t6302-for-each-ref-filter.sh         |  16 ++++\n t/t7004-tag.sh                         | 130 ++++++++++++++++++++++++++++++++-\n 13 files changed, 245 insertions(+), 25 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex e465298571..e4b5d5c3e1 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -11,7 +11,8 @@ SYNOPSIS\n 'git branch' [--color[=<when>] | --no-color] [-r | -a]\n \t[--list] [-v [--abbrev=<length> | --no-abbrev]]\n \t[--column[=<options>] | --no-column]\n-\t[(--merged | --no-merged | --contains) [<commit>]] [--sort=<key>]\n+\t[(--merged | --no-merged) [<commit>]]\n+\t[--contains [<commit]] [--no-contains [<commit>]] [--sort=<key>]\n \t[--points-at <object>] [--format=<format>] [<pattern>...]\n 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\n 'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\n@@ -35,7 +36,7 @@ as branch creation.\n \n With `--contains`, shows only the branches that contain the named commit\n (in other words, the branches whose tip commits are descendants of the\n-named commit).  With `--merged`, only branches merged into the named\n+named commit), `--no-contains` inverts it. With `--merged`, only branches merged into the named\n commit (i.e. the branches whose tip commits are reachable from the named\n commit) will be listed.  With `--no-merged` only branches not merged into\n the named commit will be listed.  If the <commit> argument is missing it\n@@ -213,6 +214,10 @@ start-point is either a local or remote-tracking branch.\n \tOnly list branches which contain the specified commit (HEAD\n \tif not specified). Implies `--list`.\n \n+--no-contains [<commit>]::\n+\tOnly list branches which don't contain the specified commit\n+\t(HEAD if not specified). Implies `--list`.\n+\n --merged [<commit>]::\n \tOnly list branches whose tips are reachable from the\n \tspecified commit (HEAD if not specified). Implies `--list`,\n@@ -298,13 +303,16 @@ If you are creating a branch that you want to checkout immediately, it is\n easier to use the git checkout command with its `-b` option to create\n a branch and check it out with a single command.\n \n-The options `--contains`, `--merged` and `--no-merged` serve three related\n-but different purposes:\n+The options `--contains`, `--no-contains`, `--merged` and `--no-merged`\n+serve four related but different purposes:\n \n - `--contains <commit>` is used to find all branches which will need\n   special attention if <commit> were to be rebased or amended, since those\n   branches contain the specified <commit>.\n \n+- `--no-contains <commit>` is the inverse of that, i.e. branches that don't\n+  contain the specified <commit>.\n+\n - `--merged` is used to find all branches which can be safely deleted,\n   since those branches are fully contained by HEAD.\n \ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex 4d55893712..03e187a105 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -11,7 +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+\t\t   [--contains [<object>]] [--no-contains [<object>]]\n \n DESCRIPTION\n -----------\n@@ -81,6 +81,10 @@ OPTIONS\n \tOnly list refs which contain the specified commit (HEAD if not\n \tspecified).\n \n+--no-contains [<object>]::\n+\tOnly list refs which don't contain the specified commit (HEAD\n+\tif not specified).\n+\n --ignore-case::\n \tSorting and filtering refs are case insensitive.\n \ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex d5cdb18d96..1be6570c90 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git tag' [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>]\n \t<tagname> [<commit> | <object>]\n 'git tag' -d <tagname>...\n-'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]\n+'git tag' [-n[<num>]] -l [--contains <commit>] [--contains <commit>] [--points-at <object>]\n \t[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>]\n \t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]\n 'git tag' -v [--format=<format>] <tagname>...\n@@ -130,6 +130,10 @@ This option is only applicable when listing tags without annotation lines.\n \tOnly list tags which contain the specified commit (HEAD if not\n \tspecified). Implies `--list`.\n \n+--no-contains [<commit>]::\n+\tOnly list tags which don't contain the specified commit (HEAD if\n+\tnot specified). Implies `--list`.\n+\n --merged [<commit>]::\n \tOnly list tags whose commits are reachable from the specified\n \tcommit (`HEAD` if not specified), incompatible with `--no-merged`.\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 52688f2e1b..0552c42ad1 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -562,7 +562,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT('r', \"remotes\",     &filter.kind, N_(\"act on remote-tracking branches\"),\n \t\t\tFILTER_REFS_REMOTES),\n \t\tOPT_CONTAINS(&filter.with_commit, N_(\"print only branches that contain the commit\")),\n+\t\tOPT_NO_CONTAINS(&filter.no_commit, N_(\"print only branches that don't contain the commit\")),\n \t\tOPT_WITH(&filter.with_commit, N_(\"print only branches that contain the commit\")),\n+\t\tOPT_WITHOUT(&filter.no_commit, N_(\"print only branches that don't contain the commit\")),\n \t\tOPT__ABBREV(&filter.abbrev),\n \n \t\tOPT_GROUP(N_(\"Specific git-branch actions:\")),\n@@ -618,7 +620,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tif (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0)\n \t\tlist = 1;\n \n-\tif (filter.with_commit || filter.merge != REF_FILTER_MERGED_NONE || filter.points_at.nr)\n+\tif (filter.with_commit || filter.merge != REF_FILTER_MERGED_NONE || filter.points_at.nr ||\n+\t    filter.no_commit)\n \t\tlist = 1;\n \n \tif (!!delete + !!rename + !!new_upstream +\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 1a5ed20f59..eca365bf89 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -9,7 +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) [<commit>]]\"),\n-\tN_(\"git for-each-ref [--contains [<commit>]]\"),\n+\tN_(\"git for-each-ref [--contains [<commit>]] [--no-contains [<commit>]]\"),\n \tNULL\n };\n \n@@ -43,6 +43,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\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_NO_CONTAINS(&filter.no_commit, N_(\"print only refs which don't contain the commit\")),\n \t\tOPT_BOOL(0, \"ignore-case\", &icase, N_(\"sorting and filtering are case insensitive\")),\n \t\tOPT_END(),\n \t};\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 8bf6d85176..dbc6f5b74b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -22,7 +22,7 @@\n static const char * const git_tag_usage[] = {\n \tN_(\"git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<head>]\"),\n \tN_(\"git tag -d <tagname>...\"),\n-\tN_(\"git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]\"\n+\tN_(\"git tag -l [-n[<num>]] [--contains <commit>] [--no-contains <commit>] [--points-at <object>]\"\n \t\t\"\\n\\t\\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]\"),\n \tN_(\"git tag -v [--format=<format>] <tagname>...\"),\n \tNULL\n@@ -424,7 +424,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\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(&filter.with_commit, N_(\"print only tags that contain the commit\")),\n+\t\tOPT_NO_CONTAINS(&filter.no_commit, N_(\"print only tags that don't contain the commit\")),\n \t\tOPT_WITH(&filter.with_commit, N_(\"print only tags that contain the commit\")),\n+\t\tOPT_WITHOUT(&filter.no_commit, N_(\"print only tags that don't contain the commit\")),\n \t\tOPT_MERGED(&filter, N_(\"print only tags that are merged\")),\n \t\tOPT_NO_MERGED(&filter, N_(\"print only tags that are not merged\")),\n \t\tOPT_CALLBACK(0 , \"sort\", sorting_tail, N_(\"key\"),\n@@ -458,7 +460,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (!cmdmode) {\n \t\tif (argc == 0)\n \t\t\tcmdmode = 'l';\n-\t\telse if (filter.with_commit ||\n+\t\telse if (filter.with_commit || filter.no_commit ||\n \t\t\t filter.points_at.nr || filter.merge_commit ||\n \t\t\t filter.lines != -1)\n \t\t\tcmdmode = 'l';\n@@ -495,6 +497,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"-n option is only allowed in list mode\"));\n \tif (filter.with_commit)\n \t\tdie(_(\"--contains option is only allowed in list mode\"));\n+\tif (filter.no_commit)\n+\t\tdie(_(\"--no-contains option is only allowed in list mode\"));\n \tif (filter.points_at.nr)\n \t\tdie(_(\"--points-at option is only allowed in list mode\"));\n \tif (filter.merge_commit)\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex fc32286a43..ec8fce5820 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1093,7 +1093,7 @@ _git_branch ()\n \t--*)\n \t\t__gitcomp \"\n \t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n-\t\t\t--track --no-track --contains --merged --no-merged\n+\t\t\t--track --no-track --contains --no-contains --merged --no-merged\n \t\t\t--set-upstream-to= --edit-description --list\n \t\t\t--unset-upstream --delete --move --remotes\n \t\t\t--column --no-column --sort= --points-at\n@@ -2862,7 +2862,7 @@ _git_tag ()\n \t\t__gitcomp \"\n \t\t\t--list --delete --verify --annotate --message --file\n \t\t\t--sign --cleanup --local-user --force --column --sort=\n-\t\t\t--contains --points-at --merged --no-merged --create-reflog\n+\t\t\t--contains --no-contains --points-at --merged --no-merged --create-reflog\n \t\t\t\"\n \t\t;;\n \tesac\ndiff --git a/parse-options.h b/parse-options.h\nindex 9f48f554ba..af711227ae 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -259,6 +259,8 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);\n \t  parse_opt_commits, (intptr_t) \"HEAD\" \\\n \t}\n #define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, PARSE_OPT_NONEG)\n+#define OPT_NO_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"no-contains\", v, h, PARSE_OPT_NONEG)\n #define OPT_WITH(v, h) _OPT_CONTAINS_OR_WITH(\"with\", v, h, PARSE_OPT_HIDDEN | PARSE_OPT_NONEG)\n+#define OPT_WITHOUT(v, h) _OPT_CONTAINS_OR_WITH(\"without\", v, h, PARSE_OPT_HIDDEN | PARSE_OPT_NONEG)\n \n #endif\ndiff --git a/ref-filter.c b/ref-filter.c\nindex d7efae7b53..1e39273005 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1487,6 +1487,7 @@ struct ref_filter_cbdata {\n \tstruct ref_array *array;\n \tstruct ref_filter *filter;\n \tstruct contains_cache contains_cache;\n+\tstruct contains_cache no_contains_cache;\n };\n \n /*\n@@ -1586,11 +1587,11 @@ static enum contains_result contains_tag_algo(struct commit *candidate,\n }\n \n static int commit_contains(struct ref_filter *filter, struct commit *commit,\n-\t\t\t   struct contains_cache *cache)\n+\t\t\t   struct commit_list *list, struct contains_cache *cache)\n {\n \tif (filter->with_commit_tag_algo)\n-\t\treturn contains_tag_algo(commit, filter->with_commit, cache) == CONTAINS_YES;\n-\treturn is_descendant_of(commit, filter->with_commit);\n+\t\treturn contains_tag_algo(commit, list, cache) == CONTAINS_YES;\n+\treturn is_descendant_of(commit, list);\n }\n \n /*\n@@ -1780,13 +1781,17 @@ 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 || filter->with_commit || filter->verbose) {\n+\tif (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {\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\t/* We perform the filtering for the '--contains' option... */\n \t\tif (filter->with_commit &&\n-\t\t    !commit_contains(filter, commit, &ref_cbdata->contains_cache))\n+\t\t    !commit_contains(filter, commit, filter->with_commit, &ref_cbdata->contains_cache))\n+\t\t\treturn 0;\n+\t\t/* ...or for the `--no-contains' option */\n+\t\tif (filter->no_commit &&\n+\t\t    commit_contains(filter, commit, filter->no_commit, &ref_cbdata->no_contains_cache))\n \t\t\treturn 0;\n \t}\n \n@@ -1887,6 +1892,7 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int\n \tfilter->kind = type & FILTER_REFS_KIND_MASK;\n \n \tinit_contains_cache(&ref_cbdata.contains_cache);\n+\tinit_contains_cache(&ref_cbdata.no_contains_cache);\n \n \t/*  Simple per-ref filtering */\n \tif (!filter->kind)\n@@ -1911,6 +1917,7 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int\n \t}\n \n \tclear_contains_cache(&ref_cbdata.contains_cache);\n+\tclear_contains_cache(&ref_cbdata.no_contains_cache);\n \n \t/*  Filters that need revision walking */\n \tif (filter->merge_commit)\ndiff --git a/ref-filter.h b/ref-filter.h\nindex e738c5dfd3..dde40f6849 100644\n--- a/ref-filter.h\n+++ b/ref-filter.h\n@@ -53,6 +53,7 @@ struct ref_filter {\n \tconst char **name_patterns;\n \tstruct sha1_array points_at;\n \tstruct commit_list *with_commit;\n+\tstruct commit_list *no_commit;\n \n \tenum {\n \t\tREF_FILTER_MERGED_NONE = 0,\ndiff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh\nindex daa3ae82b7..0ef1b6fdcc 100755\n--- a/t/t3201-branch-contains.sh\n+++ b/t/t3201-branch-contains.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-test_description='branch --contains <commit>, --merged, and --no-merged'\n+test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'\n \n . ./test-lib.sh\n \n@@ -45,6 +45,22 @@ test_expect_success 'branch --contains master' '\n \n '\n \n+test_expect_success 'branch --no-contains=master' '\n+\n+\tgit branch --no-contains=master >actual &&\n+\t>expect &&\n+\ttest_cmp expect actual\n+\n+'\n+\n+test_expect_success 'branch --no-contains master' '\n+\n+\tgit branch --no-contains master >actual &&\n+\t>expect &&\n+\ttest_cmp expect actual\n+\n+'\n+\n test_expect_success 'branch --contains=side' '\n \n \tgit branch --contains=side >actual &&\n@@ -55,6 +71,16 @@ test_expect_success 'branch --contains=side' '\n \n '\n \n+test_expect_success 'branch --no-contains=side' '\n+\n+\tgit branch --no-contains=side >actual &&\n+\t{\n+\t\techo \"  master\"\n+\t} >expect &&\n+\ttest_cmp expect actual\n+\n+'\n+\n test_expect_success 'branch --contains with pattern implies --list' '\n \n \tgit branch --contains=master master >actual &&\n@@ -65,6 +91,14 @@ test_expect_success 'branch --contains with pattern implies --list' '\n \n '\n \n+test_expect_success 'branch --no-contains with pattern implies --list' '\n+\n+\tgit branch --no-contains=master master >actual &&\n+\t>expect &&\n+\ttest_cmp expect actual\n+\n+'\n+\n test_expect_success 'side: branch --merged' '\n \n \tgit branch --merged >actual &&\n@@ -126,7 +160,9 @@ test_expect_success 'branch --no-merged with pattern implies --list' '\n test_expect_success 'implicit --list conflicts with modification options' '\n \n \ttest_must_fail git branch --contains=master -d &&\n-\ttest_must_fail git branch --contains=master -m foo\n+\ttest_must_fail git branch --contains=master -m foo &&\n+\ttest_must_fail git branch --no-contains=master -d &&\n+\ttest_must_fail git branch --no-contains=master -m foo\n \n '\n \n@@ -136,7 +172,8 @@ test_expect_success 'Assert that --contains only works on commits, not trees & b\n \tSome blob\n \tEOF\n \t) &&\n-\ttest_must_fail git branch --contains $blob\n+\ttest_must_fail git branch --contains $blob &&\n+\ttest_must_fail git branch --no-contains $blob\n '\n \n # We want to set up a case where the walk for the tracking info\n@@ -168,4 +205,15 @@ test_expect_success 'branch --merged with --verbose' '\n \ttest_i18ncmp expect actual\n '\n \n+test_expect_success 'branch --contains combined with --no-contains' '\n+\tgit branch --contains zzz --no-contains topic >actual &&\n+\tcat >expect <<-\\EOF &&\n+\t  master\n+\t  side\n+\t  zzz\n+\tEOF\n+\ttest_cmp expect actual\n+\n+'\n+\n test_done\ndiff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh\nindex d36d5dc124..fc067ed672 100755\n--- a/t/t6302-for-each-ref-filter.sh\n+++ b/t/t6302-for-each-ref-filter.sh\n@@ -93,6 +93,22 @@ test_expect_success 'filtering with --contains' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'filtering with --no-contains' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/tags/one\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --no-contains=two >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'filtering with --contains and --no-contains' '\n+\tcat >expect <<-\\EOF &&\n+\trefs/tags/two\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --contains=two --no-contains=three >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success '%(color) must fail' '\n \ttest_must_fail git for-each-ref --format=\"%(color)%(refname)\"\n '\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 3529c3009c..8a6e8032da 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1424,6 +1424,23 @@ test_expect_success 'checking that first commit is in all tags (relative)' \"\n \ttest_cmp expected actual\n \"\n \n+# All the --contains tests above, but with --no-contains\n+test_expect_success 'checking that first commit is not listed in any tag with --no-contains  (hash)' \"\n+\t>expected &&\n+\tgit tag -l --no-contains $hash1 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n+test_expect_success 'checking that first commit is in all tags (tag)' \"\n+\tgit tag -l --no-contains v1.0 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n+test_expect_success 'checking that first commit is in all tags (relative)' \"\n+\tgit tag -l --no-contains HEAD~2 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n cat > expected <<EOF\n v2.0\n EOF\n@@ -1433,6 +1450,17 @@ test_expect_success 'checking that second commit only has one tag' \"\n \ttest_cmp expected actual\n \"\n \n+cat > expected <<EOF\n+v0.2.1\n+v1.0\n+v1.0.1\n+v1.1.3\n+EOF\n+\n+test_expect_success 'inverse of the last test, with --no-contains' \"\n+\tgit tag -l --no-contains $hash2 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n \n cat > expected <<EOF\n EOF\n@@ -1442,6 +1470,19 @@ test_expect_success 'checking that third commit has no tags' \"\n \ttest_cmp expected actual\n \"\n \n+cat > expected <<EOF\n+v0.2.1\n+v1.0\n+v1.0.1\n+v1.1.3\n+v2.0\n+EOF\n+\n+test_expect_success 'conversely --no-contains on the third commit lists all tags' \"\n+\tgit tag -l --no-contains $hash3 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n # how about a simple merge?\n \n test_expect_success 'creating simple branch' '\n@@ -1463,6 +1504,19 @@ test_expect_success 'checking that branch head only has one tag' \"\n \ttest_cmp expected actual\n \"\n \n+cat > expected <<EOF\n+v0.2.1\n+v1.0\n+v1.0.1\n+v1.1.3\n+v2.0\n+EOF\n+\n+test_expect_success 'checking that branch head with --no-contains lists all but one tag' \"\n+\tgit tag -l --no-contains $hash4 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n test_expect_success 'merging original branch into this branch' '\n \tgit merge --strategy=ours master &&\n         git tag v4.0\n@@ -1484,6 +1538,20 @@ v1.0.1\n v1.1.3\n v2.0\n v3.0\n+EOF\n+\n+test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' \"\n+\tgit tag -l --no-contains $hash3 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n+cat > expected <<EOF\n+v0.2.1\n+v1.0\n+v1.0.1\n+v1.1.3\n+v2.0\n+v3.0\n v4.0\n EOF\n \n@@ -1497,6 +1565,12 @@ test_expect_success 'checking that --contains can be used in non-list mode' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'checking that initial commit is in all tags with --no-contains' \"\n+\t>expected &&\n+\tgit tag -l --no-contains $hash1 v* >actual &&\n+\ttest_cmp expected actual\n+\"\n+\n # mixing modes and options:\n \n test_expect_success 'mixing incompatibles modes and options is forbidden' '\n@@ -1522,10 +1596,13 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag -l -F some file &&\n \ttest_must_fail git tag -v -s &&\n \ttest_must_fail git tag --contains tag-tree &&\n-\ttest_must_fail git tag --contains tag-blob\n+\ttest_must_fail git tag --contains tag-blob &&\n+\ttest_must_fail git tag --no-contains tag-tree &&\n+\ttest_must_fail git tag --no-contains tag-blob &&\n+\ttest_must_fail git tag --contains --no-contains\n '\n \n-for option in --contains --merged --no-merged --points-at\n+for option in --contains --no-contains --merged --no-merged --points-at\n do\n \ttest_expect_success \"mixing incompatible modes with $option is forbidden\" \"\n \t\ttest_must_fail git tag -d $option HEAD &&\n@@ -1792,7 +1869,7 @@ run_with_limited_stack () {\n test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'\n \n # we require ulimit, this excludes Windows\n-test_expect_success ULIMIT_STACK_SIZE '--contains works in a deep repo' '\n+test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' '\n \t>expect &&\n \ti=1 &&\n \twhile test $i -lt 8000\n@@ -1808,7 +1885,9 @@ EOF\"\n \tgit checkout master &&\n \tgit tag far-far-away HEAD^ &&\n \trun_with_limited_stack git tag --contains HEAD >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp expect actual &&\n+\trun_with_limited_stack git tag --no-contains HEAD >actual &&\n+\ttest_line_count \">\" 10 actual\n '\n \n test_expect_success '--format should list tags as per format given' '\n@@ -1870,4 +1949,47 @@ test_expect_success 'ambiguous branch/tags not marked' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '--contains combined with --no-contains' '\n+\t(\n+\t\tgit init no-contains &&\n+\t\tcd no-contains &&\n+\t\ttest_commit v0.1 &&\n+\t\ttest_commit v0.2 &&\n+\t\ttest_commit v0.3 &&\n+\t\ttest_commit v0.4 &&\n+\t\ttest_commit v0.5 &&\n+\t\tcat >expected <<-\\EOF &&\n+\t\tv0.2\n+\t\tv0.3\n+\t\tv0.4\n+\t\tEOF\n+\t\tgit tag --contains v0.2 --no-contains v0.5 >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+# As the docs say, list tags which contain a specified *commit*. We\n+# don't recurse down to tags for trees or blobs pointed to by *those*\n+# commits.\n+test_expect_success 'Does --[no-]contains stop at commits? Yes!' '\n+\tcd no-contains &&\n+\tblob=$(git rev-parse v0.3:v0.3.t) &&\n+\ttree=$(git rev-parse v0.3^{tree}) &&\n+\tgit tag tag-blob $blob &&\n+\tgit tag tag-tree $tree &&\n+\tgit tag --contains v0.3 >actual &&\n+\tcat >expected <<-\\EOF &&\n+\tv0.3\n+\tv0.4\n+\tv0.5\n+\tEOF\n+\ttest_cmp expected actual &&\n+\tgit tag --no-contains v0.3 >actual &&\n+\tcat >expected <<-\\EOF &&\n+\tv0.1\n+\tv0.2\n+\tEOF\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.11.0\n\n"},{"id":"315315","messageId":"20170324184059.5374-8-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 07/16] tag tests: fix a typo in a test description","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:50Z","receivedAt":"2017-03-24T18:42:15Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change \"suceed\" to \"succeed\" in a test description. The typo has been\nhere since the code was originally added in commit ef5a6fb597 (\"Add\ntest-script for git-tag\", 2007-06-28).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7004-tag.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 830eff948e..63ee2cf727 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -136,7 +136,7 @@ test_expect_success \\\n \t'test $(git tag -l mytag) = mytag'\n \n test_expect_success \\\n-\t'listing tags using a non-matching pattern should suceed' \\\n+\t'listing tags using a non-matching pattern should succeed' \\\n \t'git tag -l xxx'\n \n test_expect_success \\\n-- \n2.11.0\n\n"},{"id":"315316","messageId":"20170324184059.5374-17-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 16/16] tag: add tests for --with and --without","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:59Z","receivedAt":"2017-03-24T18:42:19Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the test suite to test for these synonyms for --contains and\n--no-contains, respectively.\n\nBefore this change there were no tests for them at all. This doesn't\nexhaustively test for them as well as their --contains and\n--no-contains synonyms, but at least it's something.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7004-tag.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 8a6e8032da..6143113dbb 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1599,10 +1599,12 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '\n \ttest_must_fail git tag --contains tag-blob &&\n \ttest_must_fail git tag --no-contains tag-tree &&\n \ttest_must_fail git tag --no-contains tag-blob &&\n-\ttest_must_fail git tag --contains --no-contains\n+\ttest_must_fail git tag --contains --no-contains &&\n+\ttest_must_fail git tag --no-with HEAD &&\n+\ttest_must_fail git tag --no-without HEAD\n '\n \n-for option in --contains --no-contains --merged --no-merged --points-at\n+for option in --contains --with --no-contains --without --merged --no-merged --points-at\n do\n \ttest_expect_success \"mixing incompatible modes with $option is forbidden\" \"\n \t\ttest_must_fail git tag -d $option HEAD &&\n-- \n2.11.0\n\n"},{"id":"315317","messageId":"20170324184059.5374-16-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 15/16] ref-filter: reflow recently changed branch/tag/for-each-ref docs","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:58Z","receivedAt":"2017-03-24T18:42:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reflow the recently changed branch/tag-for-each-ref\ndocumentation. This change shows no changes under --word-diff, except\nthe innocuous change of moving git-tag.txt's \"[--sort=<key>]\" around\nslightly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-branch.txt | 15 ++++++++-------\n Documentation/git-tag.txt    |  7 ++++---\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex e4b5d5c3e1..5e175ec339 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -10,9 +10,9 @@ SYNOPSIS\n [verse]\n 'git branch' [--color[=<when>] | --no-color] [-r | -a]\n \t[--list] [-v [--abbrev=<length> | --no-abbrev]]\n-\t[--column[=<options>] | --no-column]\n+\t[--column[=<options>] | --no-column] [--sort=<key>]\n \t[(--merged | --no-merged) [<commit>]]\n-\t[--contains [<commit]] [--no-contains [<commit>]] [--sort=<key>]\n+\t[--contains [<commit]] [--no-contains [<commit>]]\n \t[--points-at <object>] [--format=<format>] [<pattern>...]\n 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\n 'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\n@@ -36,11 +36,12 @@ as branch creation.\n \n With `--contains`, shows only the branches that contain the named commit\n (in other words, the branches whose tip commits are descendants of the\n-named commit), `--no-contains` inverts it. With `--merged`, only branches merged into the named\n-commit (i.e. the branches whose tip commits are reachable from the named\n-commit) will be listed.  With `--no-merged` only branches not merged into\n-the named commit will be listed.  If the <commit> argument is missing it\n-defaults to `HEAD` (i.e. the tip of the current branch).\n+named commit), `--no-contains` inverts it. With `--merged`, only branches\n+merged into the named commit (i.e. the branches whose tip commits are\n+reachable from the named commit) will be listed.  With `--no-merged` only\n+branches not merged into the named commit will be listed.  If the <commit>\n+argument is missing it defaults to `HEAD` (i.e. the tip of the current\n+branch).\n \n The command's second form creates a new branch head named <branchname>\n which points to the current `HEAD`, or <start-point> if given.\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 1be6570c90..f8a0b787f4 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -12,9 +12,10 @@ SYNOPSIS\n 'git tag' [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>]\n \t<tagname> [<commit> | <object>]\n 'git tag' -d <tagname>...\n-'git tag' [-n[<num>]] -l [--contains <commit>] [--contains <commit>] [--points-at <object>]\n-\t[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>]\n-\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]\n+'git tag' [-n[<num>]] -l [--contains <commit>] [--contains <commit>]\n+\t[--points-at <object>] [--column[=<options>] | --no-column]\n+\t[--create-reflog] [--sort=<key>] [--format=<format>]\n+\t[--[no-]merged [<commit>]] [<pattern>...]\n 'git tag' -v [--format=<format>] <tagname>...\n \n DESCRIPTION\n-- \n2.11.0\n\n"},{"id":"315318","messageId":"20170324184059.5374-14-avarab@gmail.com","threadId":"45500","inReplyTo":"20170324184059.5374-1-avarab@gmail.com","subject":"[PATCH v4 13/16] tag: change --point-at to default to HEAD","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-03-24T18:40:56Z","receivedAt":"2017-03-24T18:42:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the --points-at option to default to HEAD for consistency with\nits siblings --contains, --merged etc. which default to\nHEAD. Previously we'd get:\n\n    $ git tag --points-at 2>&1 | head -n 1\n    error: option `points-at' requires a value\n\nThis changes behavior added in commit ae7706b9ac (tag: add --points-at\nlist option, 2012-02-08).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-tag.txt | 3 ++-\n builtin/tag.c             | 3 ++-\n t/t7004-tag.sh            | 9 ++++++++-\n 3 files changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 4d289f5dd5..d5cdb18d96 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -139,7 +139,8 @@ This option is only applicable when listing tags without annotation lines.\n \tcommit (`HEAD` if not specified), incompatible with `--merged`.\n \n --points-at <object>::\n-\tOnly list tags of the given object. Implies `--list`.\n+\tOnly list tags of the given object (HEAD if not\n+\tspecified). Implies `--list`.\n \n -m <msg>::\n --message=<msg>::\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 3c686961db..8bf6d85176 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -431,7 +431,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\t     N_(\"field name to sort on\"), &parse_opt_ref_sorting),\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"points-at\", &filter.points_at, N_(\"object\"),\n-\t\t\tN_(\"print only tags of the object\"), 0, parse_opt_object_name\n+\t\t\tN_(\"print only tags of the object\"), PARSE_OPT_LASTARG_DEFAULT,\n+\t\t\tparse_opt_object_name, (intptr_t) \"HEAD\"\n \t\t},\n \t\tOPT_STRING(  0 , \"format\", &format, N_(\"format\"), N_(\"format to use for the output\")),\n \t\tOPT_BOOL('i', \"ignore-case\", &icase, N_(\"sorting and filtering are case insensitive\")),\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 5823de16aa..3529c3009c 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1534,7 +1534,8 @@ do\n \t\"\n \ttest_expect_success \"Doing 'git tag --list-like $option <commit> <pattern> is permitted\" \"\n \t\tgit tag -n $option HEAD HEAD &&\n-\t\tgit tag $option HEAD HEAD\n+\t\tgit tag $option HEAD HEAD &&\n+\t\tgit tag $option\n \t\"\n done\n \n@@ -1546,6 +1547,12 @@ test_expect_success '--points-at can be used in non-list mode' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '--points-at is a synonym for --points-at HEAD' '\n+\techo v4.0 >expect &&\n+\tgit tag --points-at >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success '--points-at finds lightweight tags' '\n \techo v4.0 >expect &&\n \tgit tag --points-at v4.0 >actual &&\n-- \n2.11.0\n\n"}]}