git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ville Skyttä" <ville.skytta@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode
Date: Mon, 01 Apr 2024 08:31:22 -0700	[thread overview]
Message-ID: <xmqqttklcd6d.fsf@gitster.g> (raw)
In-Reply-To: <20240401113033.28709-1-ville.skytta@iki.fi> ("Ville Skyttä"'s message of "Mon, 1 Apr 2024 11:30:33 +0000")

Ville Skyttä <ville.skytta@iki.fi> writes:

> `GIT_PS1_SHOWCONFLICTSTATE` is a user variable that might not be set,
> causing errors when the shell is in `nounset` mode.
>
> Take into account on access by falling back to an empty string.
>
> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
> ---

Obviously a good thing to do.

A related tangent is that

    $ git grep -e '$GIT_PS1' -e '${GIT_PS1_[A-Z0-9_]*}' contrib/completion/

shows a hit for the line with SHOWCONFLICTSTATE, plus two lines with
GIT_PS1_SHOWUPSTREAM that lack the "if unset then use this value".
Do you want to do another patch to fix them, or are they good as-is
for some reason?

Thanks.

>  contrib/completion/git-prompt.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index 71f179cba3..3826f52dec 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -528,7 +528,7 @@ __git_ps1 ()
>  	fi
>  
>  	local conflict="" # state indicator for unresolved conflicts
> -	if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
> +	if [[ "${GIT_PS1_SHOWCONFLICTSTATE-}" == "yes" ]] &&
>  	   [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
>  		conflict="|CONFLICT"
>  	fi


  reply	other threads:[~2024-04-01 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 11:30 [PATCH] completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode Ville Skyttä
2024-04-01 15:31 ` Junio C Hamano [this message]
2024-04-01 17:07   ` Ville Skyttä
2024-04-01 17:26     ` Junio C Hamano
2024-04-01 19:10       ` Ville Skyttä
2024-04-01 19:38         ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqttklcd6d.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ville.skytta@iki.fi \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).