Re: Where should git-prompt.sh be installed?

2012-10-25 Thread Danny Yates
Would that not give the impression of git sh-prompt being a core command? If 
so, that would be poor, IMHO. 

When I was investigating this last night, I expected to find it (git-prompt.sh) 
in contrib, although that doesn't make an enormous amount of sense. Ideally, 
the full path to wherever it's installed should be mentioned in the bash 
completion file (which is where I went to look when __git_ps1 stopped working), 
but that would mean modifying a file from upstream and I'm not sure if that's 
easy/the done thing.

Danny. 


On 25 Oct 2012, at 01:51, Jonathan Nieder jrnie...@gmail.com wrote:

 Hi,
 
 In olden days the admin would copy contrib/completion/git-completion.sh
 to
 
/etc/bash_completion.d/git
 
 and mortals could source /etc/bash_completion or
 /etc/bash_completion.d/git in their ~/.bashrc (possibly shared among
 multiple machines) so that the bash completion and __git_ps1 helpers
 could work.
 
 With Git 1.7.12 __git_ps1 has been split into a separate file, to help
 users who only want __git_ps1 to avoid the overhead of loading the
 entire completion script (and allow the completion script to be loaded
 by bash-completion magic on the fly!).  Now the sysadmin should copy
 contrib/completion/git-completion.sh to
 
/usr/share/bash-completion/completions/git
 
 and contrib/completion/git-prompt.sh to
 
/usr/share/git-core/contrib/?? (somewhere?)
 
 Mortals source /etc/bash_completion in their ~/.bashrc (possibly
 shared among multiple machines) and expect bash completion to work.
 For __git_ps1, users should source that ?? path.
 
 Questions:
 
 1) what path is appropriate for ?? above?
 2) is this documented anywhere?
 
 Possible answers:
 
 1) Fedora uses /etc/profile.d/git-prompt.sh.  Gentoo uses
/usr/share/bash-completion/git-prompt.  Maybe others use
some other path.
 
 2) The scripts themselves suggest copying to ~/.git-completion.sh
and ~/.git-prompt.sh.
 
 Proposal:
 
  1) /usr/lib/git-core/git-sh-prompt
  2) git-sh-prompt(1)
 
 Sensible?
 
 Thanks,
 Jonathan
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Where should git-prompt.sh be installed?

2012-10-25 Thread Anders Kaseorg

On 10/25/2012 02:02 AM, Danny Yates wrote:

Would that not give the impression of git sh-prompt being a core
command?


No more than git-sh-setup, which already works like that.  Unless 
perhaps by “core” you mean “not contrib”.


(Now that I think of it, I saw a request from an Ubuntu PPA user last 
week to install git-subtree in a more accessible location, and there’s a 
similar request about gitview at https://bugs.launchpad.net/bugs/152212 
.  These are less critical since the Debian package puts them in 
/usr/share/doc/git/contrib.  Is it a good idea to package those 
somewhere like /usr/lib/git-core or /usr/bin, or is that a dangerous 
slippery slope?  I dunno.)


Anders

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Where should git-prompt.sh be installed?

2012-10-25 Thread SZEDER Gábor
On Wed, Oct 24, 2012 at 05:51:06PM -0700, Jonathan Nieder wrote:
 Hi,
 
 In olden days the admin would copy contrib/completion/git-completion.sh
 to
 
 /etc/bash_completion.d/git
 
 and mortals could source /etc/bash_completion or
 /etc/bash_completion.d/git in their ~/.bashrc (possibly shared among
 multiple machines) so that the bash completion and __git_ps1 helpers
 could work.

Ah, the good old days!  I even modified 'make install' to copy the
completion script to /etc/bash_completion.d/.  And I was happy.

 With Git 1.7.12 __git_ps1 has been split into a separate file, to help
 users who only want __git_ps1 to avoid the overhead of loading the
 entire completion script (and allow the completion script to be loaded
 by bash-completion magic on the fly!).  Now the sysadmin should copy
 contrib/completion/git-completion.sh to
 
   /usr/share/bash-completion/completions/git
 
 and contrib/completion/git-prompt.sh to
 
   /usr/share/git-core/contrib/?? (somewhere?)
 
 Mortals source /etc/bash_completion in their ~/.bashrc (possibly
 shared among multiple machines) and expect bash completion to work.
 For __git_ps1, users should source that ?? path.
 
 Questions:
 
  1) what path is appropriate for ?? above?
  2) is this documented anywhere?

