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

From: Junio C Hamano <[email-masked]>
Date: Mon, 26 Sep 2022 11:12:55 -0700

Rubén Justo <[email-masked]> writes:

> When the repository does not yet has commits, some errors describe that

"has" -> "have".

>  builtin/branch.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)

Tests to protect the new behaviour from getting broken by future
developers are missing.

> diff --git a/builtin/branch.c b/builtin/branch.c
> index 55cd9a6e99..5ca35064f3 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -538,6 +538,13 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
>  			die(_("Invalid branch name: '%s'"), oldname);
>  	}
>  
> +	if (copy && !ref_exists(oldref.buf)) {
> +		if (!strcmp(head, oldname))
> +			die(_("No commit on branch '%s' yet."), oldname);
> +		else
> +			die(_("No branch named '%s'."), oldname);
> +	}

Let's not make it worse by starting the die() message with capital
letters, even though the existing "git branch" error messages are
already mixture that they need to be cleaned up later.

Thanks.