Bug 878428

Summary: __git_ps1 not found
Product: [Fedora] Fedora Reporter: Amit Shah <amit.shah>
Component: gitAssignee: Chris Wright <chrisw>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: amit.shah, atkac, bkearney, chrisw, mailings, pbrobinson, radford, thozza, tmz
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-20 14:50:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Amit Shah 2012-11-20 12:13:18 UTC
Description of problem:

As referenced in

https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090759.html

the git-prompt.sh file isn't included in /etc/profile.d, causing the shell to complain of missing __git_ps1, (which makes yum go looking for matching packages, which means it's very slow to run any command).

I upgraded from F16 to F17 (via preupgrade) to F18 (via yum), in case that matters/helps.

git-1.8.0-1.fc18.x86_64

Comment 1 Adam Tkac 2012-11-20 14:50:01 UTC
Thanks for report. However this was intentional change. Please check bug #854061 for more details.

To fix this you must add something like

. /usr/share/git-core/contrib/completion/git-prompt.sh

to your bashrc or to your profile.

Comment 2 Ferry Huberts 2012-11-20 14:53:25 UTC
-1

Many (most!) git users have this setup by default.
This breaks all of those.

It has worked since forever, so I consider this a regression.

Comment 3 Adam Tkac 2012-11-21 09:20:31 UTC
(In reply to comment #2)
> -1
> 
> Many (most!) git users have this setup by default.
> This breaks all of those.
> 
> It has worked since forever, so I consider this a regression.

Idea of moving __git_ps1() to separate script didn't come from Fedora git maintainers. Check this upstream commit:

http://repo.or.cz/w/git.git/commit/af31a456b4cd38f2630ed8e556e23954f806a3cc

And we cannot put __git_ps1() into profile.d because it can cause issues with other non-bash shells (as written in original description of bug #854061).

Although I agree this is a regression from user point of view, we have no idea how to fix it. Please use solution written in comment #1

Comment 4 Tomáš Hozza 2013-01-26 10:55:33 UTC
(In reply to comment #1)
> To fix this you must add something like
> 
> . /usr/share/git-core/contrib/completion/git-prompt.sh
> 
> to your bashrc or to your profile.

Thanks for the fix Adam!

Comment 5 Jim Radford 2013-02-06 05:32:38 UTC
I too ran into this and consider it a regression.  I'm loathe to add another distro specific path to my startup scripts.

Given that the reason indicated above that has not been fixed is compatibility with "other" shells, the semantics of /etc/bash_completion.d and /usr/share/bash-completion/completions (the former is for backwards compatibility and always loaded, the later is the new place from which completions are demand loaded) and the upstream developers motivation

  http://thread.gmane.org/gmane.comp.version-control.git/194188

in separating git-prompt.sh out to allow for both demand loading of the git completions and *more* compatiblity with other shells like zsh, I propose putting the main git completion file in

  /usr/share/bash-completion/completions/git

and the git-prompt.sh into

  /etc/bash_completion.d/git-prompt.sh

This way git-prompt.sh gets run all the time, but only in bash and only for interactive shells, and the main git completions (the larger of the two) get loaded on demand (this really should be the case regardless of the decision on this bug) as intended?

Comment 6 Todd Zullinger 2013-02-06 19:48:51 UTC
See #854061.  This is a no-win position.  If we always source git-prompt, someone considers it a bug that we're "polluting" the environment.  If we don't, it's a bug that it must be sourced manually.

If/when upstream and/or other distros all agree on some common location for git-prompt.sh, we will move it there and likely add a symlink from the current location.

# With git-1.8, the completion and prompt bits were split.  The allows lazy
# autoloading of the completion commands.  But it means we have to source a
# different file to get __git_ps1().
git_prompt=/usr/share/git-core/contrib/completion/git-prompt.sh
if ! type __git_ps1 &>/dev/null && [[ -f $git_prompt ]]; then
    source $git_prompt
fi
unset git_prompt