Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#37117 closed defect (invalid)

git-core 1.8.0 bash completions missing git-prompt.sh code

Reported by: jeff@… Owned by: ci42
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc:
Port: git-core

Description (last modified by ryandesign (Ryan Carsten Schmidt))

__git_ps1 is no longer a defined function in the bash completions, breaking some code I use to put the branch name in my prompt. It seems that this function is in git-prompt.sh which is a second file from Shawn O. Pearce's bash completion code that the +bash_completion variant does not include.

Change History (6)

comment:1 Changed 12 years ago by jeff@…

comment:2 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Owner: changed from macports-tickets@… to ciserlohn@…
Port: git-core added

comment:3 Changed 12 years ago by ci42

Resolution: invalid
Status: newclosed

The git-core port always installs git-prompt.sh. It located in ${prefix}/share/git-core/ (use 'port contents git-core' to find it on your system).

You will have to add something like this to your ~/.bashrc or ~/.profile to use it:

if [ -f /opt/local/share/git-core/git-prompt.sh ]; then
      . /opt/local/share/git-core/git-prompt.sh
fi

comment:4 Changed 12 years ago by jeff@…

Resolution: invalid
Status: closedreopened

But the proper place is for it to be added to the /opt/local/etc/bash_completion.d directory so that

if [ -f /opt/local/etc/bash_completion ]; then

. /opt/local/etc/bash_completion

fi

works as expected and has previously. Reopening.

comment:5 in reply to:  4 Changed 12 years ago by ci42

Resolution: invalid
Status: reopenedclosed

Replying to jeff@…:

But the proper place is for it to be added to the /opt/local/etc/bash_completion.d directory so that

It's not the proper place (by the way /opt/local/etc/bash_completion.d is legacy, the new diretory is /opt/local/share/bash-completion/completions/).

The git_prompt.sh has been split out because (see https://github.com/git/git/commit/af31a456b4cd38f2630ed8e556e23954f806a3cc):

  • bash_completion can load completions dynamically, which means that the git_ps1() function is not available when the shell is created
  • some users are only interested in the __git_ps1() function but not the completions (e.g. zsh users), others are only interested in the completions not the __git_ps1() function (e.g. users who have tweaked their prompt in other ways)

Therefor is better to have both scripts in separate places where they can be individually sourced.

comment:6 Changed 12 years ago by jeff@…

And how do I do completion of my aliases? I have "gch" as git checkout and code that previously worked to make gch have bash completion just like git checkout. But now, I get "completion: function `_git_checkout' not found" when I hit tab.

Note: See TracTickets for help on using tickets.