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

Re: git-sh-prompt: bash: GIT_PS1_COMPRESSSPARSESTATE: unbound variable

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2021, 05:01 UTC
Message-ID
<xmqqv97nb51b.fsf@gitster.g>
In-Reply-To
<CABPp-BGERNLKbLA_r7i7+r+v7YK6xT00_5n9ebESb2SzLhC0Cg@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 7 quoted lines
> Yeah, I accidentally was relying on undefined-translates-to-empty,
> which breaks under set -u.  I can duplicate the precise error, and
> your fix below is exactly how I fixed it too, before seeing you posted
> the same fix.
>
> I'll post a patch with you as author...and some questions on what to
> do with the rest of the commit message and attribution tags.

Nah, please take full credit for it. It is more work to test the result of the change than just running a grep and coming up with "I wonder if this would work...".

Thanks for a sanity check.
Show 39 quoted lines
>
>> Thanks.
>>
>>  contrib/completion/git-prompt.sh | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git i/contrib/completion/git-prompt.sh w/contrib/completion/git-prompt.sh
>> index 4640a1535d..b9485f4016 100644
>> --- i/contrib/completion/git-prompt.sh
>> +++ w/contrib/completion/git-prompt.sh
>> @@ -139,7 +139,7 @@ __git_ps1_show_upstream ()
>>
>>         # parse configuration values
>>         local option
>> -       for option in ${GIT_PS1_SHOWUPSTREAM}; do
>> +       for option in ${GIT_PS1_SHOWUPSTREAM-}; do
>>                 case "$option" in
>>                 git|svn) upstream="$option" ;;
>>                 verbose) verbose=1 ;;
>> @@ -433,8 +433,8 @@ __git_ps1 ()
>>         fi
>>
>>         local sparse=""
>> -       if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
>> -          [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
>> +       if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
>> +          [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
>>            [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
>>                 sparse="|SPARSE"
>>         fi
>> @@ -543,7 +543,7 @@ __git_ps1 ()
>>                         u="%${ZSH_VERSION+%}"
>>                 fi
>>
>> -               if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
>> +               if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
>>                    [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
>>                         h="?"
>>                 fi
Previous: Elijah NewrenNext: Christoph Anton Mitterer
Message 5 of 9 in “git-sh-prompt: bash: GIT_PS1_COMPRESSSPARSESTATE: unbound variable”
  1. Christoph Anton MittererMay 13, 2021
  2. Junio C HamanoMay 13, 2021
  3. Junio C HamanoMay 13, 2021
  4. Elijah NewrenMay 13, 2021
  5. Junio C HamanoMay 13, 2021
  6. Christoph Anton MittererMay 19, 2021
  7. Junio C HamanoMay 19, 2021
  8. Elijah NewrenMay 20, 2021
  9. Christoph Anton MittererMay 13, 2021

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.