--merged [<commit>]::
Only list branches whose tips are reachable from the
- specified commit (HEAD if not specified). Implies `--list`.
+ specified commit (HEAD if not specified). Implies `--list`,
+ incompatible with `--no-merged`.
--no-merged [<commit>]::
Only list branches whose tips are not reachable from the
- specified commit (HEAD if not specified). Implies `--list`.
+ specified commit (HEAD if not specified). Implies `--list`,
+ incompatible with `--merged`.
<branchname>::
The name of the branch to create or delete.
--merged [<object>]::
Only list refs whose tips are reachable from the
- specified commit (HEAD if not specified).
+ specified commit (HEAD if not specified),
+ incompatible with `--no-merged`.
--no-merged [<object>]::
Only list refs whose tips are not reachable from the
- specified commit (HEAD if not specified).
+ specified commit (HEAD if not specified),
+ incompatible with `--merged`.
--contains [<object>]::
Only list refs which contain the specified commit (HEAD if not
--merged [<commit>]::
Only list tags whose commits are reachable from the specified
- commit (`HEAD` if not specified).
+ commit (`HEAD` if not specified), incompatible with `--no-merged`.
--no-merged [<commit>]::
Only list tags whose commits are not reachable from the specified
- commit (`HEAD` if not specified).
+ commit (`HEAD` if not specified), incompatible with `--merged`.
--points-at <object>::
Only list tags of the given object.
{
struct ref_filter *rf = opt->value;
unsigned char sha1[20];
+ int no_merged = starts_with(opt->long_name, "no");
- rf->merge = starts_with(opt->long_name, "no")
+ if (rf->merge) {
+ if (no_merged) {
+ return opterror(opt, "is incompatible with --merged", 0);
+ } else {
+ return opterror(opt, "is incompatible with --no-merged", 0);
+ }
+ }
+
+ rf->merge = no_merged
? REF_FILTER_MERGED_OMIT
: REF_FILTER_MERGED_INCLUDE;
test_must_fail git branch --merged 0000000000000000000000000000000000000000
'
+test_expect_success '--merged is incompatible with --no-merged' '
+ test_must_fail git branch --merged HEAD --no-merged HEAD
+'
+
test_expect_success 'tracking with unexpected .fetch refspec' '
rm -rf a b c d &&
git init a &&
test_cmp expect actual
'
+test_expect_success '--merged is incompatible with --no-merged' '
+ test_must_fail git for-each-ref --merged HEAD --no-merged HEAD
+'
+
test_done
test_must_fail git tag --merged=mergetest-2 foo
'
+test_expect_success '--merged is incompatible with --no-merged' '
+ test_must_fail git tag --merged HEAD --no-merged HEAD
+'
+
test_expect_success '--merged shows merged tags' '
cat >expect <<-\EOF &&
mergetest-1