Don't know what is appropriate, and it's not documented.  I for one
copy it manually to ~/.git-prompt.sh every once in a while.  And I'm
not all that happy with that.

 Possible answers:
 
  1) Fedora uses /etc/profile.d/git-prompt.sh.  Gentoo uses
 /usr/share/bash-completion/git-prompt.  Maybe others use
 some other path.
 
  2) The scripts themselves suggest copying to ~/.git-completion.sh
 and ~/.git-prompt.sh.
 
 Proposal:
 
   1) /usr/lib/git-core/git-sh-prompt
   2) git-sh-prompt(1)

Not sure about the sh part.  The prompt function is very
Bash-specific, it won't work under a plain POSIX shell.

Do other VCSes have similar prompt scripts?  Where do they install
theirs?


Gábor

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Where should git-prompt.sh be installed?

2012-10-25 Thread Jonathan Nieder
SZEDER Gábor wrote:
 On Wed, Oct 24, 2012 at 05:51:06PM -0700, Jonathan Nieder wrote:

 Proposal:

   1) /usr/lib/git-core/git-sh-prompt
   2) git-sh-prompt(1)

 Not sure about the sh part.  The prompt function is very
 Bash-specific, it won't work under a plain POSIX shell.

That's an interesting point.  Here's my logic:

The prompt function was originally Bash-specific, but over time
it gained support for Zsh as well.  If we're lucky, some day it
might gain support for mksh.

Meanwhile something simple like git-prompt would sound too much
like a normal git command, I fear.

Shell language extensions used:

 * future standard: local variables
 * cosmetic: [[ and (( syntax in place of test and $(
 * cosmetic: for ((n=1; n = n_stop; n++)) instead of a more explicit
   while loop
 * cosmetic: var+=value syntax
 * optimization:  syntax to iterate over lines in a variable
   instead of, for example, sed + eval
 * arrays: svn_remote, svn_upstream --- using plain variables would
   require some escaping.

So nothing fundamental, but since this is only useful in shells like
Bash that support command substitution in $PS1, it seems reasonable
to keep using the extensions until someone wants to use it with a
more limited shell.

In other words, the interface is still this is a scriptlet you might
source in your Bourne-style shell to get a __git_ps1 function to use
in your prompt.  The implementation language just happens not to be
POSIX shell today.

Perhaps it should return early in shells other than bash and zsh to
help people keep their .shrc simple.  What do you think?

 Do other VCSes have similar prompt scripts?  Where do they install
 theirs?

Mercurial has an hg-prompt extension that can be used by running hg
prompt.
http://mercurial.selenic.com/wiki/PromptExtension

I haven't found one for Subversion.

Bazaar has contrib/bash/bzrbashprompt.sh.  It doesn't get installed.

Thanks,
Jonathan
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Where should git-prompt.sh be installed?

2012-10-24 Thread Drew Northup
On Wed, Oct 24, 2012 at 8:51 PM, Jonathan Nieder jrnie...@gmail.com wrote:
 Now the sysadmin should copy
 contrib/completion/git-completion.sh to

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

 and contrib/completion/git-prompt.sh to

 /usr/share/git-core/contrib/?? (somewhere?)

 Mortals source /etc/bash_completion in their ~/.bashrc (possibly
 shared among multiple machines) and expect bash completion to work.
 For __git_ps1, users should source that ?? path.

 Questions:

  1) what path is appropriate for ?? above?
  2) is this documented anywhere?

 Possible answers:

  1) Fedora uses /etc/profile.d/git-prompt.sh.  Gentoo uses
 /usr/share/bash-completion/git-prompt.  Maybe others use
 some other path.

  2) The scripts themselves suggest copying to ~/.git-completion.sh
 and ~/.git-prompt.sh.

 Proposal:

   1) /usr/lib/git-core/git-sh-prompt
   2) git-sh-prompt(1)

 Sensible?

Does the LSB provide any guidance? If not, or if such guidance isn't
helpful, I say that looks reasonable.

What I'd like to know is why we are saying copy when symlinking is
likely to be more easily maintainable? (Less chance to screw up.)

-- 
-Drew Northup
--
As opposed to vegetable or mineral error?
-John Pescatore, SANS NewsBites Vol. 12 Num. 59
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html