2007-11-19 07:22:00 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
>file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch -M main &&
|
2007-11-19 07:22:00 +01:00
|
|
|
git branch side &&
|
|
|
|
|
|
|
|
echo 1 >file &&
|
|
|
|
test_tick &&
|
2020-12-17 02:07:02 +01:00
|
|
|
git commit -a -m "second on main" &&
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
git checkout side &&
|
|
|
|
echo 1 >file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -a -m "second on side" &&
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git merge main
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'branch --contains=main' '
|
2007-11-19 07:22:00 +01:00
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --contains=main >actual &&
|
2007-11-19 07:22:00 +01:00
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main" && echo "* side"
|
2007-11-19 07:22:00 +01:00
|
|
|
} >expect &&
|
2008-03-12 22:36:36 +01:00
|
|
|
test_cmp expect actual
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'branch --contains main' '
|
2007-11-19 07:22:00 +01:00
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --contains main >actual &&
|
2007-11-19 07:22:00 +01:00
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main" && echo "* side"
|
2007-11-19 07:22:00 +01:00
|
|
|
} >expect &&
|
2008-03-12 22:36:36 +01:00
|
|
|
test_cmp expect actual
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'branch --no-contains=main' '
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --no-contains=main >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'branch --no-contains main' '
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --no-contains main >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-19 07:22:00 +01:00
|
|
|
test_expect_success 'branch --contains=side' '
|
|
|
|
|
|
|
|
git branch --contains=side >actual &&
|
|
|
|
{
|
|
|
|
echo "* side"
|
|
|
|
} >expect &&
|
2008-03-12 22:36:36 +01:00
|
|
|
test_cmp expect actual
|
2007-11-19 07:22:00 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
test_expect_success 'branch --no-contains=side' '
|
|
|
|
|
|
|
|
git branch --no-contains=side >actual &&
|
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main"
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-01-31 07:46:11 +01:00
|
|
|
test_expect_success 'branch --contains with pattern implies --list' '
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --contains=main main >actual &&
|
2013-01-31 07:46:11 +01:00
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main"
|
2013-01-31 07:46:11 +01:00
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
test_expect_success 'branch --no-contains with pattern implies --list' '
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --no-contains=main main >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-04-18 18:30:15 +02:00
|
|
|
test_expect_success 'side: branch --merged' '
|
|
|
|
|
|
|
|
git branch --merged >actual &&
|
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main" &&
|
2008-04-18 18:30:15 +02:00
|
|
|
echo "* side"
|
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-01-31 07:46:11 +01:00
|
|
|
test_expect_success 'branch --merged with pattern implies --list' '
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --merged=side main >actual &&
|
2013-01-31 07:46:11 +01:00
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo " main"
|
2013-01-31 07:46:11 +01:00
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-04-18 18:30:15 +02:00
|
|
|
test_expect_success 'side: branch --no-merged' '
|
|
|
|
|
|
|
|
git branch --no-merged >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
2008-04-18 18:30:15 +02:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'main: branch --merged' '
|
2008-04-18 18:30:15 +02:00
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git checkout main &&
|
2008-04-18 18:30:15 +02:00
|
|
|
git branch --merged >actual &&
|
|
|
|
{
|
2020-12-17 02:07:02 +01:00
|
|
|
echo "* main"
|
2008-04-18 18:30:15 +02:00
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'main: branch --no-merged' '
|
2008-04-18 18:30:15 +02:00
|
|
|
|
|
|
|
git branch --no-merged >actual &&
|
|
|
|
{
|
|
|
|
echo " side"
|
|
|
|
} >expect &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-01-31 07:46:11 +01:00
|
|
|
test_expect_success 'branch --no-merged with pattern implies --list' '
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --no-merged=main main >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
2013-01-31 07:46:11 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'implicit --list conflicts with modification options' '
|
|
|
|
|
2020-12-17 02:07:02 +01:00
|
|
|
test_must_fail git branch --contains=main -d &&
|
|
|
|
test_must_fail git branch --contains=main -m foo &&
|
|
|
|
test_must_fail git branch --no-contains=main -d &&
|
|
|
|
test_must_fail git branch --no-contains=main -m foo
|
2013-01-31 07:46:11 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2017-03-23 14:05:18 +01:00
|
|
|
test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
|
2020-12-17 02:07:02 +01:00
|
|
|
test_must_fail git branch --contains main^{tree} &&
|
2017-03-23 14:05:18 +01:00
|
|
|
blob=$(git hash-object -w --stdin <<-\EOF
|
|
|
|
Some blob
|
|
|
|
EOF
|
|
|
|
) &&
|
ref-filter: add --no-contains option to tag/branch/for-each-ref
Change the tag, branch & for-each-ref commands to have a --no-contains
option in addition to their longstanding --contains options.
This allows for finding the last-good rollout tag given a known-bad
<commit>. Given a hypothetically bad commit cf5c7253e0, the git
version to revert to can be found with this hacky two-liner:
(git tag -l 'v[0-9]*'; git tag -l --contains cf5c7253e0 'v[0-9]*') |
sort | uniq -c | grep -E '^ *1 ' | awk '{print $2}' | tail -n 10
With this new --no-contains option the same can be achieved with:
git tag -l --no-contains cf5c7253e0 'v[0-9]*' | sort | tail -n 10
As the filtering machinery is shared between the tag, branch &
for-each-ref commands, implement this for those commands too. A
practical use for this with "branch" is e.g. finding branches which
were branched off between v2.8.0 and v2.10.0:
git branch --contains v2.8.0 --no-contains v2.10.0
The "describe" command also has a --contains option, but its semantics
are unrelated to what tag/branch/for-each-ref use --contains for. A
--no-contains option for "describe" wouldn't make any sense, other
than being exactly equivalent to not supplying --contains at all,
which would be confusing at best.
Add a --without option to "tag" as an alias for --no-contains, for
consistency with --with and --contains. The --with option is
undocumented, and possibly the only user of it is
Junio (<xmqqefy71iej.fsf@gitster.mtv.corp.google.com>). But it's
trivial to support, so let's do that.
The additions to the the test suite are inverse copies of the
corresponding --contains tests. With this change --no-contains for
tag, branch & for-each-ref is just as well tested as the existing
--contains option.
In addition to those tests, add a test for "tag" which asserts that
--no-contains won't find tree/blob tags, which is slightly
unintuitive, but consistent with how --contains works & is documented.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 19:40:57 +01:00
|
|
|
test_must_fail git branch --contains $blob &&
|
|
|
|
test_must_fail git branch --no-contains $blob
|
2017-03-23 14:05:18 +01:00
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:38 +02:00
|
|
|
test_expect_success 'multiple branch --contains' '
|
2020-12-17 02:07:02 +01:00
|
|
|
git checkout -b side2 main &&
|
2020-09-16 04:08:38 +02:00
|
|
|
>feature &&
|
|
|
|
git add feature &&
|
|
|
|
git commit -m "add feature" &&
|
2020-12-17 02:07:02 +01:00
|
|
|
git checkout -b next main &&
|
2020-09-16 04:08:38 +02:00
|
|
|
git merge side &&
|
|
|
|
git branch --contains side --contains side2 >actual &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
* next
|
|
|
|
side
|
|
|
|
side2
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:40 +02:00
|
|
|
test_expect_success 'multiple branch --merged' '
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --merged next --merged main >actual &&
|
2020-09-16 04:08:40 +02:00
|
|
|
cat >expect <<-\EOF &&
|
2020-12-17 02:07:02 +01:00
|
|
|
main
|
2020-09-16 04:08:40 +02:00
|
|
|
* next
|
|
|
|
side
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:38 +02:00
|
|
|
test_expect_success 'multiple branch --no-contains' '
|
|
|
|
git branch --no-contains side --no-contains side2 >actual &&
|
|
|
|
cat >expect <<-\EOF &&
|
2020-12-17 02:07:02 +01:00
|
|
|
main
|
2020-09-16 04:08:38 +02:00
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:40 +02:00
|
|
|
test_expect_success 'multiple branch --no-merged' '
|
2020-12-17 02:07:02 +01:00
|
|
|
git branch --no-merged next --no-merged main >actual &&
|
2020-09-16 04:08:40 +02:00
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
side2
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:38 +02:00
|
|
|
test_expect_success 'branch --contains combined with --no-contains' '
|
2020-12-17 02:07:02 +01:00
|
|
|
git checkout -b seen main &&
|
2020-09-16 04:08:38 +02:00
|
|
|
git merge side &&
|
|
|
|
git merge side2 &&
|
|
|
|
git branch --contains side --no-contains side2 >actual &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
next
|
|
|
|
side
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2020-09-16 04:08:40 +02:00
|
|
|
test_expect_success 'branch --merged combined with --no-merged' '
|
|
|
|
git branch --merged seen --no-merged next >actual &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
* seen
|
|
|
|
side2
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-09-18 12:49:43 +02:00
|
|
|
# We want to set up a case where the walk for the tracking info
|
|
|
|
# of one branch crosses the tip of another branch (and make sure
|
|
|
|
# that the latter walk does not mess up our flag to see if it was
|
|
|
|
# merged).
|
|
|
|
#
|
2020-12-17 02:07:02 +01:00
|
|
|
# Here "topic" tracks "main" with one extra commit, and "zzz" points to the
|
|
|
|
# same tip as main The name "zzz" must come alphabetically after "topic"
|
2014-09-18 12:49:43 +02:00
|
|
|
# as we process them in that order.
|
2020-12-17 02:07:02 +01:00
|
|
|
test_expect_success 'branch --merged with --verbose' '
|
|
|
|
git branch --track topic main &&
|
2014-09-18 12:49:43 +02:00
|
|
|
git branch zzz topic &&
|
|
|
|
git checkout topic &&
|
|
|
|
test_commit foo &&
|
|
|
|
git branch --merged topic >actual &&
|
|
|
|
cat >expect <<-\EOF &&
|
2020-12-17 02:07:02 +01:00
|
|
|
main
|
2014-09-18 12:49:43 +02:00
|
|
|
* topic
|
|
|
|
zzz
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual &&
|
|
|
|
git branch --verbose --merged topic >actual &&
|
2019-08-18 21:16:33 +02:00
|
|
|
cat >expect <<-EOF &&
|
2020-10-23 16:00:05 +02:00
|
|
|
main $(git rev-parse --short main) second on main
|
|
|
|
* topic $(git rev-parse --short topic ) [ahead 1] foo
|
|
|
|
zzz $(git rev-parse --short zzz ) second on main
|
2014-09-18 12:49:43 +02:00
|
|
|
EOF
|
2021-02-11 02:53:53 +01:00
|
|
|
test_cmp expect actual
|
2014-09-18 12:49:43 +02:00
|
|
|
'
|
|
|
|
|
2007-11-19 07:22:00 +01:00
|
|
|
test_done
|