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

Re: [PATCH v4] git-prompt.sh: Option to hide prompt for ignored pwd

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2015, 23:31 UTC
Message-ID
<xmqqwq4zmqpt.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1420441418-12511-1-git-send-email-rhansen@bbn.com>
Richard Hansen <rhansen@bbn.com> writes:
Show 12 quoted lines
> This is the patch from:
>
>   http://article.gmane.org/gmane.comp.version-control.git/258313
>
> modified to include the changes I suggested in:
>
>   http://article.gmane.org/gmane.comp.version-control.git/258355
>
> I never heard back regarding my suggested changes.  The feature was so
> close to ready and I thought it would be a shame for the feature to
> silently die, so I'm submitting a re-roll with my suggested changes on
> behalf of the original author.
> +# If you would like __git_ps1 to do nothing in the case when the current
> +# directory is set up to be ignored by git, then set
> +# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
> +# repository level by setting bash.hideIfPwdIgnored to "false".

Perhaps nobody had much interest in the original or the update. Occassionally resending with improvements like this is a good way to show it to more people who may have missed it the last time to solicit comments and supports.

I am personally not very interested, as you and the original made it sound as if this is primarily for those who keep track of $HOME/.dot files in $HOME/.git, which is one of the ways I would never use Git.

But I do not have to be the target of each and every new feature ;-).
Show 8 quoted lines
>  # check whether printf supports -v
>  __git_printf_supports_v=
> @@ -369,6 +374,17 @@ __git_ps1 ()
>  	local inside_gitdir="${repo_info##*$'\n'}"
>  	local g="${repo_info%$'\n'*}"
>  
> +	if [ "true" = "$inside_worktree" ] &&
> +	   [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED}" ] &&

Many existing checks on variables are written this way with the "subsitutute with default value" syntax

        if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&

to make sure that people with non-standard settings to report references to unset variables as errors will not have to suffer. Don't you need to do something similar here?

Show 7 quoted lines
> +	   [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
> +	   git check-ignore -q .
> +	then
> +		if [ $pcmode = yes ]; then
> +			PS1="$ps1pc_start$ps1pc_end"
> +		fi
> +		return

There are already two places where "under pcmode, we need to set PS1 to this empty thing" is known, and this patch adds yet another. Would it be sensible to refactor that into a helper function, or open coding them this way is necessary for performance or some other reasons?

Show 15 quoted lines
> +	fi
> +
>  	local r=""
>  	local b=""
>  	local step=""
> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> index 9150984..37953c8 100755
> --- a/t/t9903-bash-prompt.sh
> +++ b/t/t9903-bash-prompt.sh
> @@ -35,6 +35,8 @@ test_expect_success 'setup for prompt tests' '
>  	git commit -m "another b2" file &&
>  	echo 000 >file &&
>  	git commit -m "yet another b2" file &&
> +	mkdir ignored_dir &&
> +	echo "ignored_dir/" >> .gitignore &&
Drop the SP after (but not before) redirection operator >>.
Previous: Richard HansenNext: Richard Hansen
Message 14 of 18 in “git-prompt.sh: Omit prompt for ignored directories”
  1. git-prompt.sh: Omit prompt for ignored directoriesJess Austin, Oct 8, 2014
  2. Richard HansenOct 8, 2014
  3. Fwd: [PATCH] git-prompt.sh: Omit prompt for ignored directoriesJess Austin, Oct 8, 2014
  4. Richard HansenOct 9, 2014
  5. Jess AustinOct 9, 2014
  6. Richard HansenOct 9, 2014
  7. git-prompt.sh: Hide prompt for ignored pwdJess Austin, Oct 14, 2014
  8. Johannes SixtOct 14, 2014
  9. Richard HansenOct 14, 2014
  10. Richard HansenOct 14, 2014
  11. git-prompt.sh: Option to hide prompt for ignored pwdJess Austin, Oct 15, 2014
  12. Richard HansenOct 15, 2014
  13. git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 5, 2015
  14. Junio C HamanoJan 6, 2015
  15. 0/2 git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 7, 2015
  16. 1/2 git-prompt.sh: if pc mode, immediately set PS1 to a plain promptRichard Hansen, Jan 7, 2015
  17. SZEDER GáborJan 14, 2015
  18. 2/2 git-prompt.sh: Option to hide prompt for ignored pwdRichard Hansen, Jan 7, 2015

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.