Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#29141 - [git] Put Git's bash-completion script back into /etc/bash_completion.d

Attached to Project: Arch Linux
Opened by Kerrick Staley (KerrickStaley) - Wednesday, 28 March 2012, 04:42 GMT
Last edited by Dan McGee (toofishes) - Tuesday, 03 April 2012, 19:35 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Dan McGee (toofishes)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 4
Private No


Git's script for bash_completion not only defines completions but also defines some functions such as __git_ps1.

The git- PKGBUILD has this line:
install -m644 ./contrib/completion/git-completion.bash "$pkgdir"/etc/bash_completion.d/git
The git- PKGBUILD has this line:
install -m644 ./contrib/completion/git-completion.bash "$pkgdir"/usr/share/bash-completion/completions/git

Installing in the original location causes the script to run whenever bash starts. Now, it only runs when you try to autocomplete a git command, and so the __git_ps1 function isn't available when you first open the shell.

Related forum topic:
This task depends upon

Closed by  Dan McGee (toofishes)
Tuesday, 03 April 2012, 19:35 GMT
Reason for closing:  Fixed
Additional comments about closing:, awaiting changes upstream for a split file
Comment by Dan McGee (toofishes) - Wednesday, 28 March 2012, 14:40 GMT
Yes, this has to do with bash-completion now loading completion files on the fly rather than all at once.

It would be great if you could see what upstream git has to think about this, or how they plan on solving it. It seems like the bash-completion file will no longer be able to pull double-duty.
Comment by Ted Pavlic (tpavlic) - Thursday, 29 March 2012, 03:31 GMT
Personally, I get around this problem by creating a symlink from /etc/bash_completion.d/git to the new location.

__git_ps1 is a long standing feature of the bash_completion in git source's contrib (I know, because I've contributed to it). It's not going away.

Either the git package needs to put git back in /etc/bash_completion.d, or a second bash-completion-static should be put there with __git_ps1. Otherwise, a lot of PS1 prompts will be broken.

Someone could try to convince gitster et al. to create a bash-completion-static that contains __git_ps1, but my guess is that there will be resistance to this approach unless it becomes common to split completion scripts into a dynamic and static part.
Comment by Dave Reisner (falconindy) - Thursday, 29 March 2012, 03:35 GMT
git completions are shipped with the git package, not the bash-completion package...
Comment by Alexandre Isoard (surfmaths) - Thursday, 29 March 2012, 18:50 GMT
The symlink solution works well and is "almost" clean (for temporary fix).

$ ln -s /usr/share/bash-completion/completions/git /etc/bash_completion.d/git

And the analysis is exact. (checked with echo statements)