git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Hansen <rhansen@bbn.com>
To: gitster@pobox.com
Cc: j6t@kdbg.org, jess.austin@gmail.com, git@vger.kernel.org
Subject: [PATCH v5 0/2] git-prompt.sh: Option to hide prompt for ignored pwd
Date: Tue,  6 Jan 2015 20:22:25 -0500	[thread overview]
Message-ID: <1420593747-24110-1-git-send-email-rhansen@bbn.com> (raw)
In-Reply-To: <xmqqwq4zmqpt.fsf@gitster.dls.corp.google.com>

On 2015-01-06T15:31-08:00, Junio C Hamano wrote:
>> 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.

I do keep my dotfiles in a Git repository (~/.git exists), yet I
wouldn't use this feature either.  (I just use refs/heads/dotfiles as
HEAD so that my prompt is unique when I'm not in some project working
directory.)

However, it doesn't seem like a very invasive change to me, and at
least one person wants this feature (evidenced by Jess Austin going to
the trouble of submitting a patch), so I thought I'd help it along.

If someone has a reasonable objection to this feature, or even if
there's not enough positive interest, I wouldn't be too sad to see it
not get adopted.

>> +	   [ -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?

Yes; fixed.

>> +	   [ "$(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?

I thought about factoring it out, but didn't because defining a
function with just three lines seemed awkward.  But I thought of a
better way to eliminate the duplicate code without defining a helper
function; see the new prequel patch.

>> +	echo "ignored_dir/" >> .gitignore &&
> 
> Drop the SP after (but not before) redirection operator >>.

Done.

Thanks for the review,
Richard


Jess Austin (1):
  git-prompt.sh: Option to hide prompt for ignored pwd

Richard Hansen (1):
  git-prompt.sh: if pc mode, immediately set PS1 to a plain prompt

 contrib/completion/git-prompt.sh |  24 ++++++---
 t/t9903-bash-prompt.sh           | 106 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+), 7 deletions(-)

-- 
2.2.1

  reply	other threads:[~2015-01-07  1:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 19:04 [PATCH] git-prompt.sh: Omit prompt for ignored directories Jess Austin
2014-10-08 21:12 ` Richard Hansen
     [not found]   ` <CANp8Xb8ETG-ZFCqrOk=f-RbxtRxehBmAR1O5ozLH80zimWq_Gw@mail.gmail.com>
2014-10-08 21:37     ` Fwd: " Jess Austin
2014-10-09  5:37       ` Richard Hansen
2014-10-09 10:27         ` Jess Austin
2014-10-09 22:09           ` Richard Hansen
2014-10-14  2:32             ` [PATCH] git-prompt.sh: Hide prompt for ignored pwd Jess Austin
2014-10-14 18:47               ` Johannes Sixt
2014-10-14 19:08                 ` Richard Hansen
2014-10-15  4:06                 ` [PATCH] git-prompt.sh: Option to hide " Jess Austin
2014-10-15 20:28                   ` Richard Hansen
2015-01-05  7:03                     ` [PATCH v4] " Richard Hansen
2015-01-06 23:31                       ` Junio C Hamano
2015-01-07  1:22                         ` Richard Hansen [this message]
2015-01-07  1:22                           ` [PATCH v5 1/2] git-prompt.sh: if pc mode, immediately set PS1 to a plain prompt Richard Hansen
2015-01-14 11:45                             ` [PATCH v5 1/2] git-prompt.sh: if pc mode, immediately set PS1 SZEDER Gábor
2015-01-07  1:22                           ` [PATCH v5 2/2] git-prompt.sh: Option to hide prompt for ignored pwd Richard Hansen
2014-10-14 19:21               ` [PATCH] git-prompt.sh: Hide " Richard Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420593747-24110-1-git-send-email-rhansen@bbn.com \
    --to=rhansen@bbn.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jess.austin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).