small tip regarding git branch bash prompt in F18/Rawhide
Adam Williamson
awilliam at redhat.com
Tue Aug 28 01:03:27 UTC 2012
On 2012-08-25 16:31, Garrett Holmstrom wrote:
> On 2012-08-25 10:09, Todd Zullinger wrote:
>> Enrico Scholz wrote:
>>> Todd Zullinger <tmz at pobox.com> writes:
>>>> Doing this would break current users that have already configured
>>>> their system to use __git_ps1().
>>>
>>> What are "current users"? Those who installed your just released
>>> rawhide changes?
>>
>> No, it breaks anyone that's currently using __git_ps1(), as the
>> function
>> was previously defined in /etc/bash_completion.d/git. Newer
>> releases of
>> bash-completion are moving to on-demand loading, hence upstream git
>> has
>> split out the __git_ps1() function and a few other support
>> functions.
>> Not having this available for current users means anyone with
>> __git_ps1() in their prompt will get an ugly error every time they
>> hit
>> return, e.g.:
>>
>> bash: __git_ps1: command not found
>>
>> That's far more annoying to far more people than having this
>> function in
>> the environment, in my opinion.
>>
>> I don't see the compelling reason to jump through hoops or expect
>> users
>> to make more changes than needed to enable git info in their
>> prompts.
>> Without some justification of harm, I'm not inclined to change this.
>> What's the reason to strongly oppose this being in /etc/profile.d?
>
> It's the fact that you're now adding functions to *every* shell,
> whereas before it was just bash, and then only for people who opted
> into completion. Since git-prompt.sh makes no attempt to whitelist
> (or even blacklist) shells for compatibility its code will
> unconditionally attempt to run, whether doing so will result in
> errors
> or not.
>
> Since you're looking to maintain compatibility with bash users who
> rely on that function, is there another, bash-specific location where
> that file could go? Or might it make more sense to add a simple
> whitelist or some other check to the top of the file instead?
FWIW, I don't see any problem with requiring people to update their
.bash_profile between F17 and F18 to keep this trick working. The only
thing I considered a 'bug' when posting my initial mail was that the
script lives in a directory whose name is very mutable, so people would
have to keep changing it a lot.
I don't think we need to bend over backwards to make it work for people
upgrading from f17 without them having to make any manual change, and I
don't think it's worth polluting the environment of every user with git
installed just for that result. I think it's fine just to put the script
somewhere where its location will remain permanent, and tell people to
update their .bash_profile to source that.
I think we should ignore the issue of bash-completion entirely. One of
the points of this upstream change is that the use of __git_ps1 had
nothing to do, really, with bash-completion in the first place: you can
use __git_ps1 without using bash-completion and you can use git
bash-completion without using __git_ps1.
--
Adam Williamson
Fedora QA Community Monkey
IRC: adamw | Twitter: AdamW_Fedora | identi.ca: adamwfedora
http://www.happyassassin.net
More information about the devel
mailing list