Re: [PATCH v3] branch: description for non-existent branch errors
- From
Rubén Justo <rjusto@gmail.com>
- Date
- Oct 8, 2022, 08:54 UTC
- Message-ID
- <7a332503-d267-6d2c-c2bd-d072411ca408@gmail.com>
- In-Reply-To
- <CAPig+cT+Yeh95p-2PgMDYz+_AxeEA72i-zLuQu11QEyWAt8kiA@mail.gmail.com>
On 8/10/22 5:27, Eric Sunshine wrote:
Show 31 quoted lines
> On Fri, Oct 7, 2022 at 8:49 PM Rubén Justo <rjusto@gmail.com> wrote: >> [...] >> 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. > >> +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.
Thanks, I didn't know about $SQ.
'\''$current'\'' vs $SQ$current$SQ vs ${SQ}$current${SQ}I also find ugly that escaping, but I think is harder to read and error prone to use $SQ here.. :-/