{"thread":{"id":"30089","subject":"bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","startedAt":"2012-03-28T20:27:20Z","lastAt":"2012-04-07T13:47:49Z","messageCount":8,"participants":["Kerrick Staley","Junio C Hamano","Jonathan Nieder","Jeff King","Felipe Contreras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"187995","messageId":"CANaWP3wu3260uFNzCLJ=YSG1BWFr=ge_6CmMGrG6zLThvFnjcQ@mail.gmail.com","threadId":"30089","inReplyTo":null,"subject":"bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Kerrick Staley","fromEmail":"mail@kerrickstaley.com","sentAt":"2012-03-28T20:27:20Z","receivedAt":"2012-03-28T20:27:20Z","isPatch":false,"sender":{"key":"mail@kerrickstaley.com","avatar":null},"body":"The __git_ps1 function is defined in same script that defines Git's\ntab completions (contrib/completion/git-completion.bash). Since\nbash-completion loads completions on-the-fly in newer versions, the\n__git_ps1 function isn't immediately available in a new shell. How\nshould this be handled? Should users just source git-completion.bash\nbefore they redefine $PS1?\n\n-Kerrick Staley\n"},{"id":"188017","messageId":"7v1uoctlp2.fsf@alter.siamese.dyndns.org","threadId":"30089","inReplyTo":"CANaWP3wu3260uFNzCLJ=YSG1BWFr=ge_6CmMGrG6zLThvFnjcQ@mail.gmail.com","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-28T22:17:13Z","receivedAt":"2012-03-28T22:17:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kerrick Staley <mail@kerrickstaley.com> writes:\n\n> The __git_ps1 function is defined in same script that defines Git's\n> tab completions (contrib/completion/git-completion.bash). Since\n> bash-completion loads completions on-the-fly in newer versions, the\n> __git_ps1 function isn't immediately available in a new shell. How\n> should this be handled? Should users just source git-completion.bash\n> before they redefine $PS1?\n\nSorry, I don't quite get it.  \"newer verions\" of what?\n\nTo me, completion scripts have always been to be dot-sourced early, making\nsure inclusion happen before PS1 is used.  Did we change anything recently\nto break it????\n"},{"id":"188024","messageId":"20120328230642.GA16925@burratino","threadId":"30089","inReplyTo":"CANaWP3wu3260uFNzCLJ=YSG1BWFr=ge_6CmMGrG6zLThvFnjcQ@mail.gmail.com","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-03-28T23:06:42Z","receivedAt":"2012-03-28T23:06:42Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Kerrick Staley wrote:\n\n>                                                           Since\n> bash-completion loads completions on-the-fly in newer versions, the\n> __git_ps1 function isn't immediately available in a new shell. How\n> should this be handled? Should users just source git-completion.bash\n> before they redefine $PS1?\n\nYes, I think so.  Do the release notes for version 2.0 of the\n/etc/bash_completion wrapper script mention this change?\n\nThanks,\nJonathan\n"},{"id":"188027","messageId":"CANaWP3w9KDu57aHquRRYt8td_haSWTBKs7zUHy-xu0B61gmr9A@mail.gmail.com","threadId":"30089","inReplyTo":"20120328230642.GA16925@burratino","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Kerrick Staley","fromEmail":"mail@kerrickstaley.com","sentAt":"2012-03-29T00:00:35Z","receivedAt":"2012-03-29T00:00:35Z","isPatch":false,"sender":{"key":"mail@kerrickstaley.com","avatar":null},"body":"On Wed, Mar 28, 2012 at 5:17 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Sorry, I don't quite get it.  \"newer verions\" of what?\n>\n> To me, completion scripts have always been to be dot-sourced early, making\n> sure inclusion happen before PS1 is used.  Did we change anything recently\n> to break it????\n\nbash-completion 1.99 (still a \"beta\", but Arch Linux now ships it)\nwill automatically source the git-completion.bash script when you type\ngit <tab>. The script is no longer sourced when you first open a\nshell.\n\nThere are two main ways to fix this:\n1) define __git_ps1 (and friends) in a different script, which will\nget installed in /etc/profile.d (this is the \"proper way\")\n2) require that git-completion.bash always be loaded in the beginning\ninstead of on-the-fly (which is how it works now now)\n\nI can submit a patch implementing option (1) if needed.\n\nThis is a very minor issue, but some recommendation from upstream\nwould be nice so that distros know how to handle this.\n\nOn Wed, Mar 28, 2012 at 6:06 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Yes, I think so.  Do the release notes for version 2.0 of the\n> /etc/bash_completion wrapper script mention this change?\n\nI'm not sure, but the feature is definitely there. The branch\nimplementing this feature has been merged into the project's master\n(see http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=commit;h=b377dc5de84913b69efa325590e9d0bb97d02128).\n\n-Kerrick\n"},{"id":"188035","messageId":"20120329054942.GB27604@sigill.intra.peff.net","threadId":"30089","inReplyTo":"CANaWP3w9KDu57aHquRRYt8td_haSWTBKs7zUHy-xu0B61gmr9A@mail.gmail.com","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-29T05:49:43Z","receivedAt":"2012-03-29T05:49:43Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 28, 2012 at 07:00:35PM -0500, Kerrick Staley wrote:\n\n> bash-completion 1.99 (still a \"beta\", but Arch Linux now ships it)\n> will automatically source the git-completion.bash script when you type\n> git <tab>. The script is no longer sourced when you first open a\n> shell.\n> \n> There are two main ways to fix this:\n> 1) define __git_ps1 (and friends) in a different script, which will\n> get installed in /etc/profile.d (this is the \"proper way\")\n> 2) require that git-completion.bash always be loaded in the beginning\n> instead of on-the-fly (which is how it works now now)\n\nI would much rather see (1). There is a very good reason for\nbash-completion doing dynamic loading, which is that loading all of the\ncompletions made shell startup horribly slow. We should do our part to\nhelp keep startup fast by splitting the dynamically-loadable bits from\nthe must-be-loaded-at-start bits.\n\n-Peff\n"},{"id":"188036","messageId":"20120329055702.GC27604@sigill.intra.peff.net","threadId":"30089","inReplyTo":"7v1uoctlp2.fsf@alter.siamese.dyndns.org","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-29T05:57:02Z","receivedAt":"2012-03-29T05:57:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 28, 2012 at 03:17:13PM -0700, Junio C Hamano wrote:\n\n> Kerrick Staley <mail@kerrickstaley.com> writes:\n> \n> > The __git_ps1 function is defined in same script that defines Git's\n> > tab completions (contrib/completion/git-completion.bash). Since\n> > bash-completion loads completions on-the-fly in newer versions, the\n> > __git_ps1 function isn't immediately available in a new shell. How\n> > should this be handled? Should users just source git-completion.bash\n> > before they redefine $PS1?\n> \n> Sorry, I don't quite get it.  \"newer verions\" of what?\n> \n> To me, completion scripts have always been to be dot-sourced early, making\n> sure inclusion happen before PS1 is used.  Did we change anything recently\n> to break it????\n\nNo, it is not us. The bash-completion project used to look in something\nlike /etc/bash_completions.d and load everything at shell startup.\nPackagers could then drop our git-completion file there, and everything\njust worked.\n\nBut it made starting the shell very slow, as you loaded completions for\ncommands that you were unlikely to ever run. Newer versions of\nbash-completions load as little as possible on startup. When you first\ntry to tab-complete \"git <tab>\", _then_ it looks for a \"git\" file and\nloads it on the fly.\n\nSo people who put \". /path/to/git-completion.bash\" have nothing to worry\nabout. Everything will work as normal. People who depend on dropping\nthe file somewhere that bash-completion can find it (or who use a\npackage which does so) will find that they do not have __git_ps1 at\nshell startup with newer versions of bash-completion. Those people will\nneed to start sourcing the file themselves (or possibly bash-completion\ncould do it, but it really feels like it is not their responsibility, as\nthe prompt functions have nothing to do with completion).\n\nWe can help them out by breaking the file apart into \"must be loaded at\nstartup\" and \"can be loaded dynamically\" bits, so they don't end up\nloading more than they need to.\n\n-Peff\n"},{"id":"188731","messageId":"CAMP44s0rYpVhPpaf=C_aPoLUxy=EsiSxYNf04+B0_-MxzCftFw@mail.gmail.com","threadId":"30089","inReplyTo":"CANaWP3w9KDu57aHquRRYt8td_haSWTBKs7zUHy-xu0B61gmr9A@mail.gmail.com","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-07T13:01:55Z","receivedAt":"2012-04-07T13:01:55Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Mar 29, 2012 at 3:00 AM, Kerrick Staley <mail@kerrickstaley.com> wrote:\n> 1) define __git_ps1 (and friends) in a different script, which will\n> get installed in /etc/profile.d (this is the \"proper way\")\n\nI prefer this because it's useful for zsh as well; not everybody uses\nthe bash completion in zsh. I believe somebody already proposed this\nbecause of this reason. FWIW I named the script git-prompt.sh on my\nside.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"188733","messageId":"20120407134749.GA2377@burratino","threadId":"30089","inReplyTo":"CAMP44s0rYpVhPpaf=C_aPoLUxy=EsiSxYNf04+B0_-MxzCftFw@mail.gmail.com","subject":"Re: bash-completion now loads completions dynamically, so __git_ps1 is not defined when you open a shell","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-07T13:47:49Z","receivedAt":"2012-04-07T13:47:49Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n> On Thu, Mar 29, 2012 at 3:00 AM, Kerrick Staley <mail@kerrickstaley.com> wrote:\n\n>> 1) define __git_ps1 (and friends) in a different script, which will\n>> get installed in /etc/profile.d (this is the \"proper way\")\n>\n> I prefer this because it's useful for zsh as well\n\nSounds good to me.  In fact, I imagine you'll find no one it does not\nsound good to.  Please feel free to make it so.\n"}]}