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

Re: [PATCH 1/1] git-prompt.sh: update shell variable instructions.

From
Edward D'Souza <edsouza@gmail.com>
Date
Jun 5, 2019, 19:26 UTC
Message-ID
<CAH-P7x5t76wpjj--xvQAsqAMp7WTdsOKvou=13qpMJkuWOBzow@mail.gmail.com>
In-Reply-To
<20190605160656.GU951@szeder.dev>

Confirming that I can't reproduce this either. Should have done that first before continuing with a PR from two years ago!

On Wed, Jun 5, 2019 at 12:07 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
Show 70 quoted lines
>
> On Wed, Jun 05, 2019 at 08:06:07AM -0700, Edward D'Souza via GitGitGadget wrote:
> > From: Edward D'Souza <edsouza@gmail.com>
> >
> > Clarify the need to set variables like GIT_PS1_SHOWDIRTYSTATE before
> > "source ~/.git-prompt.sh" is executed in your shell init process.
> >
> > If you set these preferences too late i.e. after .git-prompt.sh executes,
> > they will silently fail to take effect.
>
> I can't reproduce this.  It doesn't matter when these variables are
> set, because __git_ps1() checks them each time it is invoked, it
> always has.
>
>   $ echo $GIT_PS1_SHOWSTASHSTATE $GIT_PS1_SHOWDIRTYSTATE $GIT_PS1_SHOWUNTRACKEDFILES
>
>   /tmp/repo$ git init
>   Initialized empty Git repository in /tmp/repo/.git/
>   /tmp/repo (master)$ echo 1 >file
>   /tmp/repo (master)$ git add file
>   /tmp/repo (master)$ git commit -q -m initial
>   /tmp/repo (master)$ echo 2 >file
>   /tmp/repo (master)$ git stash
>   Saved working directory and index state WIP on master: 5ae0413 initial
>   /tmp/repo (master)$ echo 3 >file
>   /tmp/repo (master)$ git add file
>   /tmp/repo (master)$ echo 4 >file
>   /tmp/repo (master)$ >untracked
>   /tmp/repo (master)$ GIT_PS1_SHOWSTASHSTATE=y
>   /tmp/repo (master $)$ GIT_PS1_SHOWDIRTYSTATE=y
>   /tmp/repo (master *+$)$ GIT_PS1_SHOWUNTRACKEDFILES=y
>   /tmp/repo (master *+$%)$ unset GIT_PS1_SHOWSTASHSTATE GIT_PS1_SHOWDIRTYSTATE GIT_PS1_SHOWUNTRACKEDFILES
>   /tmp/repo (master)$
>
> Note that some of these status indicators are controlled not only by
> environment variables but by corresponding 'bash.<indicator>' config
> variables as well.  Even if the env var is set to enable the status
> indicator globally, the config setting can still override that to
> allow disabling potentially expensive indicators on a per-repo basis.
> Is it possible that you had e.g. 'bash.showDirtyState = false' in your
> config somewhere?
>
> Anyway, even if the issue were real, this patch goes in the wrong
> direction: instead of requiring a workaround from users, we should
> rather fix the issue.
>
> > Signed-off-by: Edward D'Souza <edsouza@gmail.com>
> > ---
> >  contrib/completion/git-prompt.sh | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> > index c6cbef38c2..ab5bcc0fec 100644
> > --- a/contrib/completion/git-prompt.sh
> > +++ b/contrib/completion/git-prompt.sh
> > @@ -35,6 +35,11 @@
> >  #
> >  # The prompt status always includes the current branch name.
> >  #
> > +# The prompt can be customized by setting various shell variables
> > +# (GIT_PS1_SHOWDIRTYSTATE, GIT_PS1_SHOWSTASHSTATE, etc.), which are described
> > +# below. Make sure that these variables get set *before* the
> > +# "source ~/.git-prompt.sh" line from step 2 (above) runs.
> > +#
> >  # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
> >  # unstaged (*) and staged (+) changes will be shown next to the branch
> >  # name.  You can configure this per-repository with the
> > --
> > gitgitgadget
>
Previous: SZEDER Gábor
Message 4 of 4 in “Improve instructions around how to set git-prompt preference variables.”
  1. 0/1 Improve instructions around how to set git-prompt preference variables.Edward D'Souza via GitGitGadget, Jun 5, 2019
  2. 1/1 git-prompt.sh: update shell variable instructions.Edward D'Souza via GitGitGadget, Jun 5, 2019
  3. SZEDER GáborJun 5, 2019
  4. Edward D'SouzaJun 5, 2019

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.