Re: [PATCH v3] branch: description for non-existent branch errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 7, 2022 at 8:49 PM Rubén Justo <rjusto@xxxxxxxxx> wrote:
> [...]
> Make the error descriptions for those branch operations with unborn or
> non-existent branches, more informative.
> [...]
> Signed-off-by: Rubén Justo <rjusto@xxxxxxxxx>
> ---
> diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
> @@ -7,6 +7,28 @@ test_description='test show-branch'
> +test_expect_success 'error descriptions on empty repository' '
> +       current=$(git branch --show-current) &&
> +       cat >expect <<-EOF &&
> +       error: No commit on branch '\''$current'\'' yet.
> +       EOF

It's a matter of taste, but leaving and re-entering the single-quoted
context, along with escaping, can make for a difficult read. You could
instead take advantage of the SQ variable already defined by the test
scripts:

    echo "error: No commit on branch $SQ$current$SQ yet." >expect &&

Not worth a re-roll, of course.

> +test_expect_success 'fatal descriptions on empty repository' '
> +       current=$(git branch --show-current) &&
> +       cat >expect <<-EOF &&
> +       fatal: No commit on branch '\''$current'\'' yet.
> +       EOF

Ditto.

> +test_expect_success 'error descriptions on non-existent branch' '
> +       cat >expect <<-EOF &&
> +       error: No branch named '\''non-existent'\'.'
> +       EOF

Likewise.

> +test_expect_success 'fatal descriptions on non-existent branch' '
> +       cat >expect <<-EOF &&
> +       fatal: branch '\''non-existent'\'' does not exist
> +       EOF

Same.

> +       test_must_fail git branch --set-upstream-to=non-existent non-existent 2>actual &&
> +       test_cmp expect actual &&
> +
> +       cat >expect <<-EOF &&
> +       fatal: No branch named '\''non-existent'\''.
> +       EOF

Again.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux