{"thread":{"id":"51243","subject":"[PATCH 0/1] Improve instructions around how to set git-prompt preference variables.","startedAt":"2019-06-05T15:06:09Z","lastAt":"2019-06-05T19:26:51Z","messageCount":4,"participants":["Edward D'Souza via GitGitGadget","SZEDER Gábor","Edward D'Souza"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"376713","messageId":"pull.255.git.gitgitgadget@gmail.com","threadId":"51243","inReplyTo":null,"subject":"[PATCH 0/1] Improve instructions around how to set git-prompt preference variables.","fromName":"Edward D'Souza via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-05T15:06:06Z","receivedAt":"2019-06-05T15:06:09Z","isPatch":true,"sender":{"key":"edsouza@gmail.com","avatar":"https://gravatar.com/avatar/74a8cbf91f485a8b3abc3b14fe558f2d7400d0fd55b2d308ba41668c062f3540?d=mp&s=160"},"body":"When I first tried to use the git-prompt.sh script, I followed the\ninstructions at the top of the file and everything worked, except for the\n\"GIT_PS1_SHOWDIRTYSTATE\" preference. Even though I had it set to true, I\nwasn't seeing the \"()\" and \"(+)\" in my shell prompt. After a few hours of\npoking around, I finally discovered what I had done wrong: I was setting the\nvariable *after the \"source ~/.git-prompt.sh\" line, and it has to be set \nbefore.\n\nI moved the lines around my .bashrc script and got everything working, but I\nthought the instructions could be a bit more explicit about how to set these\npreference variables, especially because this is a silent failure situation;\nthe preference doesn't work if you get the order wrong and there are no\nwarnings or errors to guide you.\n\nThis patch started as a PR on the official Github project two years ago (\nhttps://github.com/git/git/pull/425), back when I didn't know the official\nprocess for submitting patches. Luckily, a kind user (@dscho) saw it and\npointed me in the right direction to get it submitted.\n\nThis will be my first time submitting a patch, so hopefully I've figured out\nthe process.\n\nEdward D'Souza (1):\n  git-prompt.sh: update shell variable instructions.\n\n contrib/completion/git-prompt.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\n\nbase-commit: cb5918aa0d50f50e83787f65c2ddc3dcb10159fe\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-255%2Fghedsouza%2Fpatch-1-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-255/ghedsouza/patch-1-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/255\n-- \ngitgitgadget\n"},{"id":"376714","messageId":"0074d3da7ad402043d58ebb107435ce955a347f5.1559747165.git.gitgitgadget@gmail.com","threadId":"51243","inReplyTo":"pull.255.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git-prompt.sh: update shell variable instructions.","fromName":"Edward D'Souza via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-06-05T15:06:07Z","receivedAt":"2019-06-05T15:06:11Z","isPatch":true,"sender":{"key":"edsouza@gmail.com","avatar":"https://gravatar.com/avatar/74a8cbf91f485a8b3abc3b14fe558f2d7400d0fd55b2d308ba41668c062f3540?d=mp&s=160"},"body":"From: Edward D'Souza <edsouza@gmail.com>\n\nClarify the need to set variables like GIT_PS1_SHOWDIRTYSTATE before\n\"source ~/.git-prompt.sh\" is executed in your shell init process.\n\nIf you set these preferences too late i.e. after .git-prompt.sh executes,\nthey will silently fail to take effect.\n\nSigned-off-by: Edward D'Souza <edsouza@gmail.com>\n---\n contrib/completion/git-prompt.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex c6cbef38c2..ab5bcc0fec 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -35,6 +35,11 @@\n #\n # The prompt status always includes the current branch name.\n #\n+# The prompt can be customized by setting various shell variables\n+# (GIT_PS1_SHOWDIRTYSTATE, GIT_PS1_SHOWSTASHSTATE, etc.), which are described\n+# below. Make sure that these variables get set *before* the\n+# \"source ~/.git-prompt.sh\" line from step 2 (above) runs.\n+#\n # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,\n # unstaged (*) and staged (+) changes will be shown next to the branch\n # name.  You can configure this per-repository with the\n-- \ngitgitgadget\n"},{"id":"376717","messageId":"20190605160656.GU951@szeder.dev","threadId":"51243","inReplyTo":"0074d3da7ad402043d58ebb107435ce955a347f5.1559747165.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git-prompt.sh: update shell variable instructions.","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-06-05T16:06:56Z","receivedAt":"2019-06-05T16:07:02Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Wed, Jun 05, 2019 at 08:06:07AM -0700, Edward D'Souza via GitGitGadget wrote:\n> From: Edward D'Souza <edsouza@gmail.com>\n> \n> Clarify the need to set variables like GIT_PS1_SHOWDIRTYSTATE before\n> \"source ~/.git-prompt.sh\" is executed in your shell init process.\n> \n> If you set these preferences too late i.e. after .git-prompt.sh executes,\n> they will silently fail to take effect.\n\nI can't reproduce this.  It doesn't matter when these variables are\nset, because __git_ps1() checks them each time it is invoked, it\nalways has.\n\n  $ echo $GIT_PS1_SHOWSTASHSTATE $GIT_PS1_SHOWDIRTYSTATE $GIT_PS1_SHOWUNTRACKEDFILES\n  \n  /tmp/repo$ git init\n  Initialized empty Git repository in /tmp/repo/.git/\n  /tmp/repo (master)$ echo 1 >file\n  /tmp/repo (master)$ git add file\n  /tmp/repo (master)$ git commit -q -m initial\n  /tmp/repo (master)$ echo 2 >file\n  /tmp/repo (master)$ git stash \n  Saved working directory and index state WIP on master: 5ae0413 initial\n  /tmp/repo (master)$ echo 3 >file\n  /tmp/repo (master)$ git add file\n  /tmp/repo (master)$ echo 4 >file\n  /tmp/repo (master)$ >untracked\n  /tmp/repo (master)$ GIT_PS1_SHOWSTASHSTATE=y\n  /tmp/repo (master $)$ GIT_PS1_SHOWDIRTYSTATE=y\n  /tmp/repo (master *+$)$ GIT_PS1_SHOWUNTRACKEDFILES=y\n  /tmp/repo (master *+$%)$ unset GIT_PS1_SHOWSTASHSTATE GIT_PS1_SHOWDIRTYSTATE GIT_PS1_SHOWUNTRACKEDFILES\n  /tmp/repo (master)$ \n\nNote that some of these status indicators are controlled not only by\nenvironment variables but by corresponding 'bash.<indicator>' config\nvariables as well.  Even if the env var is set to enable the status\nindicator globally, the config setting can still override that to\nallow disabling potentially expensive indicators on a per-repo basis.\nIs it possible that you had e.g. 'bash.showDirtyState = false' in your\nconfig somewhere?\n\nAnyway, even if the issue were real, this patch goes in the wrong\ndirection: instead of requiring a workaround from users, we should\nrather fix the issue.\n\n> Signed-off-by: Edward D'Souza <edsouza@gmail.com>\n> ---\n>  contrib/completion/git-prompt.sh | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> index c6cbef38c2..ab5bcc0fec 100644\n> --- a/contrib/completion/git-prompt.sh\n> +++ b/contrib/completion/git-prompt.sh\n> @@ -35,6 +35,11 @@\n>  #\n>  # The prompt status always includes the current branch name.\n>  #\n> +# The prompt can be customized by setting various shell variables\n> +# (GIT_PS1_SHOWDIRTYSTATE, GIT_PS1_SHOWSTASHSTATE, etc.), which are described\n> +# below. Make sure that these variables get set *before* the\n> +# \"source ~/.git-prompt.sh\" line from step 2 (above) runs.\n> +#\n>  # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,\n>  # unstaged (*) and staged (+) changes will be shown next to the branch\n>  # name.  You can configure this per-repository with the\n> -- \n> gitgitgadget\n\n"},{"id":"376725","messageId":"CAH-P7x5t76wpjj--xvQAsqAMp7WTdsOKvou=13qpMJkuWOBzow@mail.gmail.com","threadId":"51243","inReplyTo":"20190605160656.GU951@szeder.dev","subject":"Re: [PATCH 1/1] git-prompt.sh: update shell variable instructions.","fromName":"Edward D'Souza","fromEmail":"edsouza@gmail.com","sentAt":"2019-06-05T19:26:38Z","receivedAt":"2019-06-05T19:26:51Z","isPatch":true,"sender":{"key":"edsouza@gmail.com","avatar":"https://gravatar.com/avatar/74a8cbf91f485a8b3abc3b14fe558f2d7400d0fd55b2d308ba41668c062f3540?d=mp&s=160"},"body":"Confirming that I can't reproduce this either. Should have done that\nfirst before continuing with a PR from two years ago!\n\nOn Wed, Jun 5, 2019 at 12:07 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:\n>\n> On Wed, Jun 05, 2019 at 08:06:07AM -0700, Edward D'Souza via GitGitGadget wrote:\n> > From: Edward D'Souza <edsouza@gmail.com>\n> >\n> > Clarify the need to set variables like GIT_PS1_SHOWDIRTYSTATE before\n> > \"source ~/.git-prompt.sh\" is executed in your shell init process.\n> >\n> > If you set these preferences too late i.e. after .git-prompt.sh executes,\n> > they will silently fail to take effect.\n>\n> I can't reproduce this.  It doesn't matter when these variables are\n> set, because __git_ps1() checks them each time it is invoked, it\n> always has.\n>\n>   $ echo $GIT_PS1_SHOWSTASHSTATE $GIT_PS1_SHOWDIRTYSTATE $GIT_PS1_SHOWUNTRACKEDFILES\n>\n>   /tmp/repo$ git init\n>   Initialized empty Git repository in /tmp/repo/.git/\n>   /tmp/repo (master)$ echo 1 >file\n>   /tmp/repo (master)$ git add file\n>   /tmp/repo (master)$ git commit -q -m initial\n>   /tmp/repo (master)$ echo 2 >file\n>   /tmp/repo (master)$ git stash\n>   Saved working directory and index state WIP on master: 5ae0413 initial\n>   /tmp/repo (master)$ echo 3 >file\n>   /tmp/repo (master)$ git add file\n>   /tmp/repo (master)$ echo 4 >file\n>   /tmp/repo (master)$ >untracked\n>   /tmp/repo (master)$ GIT_PS1_SHOWSTASHSTATE=y\n>   /tmp/repo (master $)$ GIT_PS1_SHOWDIRTYSTATE=y\n>   /tmp/repo (master *+$)$ GIT_PS1_SHOWUNTRACKEDFILES=y\n>   /tmp/repo (master *+$%)$ unset GIT_PS1_SHOWSTASHSTATE GIT_PS1_SHOWDIRTYSTATE GIT_PS1_SHOWUNTRACKEDFILES\n>   /tmp/repo (master)$\n>\n> Note that some of these status indicators are controlled not only by\n> environment variables but by corresponding 'bash.<indicator>' config\n> variables as well.  Even if the env var is set to enable the status\n> indicator globally, the config setting can still override that to\n> allow disabling potentially expensive indicators on a per-repo basis.\n> Is it possible that you had e.g. 'bash.showDirtyState = false' in your\n> config somewhere?\n>\n> Anyway, even if the issue were real, this patch goes in the wrong\n> direction: instead of requiring a workaround from users, we should\n> rather fix the issue.\n>\n> > Signed-off-by: Edward D'Souza <edsouza@gmail.com>\n> > ---\n> >  contrib/completion/git-prompt.sh | 5 +++++\n> >  1 file changed, 5 insertions(+)\n> >\n> > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> > index c6cbef38c2..ab5bcc0fec 100644\n> > --- a/contrib/completion/git-prompt.sh\n> > +++ b/contrib/completion/git-prompt.sh\n> > @@ -35,6 +35,11 @@\n> >  #\n> >  # The prompt status always includes the current branch name.\n> >  #\n> > +# The prompt can be customized by setting various shell variables\n> > +# (GIT_PS1_SHOWDIRTYSTATE, GIT_PS1_SHOWSTASHSTATE, etc.), which are described\n> > +# below. Make sure that these variables get set *before* the\n> > +# \"source ~/.git-prompt.sh\" line from step 2 (above) runs.\n> > +#\n> >  # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,\n> >  # unstaged (*) and staged (+) changes will be shown next to the branch\n> >  # name.  You can configure this per-repository with the\n> > --\n> > gitgitgadget\n>\n"}]}