git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 8, 2022, 03:27 UTC
Message-ID
<CAPig+cT+Yeh95p-2PgMDYz+_AxeEA72i-zLuQu11QEyWAt8kiA@mail.gmail.com>
In-Reply-To
<8d627a2c-923f-181f-a03b-15f370c4dd0f@gmail.com>
On Fri, Oct 7, 2022 at 8:49 PM Rubén Justo <rjusto@gmail.com> wrote:
Show 13 quoted lines
> [...]
> Make the error descriptions for those branch operations with unborn or
> non-existent branches, more informative.
> [...]
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
> 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.
Show 5 quoted lines
> +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.
Show 6 quoted lines
> +       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.
Previous: Rubén JustoNext: Rubén Justo
Message 14 of 16 in “branch: description for non-existent branch errors”
  1. branch: description for non-existent branch errorsRubén Justo, Sep 22, 2022
  2. branch: description for non-existent branch errorsRubén Justo, Sep 24, 2022
  3. Junio C HamanoSep 26, 2022
  4. Rubén JustoSep 26, 2022
  5. Junio C HamanoSep 27, 2022
  6. Junio C HamanoSep 28, 2022
  7. Junio C HamanoSep 28, 2022
  8. Rubén JustoSep 28, 2022
  9. Junio C HamanoSep 29, 2022
  10. branch: description for non-existent branch errorsRubén Justo, Sep 30, 2022
  11. Bagas SanjayaOct 1, 2022
  12. Rubén JustoOct 2, 2022
  13. branch: description for non-existent branch errorsRubén Justo, Oct 8, 2022
  14. Eric SunshineOct 8, 2022
  15. Rubén JustoOct 8, 2022
  16. Junio C HamanoOct 9, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.