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

Re: [PATCH] completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2024, 15:31 UTC
Message-ID
<xmqqttklcd6d.fsf@gitster.g>
In-Reply-To
<20240401113033.28709-1-ville.skytta@iki.fi>
Ville Skyttä <ville.skytta@iki.fi> writes:
Show 7 quoted lines
> `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.
Show 16 quoted lines
>  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
Previous: Ville SkyttäNext: Ville Skyttä
Message 2 of 6 in “completion: fix prompt with unset SHOWCONFLICTSTATE in nounset mode”
  1. completion: fix prompt with unset SHOWCONFLICTSTATE in nounset modeVille Skyttä, Apr 1, 2024
  2. Junio C HamanoApr 1, 2024
  3. Ville SkyttäApr 1, 2024
  4. Junio C HamanoApr 1, 2024
  5. Ville SkyttäApr 1, 2024
  6. Junio C HamanoApr 1, 2024

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.