From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Tao Klerks via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Tao Klerks <tao@klerks.biz>
Subject: Re: [PATCH v3 2/2] t3200: tests for new branch.autosetupmerge option "simple"
Date: Mon, 28 Feb 2022 10:34:32 +0100 [thread overview]
Message-ID: <220228.86o82r5nzm.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <d5b18c7949fdea966d31b2b8ca3f8aa8ed3a86b6.1646032466.git.gitgitgadget@gmail.com>
On Mon, Feb 28 2022, Tao Klerks via GitGitGadget wrote:
> From: Tao Klerks <tao@klerks.biz>
>
> In the previous commit a new autosetupmerge option was introduced.
>
> Extend the existing branch tests with three new cases testing this
> option - the obvious matching-name and non-matching-name cases, and
> also a non-matching-ref-type case.
>
> The matching-name case needs to temporarily create an independent
> repo to fetch from, as the general strategy of using the local repo as
> the remote in these tests precludes locally branching with the same
> name as in the "remote".
>
> Signed-off-by: Tao Klerks <tao@klerks.biz>
> ---
> t/t3200-branch.sh | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index 7a0ff75ba86..15cc58f1e64 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -886,6 +886,41 @@ test_expect_success 'branch from tag w/--track causes failure' '
> test_must_fail git branch --track my11 foobar
> '
>
> +test_expect_success 'simple tracking works when remote branch name matches' '
> + test_create_repo otherserver &&
> + test_commit -C otherserver my_commit 1 &&
> + git -C otherserver branch feature &&
> + git config branch.autosetupmerge simple &&
> + git config remote.otherserver.url otherserver &&
> + git config remote.otherserver.fetch refs/heads/*:refs/remotes/otherserver/* &&
Shouldn't these use test_config, or if the tests below need them do that
via a helper, so later added tests don't need to reset this state?
> + git fetch otherserver &&
> + git branch feature otherserver/feature &&
> + rm -fr otherserver &&
Instead of "rm -rf" after, do above:
test_when_finished "rm -rf otherserver" &&
git init otherserver
(you don't need "test_create_repo" either, just use "git init")
> + test $(git config branch.feature.remote) = otherserver &&
> + test $(git config branch.feature.merge) = refs/heads/feature
Use:
echo otherserver >expect &&
git config ... >actual &&
test_cmp expect actual
etc., the pattern you're using here will hide git's exit code on
segfaults, abort() etc., and also makes for less useful debug info on
failure than test_cmp.
> +'
> +
> +test_expect_success 'simple tracking skips when remote branch name does not match' '
> + git config branch.autosetupmerge simple &&
> + git config remote.local.url . &&
> + git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
ditto config setup above, this is quite hard to follow in sequence since
yo uneed to reason about all existing config. Let's start with a clean
slate for each test_expect_success and setup the specific config we want
instead.fallow since
> + (git show-ref -q refs/remotes/local/main || git fetch local) &&
This likewise hides segfaults etc. Use:
test_might_fail git show-ref ...
But maybe this whole thing should use "git rev-parse --verify" or
something?
> + git branch my-other local/main &&
> + test -z "$(git config branch.my-other.remote)" &&
> + test -z "$(git config branch.my-other.merge)"
ditto test_cmp comments, but here:
git ... >out &&
test_must_be_empty out
> +'
> +
> +test_expect_success 'simple tracking skips when remote ref is not a branch' '
> + git config branch.autosetupmerge simple &&
> + git tag mytag12 main &&
> + git config remote.localtags.url . &&
> + git config remote.localtags.fetch refs/tags/*:refs/remotes/localtags/* &&
> + (git show-ref -q refs/remotes/localtags/mytag12 || git fetch localtags) &&
> + git branch mytag12 localtags/mytag12 &&
> + test -z "$(git config branch.mytag12.remote)" &&
> + test -z "$(git config branch.mytag12.merge)"
ditto above.
> +'
> +
> test_expect_success '--set-upstream-to fails on multiple branches' '
> echo "fatal: too many arguments to set new upstream" >expect &&
> test_must_fail git branch --set-upstream-to main a b c 2>err &&
next prev parent reply other threads:[~2022-02-28 9:39 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 9:45 [PATCH 0/3] adding new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-24 9:45 ` [PATCH 1/3] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-24 19:20 ` Junio C Hamano
2022-02-24 9:45 ` [PATCH 2/3] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-24 9:45 ` [PATCH 3/3] branch documentation: new autosetupmerge " Tao Klerks via GitGitGadget
2022-02-24 19:38 ` Junio C Hamano
2022-02-25 18:52 ` [PATCH v2 0/2] adding new branch.autosetupmerge " Tao Klerks via GitGitGadget
2022-02-25 18:52 ` [PATCH v2 1/2] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-25 20:15 ` Junio C Hamano
2022-02-27 23:59 ` Tao Klerks
2022-02-25 18:52 ` [PATCH v2 2/2] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-28 7:14 ` [PATCH v3 0/2] adding " Tao Klerks via GitGitGadget
2022-02-28 7:14 ` [PATCH v3 1/2] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-28 10:39 ` Ævar Arnfjörð Bjarmason
2022-03-02 9:35 ` Tao Klerks
2022-03-20 17:00 ` Tao Klerks
2022-02-28 7:14 ` [PATCH v3 2/2] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-28 9:34 ` Ævar Arnfjörð Bjarmason [this message]
2022-03-01 2:58 ` Eric Sunshine
2022-03-01 9:59 ` Tao Klerks
2022-03-01 9:59 ` Tao Klerks
2022-03-21 6:17 ` [PATCH v4] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-04-18 18:15 ` Josh Steadmon
2022-04-20 5:12 ` Tao Klerks
2022-04-20 17:19 ` Josh Steadmon
2022-04-20 17:43 ` Junio C Hamano
2022-04-20 21:31 ` Tao Klerks
2022-04-21 1:53 ` Junio C Hamano
2022-04-21 10:04 ` Tao Klerks
2022-04-22 2:27 ` Junio C Hamano
2022-04-22 9:24 ` Tao Klerks
2022-04-22 13:27 ` Tao Klerks
2022-04-23 4:44 ` Junio C Hamano
2022-04-24 11:57 ` Tao Klerks
2022-04-29 7:31 ` Tao Klerks
2022-04-29 9:56 ` [PATCH v5 0/3] New options to support "simple" centralized workflow Tao Klerks via GitGitGadget
2022-04-29 9:56 ` [PATCH v5 1/3] branch: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-04-29 9:56 ` [PATCH v5 2/3] push: default to single remote even when not named origin Tao Klerks via GitGitGadget
2022-04-29 9:56 ` [PATCH v5 3/3] push: new config option "push.autoSetupRemote" supports "simple" push Tao Klerks via GitGitGadget
2022-04-29 18:50 ` [PATCH v5 0/3] New options to support "simple" centralized workflow Junio C Hamano
2022-04-30 15:48 ` Tao Klerks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=220228.86o82r5nzm.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=tao@klerks.biz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).