threads / patch / 36572

patchcompletion: move out of contrib

Subject: [PATCH] completion: move out of contrib

## tl;dr

6 messages between May 3, 2014 and May 7, 2014. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Felipe Contreras· May 3, 2014, 00:36 UTC · lore

These have been stable and widely used for quite a long time, they even have tests outside of the contrib area, and most distributions ship them, so they can be considered part of the core already.

Let's move them out of contrib and install them by default.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Makefile                                           | 5 ++++-
 {contrib/completion => shared}/git-completion.bash | 0
 {contrib/completion => shared}/git-completion.zsh  | 0
 {contrib/completion => shared}/git-prompt.sh       | 0
 t/t9902-completion.sh                              | 2 +-
 t/t9903-bash-prompt.sh                             | 2 +-
 6 files changed, 6 insertions(+), 3 deletions(-)
 rename {contrib/completion => shared}/git-completion.bash (100%)
 rename {contrib/completion => shared}/git-completion.zsh (100%)
 rename {contrib/completion => shared}/git-prompt.sh (100%)
Show changes to 6 files +6 −3

Makefile, contrib/completion/git-completion.bash, contrib/completion/git-completion.zsh, contrib/completion/git-prompt.sh, t/t9902-completion.sh, t/t9903-bash-prompt.sh

diff --git a/Makefile b/Makefile
index a53f3a8..4a022cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1581,6 +1581,7 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
 prefix_SQ = $(subst ','\'',$(prefix))
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
+sharedir_SQ = $(subst ','\'',$(sharedir))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -2334,7 +2335,6 @@ endif
 mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 
 install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
-
 install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
@@ -2344,6 +2344,9 @@ install: all
 	$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
 	$(INSTALL) -m 644 mergetools/* '$(DESTDIR_SQ)$(mergetools_instdir_SQ)'
+	$(INSTALL) -D -m 644 shared/git-completion.bash '$(DESTDIR_SQ)$(sharedir_SQ)'/bash-completion/completions/git
+	$(INSTALL) -D -m 644 shared/git-prompt.sh '$(DESTDIR_SQ)$(sharedir_SQ)'/git-core/git-prompt.sh
+	$(INSTALL) -D -m 644 shared/git-completion.zsh '$(DESTDIR_SQ)$(sharedir_SQ)'/zsh/site-functions/_git
 ifndef NO_GETTEXT
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
 	(cd po/build/locale && $(TAR) cf - .) | \
diff --git a/contrib/completion/git-completion.bash b/shared/git-completion.bash
similarity index 100%
rename from contrib/completion/git-completion.bash
rename to shared/git-completion.bash
diff --git a/contrib/completion/git-completion.zsh b/shared/git-completion.zsh
similarity index 100%
rename from contrib/completion/git-completion.zsh
rename to shared/git-completion.zsh
diff --git a/contrib/completion/git-prompt.sh b/shared/git-prompt.sh
similarity index 100%
rename from contrib/completion/git-prompt.sh
rename to shared/git-prompt.sh
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 2d4beb5..d8674e4 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -32,7 +32,7 @@ complete ()
 
 GIT_TESTING_COMMAND_COMPLETION='add checkout check-attr filter-branch ls-files'
 
-. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash"
+. "$GIT_BUILD_DIR/shared/git-completion.bash"
 
 # We don't need this function to actually join words or do anything special.
 # Also, it's cleaner to avoid touching bash's internal completion variables.
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 59f875e..272e5b3 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -7,7 +7,7 @@ test_description='test git-specific bash prompt functions'
 
 . ./lib-bash.sh
 
-. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
+. "$GIT_BUILD_DIR/shared/git-prompt.sh"
 
 actual="$TRASH_DIRECTORY/actual"
 c_red='\\[\\e[31m\\]'
-- 
1.9.2+fc1.20.g204a630
Junio C Hamano· May 7, 2014, 00:28 UTC · re: Felipe Contreras · lore

Re: [PATCH] completion: move out of contrib

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 18 quoted lines
> These have been stable and widely used for quite a long time, they even
> have tests outside of the contrib area, and most distributions ship
> them, so they can be considered part of the core already.
>
> Let's move them out of contrib and install them by default.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  Makefile                                           | 5 ++++-
>  {contrib/completion => shared}/git-completion.bash | 0
>  {contrib/completion => shared}/git-completion.zsh  | 0
>  {contrib/completion => shared}/git-prompt.sh       | 0
>  t/t9902-completion.sh                              | 2 +-
>  t/t9903-bash-prompt.sh                             | 2 +-
>  6 files changed, 6 insertions(+), 3 deletions(-)
>  rename {contrib/completion => shared}/git-completion.bash (100%)
>  rename {contrib/completion => shared}/git-completion.zsh (100%)
>  rename {contrib/completion => shared}/git-prompt.sh (100%)
I am not sure whom this change is meant to help.
 - Those who build from source *and* care about having the latest
   completion must already have a way they have been using to
   install them.  They will have to change their procedure to adjust
   for the change of the path, *and* disable the part of "install"
   that installs it to $(sharedir) which is unlikely to match where
   they have been installing completion scripts.
 - Those who package completion for distros already have a way they
   have been using to install them.  They suffer the same as those
   who build from the source.
 - Those who use pre-packaged Git and completion scripts would not
   care.
 - Those who have *not* installed from the source may benefit for
   being able to say "make install" and let it be installed, but
   they have to dot-include /usr/share/git-completion.bash location,
   which is new, not from /etc/bash_completion.d/git as they are
   used to.
A better change might be to give a new Makefile target, perhaps
    $ make install.contrib-completion

without moving the scripts from their current place. That way, nobody gets hurt, and those who are new to Git who want to build and install from the source would not have to invent their own way to install stuff from contrib/ (the same goes for other contrib/ tools such as contrib/workdir/ we may want to add a new target to let you say "make install.contrib-workdir").

I _may_ be persuaded to fold the installation of all possible contrib/ stuff into the regular "make install", but I haven't thought things through.

The patch does two unrelated things:
 - Move things in the source tree.
 - Install the completion by default.

I very much agree that the latter may be a good thing to have in the polished end result. I am not sure if the installation location chosen is sensible. At least, another redirection

    git_completion_dir = $(sharedir)

may be necessary to allow people install these in the location they want.

Felipe Contreras· May 7, 2014, 01:18 UTC · re: Junio C Hamano · lore

Re: [PATCH] completion: move out of contrib

Junio C Hamano wrote:
Show 29 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > These have been stable and widely used for quite a long time, they even
> > have tests outside of the contrib area, and most distributions ship
> > them, so they can be considered part of the core already.
> >
> > Let's move them out of contrib and install them by default.
> >
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> >  Makefile                                           | 5 ++++-
> >  {contrib/completion => shared}/git-completion.bash | 0
> >  {contrib/completion => shared}/git-completion.zsh  | 0
> >  {contrib/completion => shared}/git-prompt.sh       | 0
> >  t/t9902-completion.sh                              | 2 +-
> >  t/t9903-bash-prompt.sh                             | 2 +-
> >  6 files changed, 6 insertions(+), 3 deletions(-)
> >  rename {contrib/completion => shared}/git-completion.bash (100%)
> >  rename {contrib/completion => shared}/git-completion.zsh (100%)
> >  rename {contrib/completion => shared}/git-prompt.sh (100%)
> 
> I am not sure whom this change is meant to help.
> 
>  - Those who build from source *and* care about having the latest
>    completion must already have a way they have been using to
>    install them.  They will have to change their procedure to adjust
>    for the change of the path, *and* disable the part of "install"
>    that installs it to $(sharedir) which is unlikely to match where
>    they have been installing completion scripts.
No.
>  - Those who package completion for distros already have a way they
>    have been using to install them.  They suffer the same as those
>    who build from the source.

Yes, *if* they have been packaging them, they have a way. But what if they haven't been doing so?

And for the ones that have a way, now they need one hack less.
>  - Those who use pre-packaged Git and completion scripts would not
>    care.
No.
Show 5 quoted lines
>  - Those who have *not* installed from the source may benefit for
>    being able to say "make install" and let it be installed, but
>    they have to dot-include /usr/share/git-completion.bash location,
>    which is new, not from /etc/bash_completion.d/git as they are
>    used to.

Wrong. They don't have to dot-include anything, bash-completion does that automagically. If they don't have bash-completion, sure, they'll need to dot-include the new location.

And the location is not /usr/share/git-completion.bash, it's $(sharedir)/bash-completion/completions.

Although after reading bash-completion's README, it should actually be:
 % pkg-config --variable=completionsdir bash-completion
Show 5 quoted lines
> A better change might be to give a new Makefile target, perhaps
> 
>     $ make install.contrib-completion
> 
> without moving the scripts from their current place.

But they are not contrib, they are part of the core, and should be distributed by default.

Show 5 quoted lines
> That way, nobody gets hurt, and those who are new to Git who want to
> build and install from the source would not have to invent their own
> way to install stuff from contrib/ (the same goes for other contrib/
> tools such as contrib/workdir/ we may want to add a new target to let
> you say "make install.contrib-workdir").
There is already a way to install from contrib.
 % make -C contrib/remote-helpers install
The fact that you never picked my fixes to make it so is another matter.
> I _may_ be persuaded to fold the installation of all possible
> contrib/ stuff into the regular "make install", but I haven't
> thought things through.

But the completions are not contrib, they are essentially part of the core.

If you want to demote them to contrib, then they shouldn't be tested by default, and t9902-completion.sh and t9903-bash-prompt.sh should be moved out to contrib.

You cannot have your cake and eat it at the same time.
Show 14 quoted lines
> The patch does two unrelated things:
> 
>  - Move things in the source tree.
> 
>  - Install the completion by default.
> 
> I very much agree that the latter may be a good thing to have in the
> polished end result.  I am not sure if the installation location
> chosen is sensible.  At least, another redirection
> 
>     git_completion_dir = $(sharedir)
> 
> may be necessary to allow people install these in the location they
> want.
ifneq ($(prefix),$(HOME))
	bashcompletiondir := $(shell pkg-config --variable=completionsdir bash-completion 2> /dev/null)
endif
ifndef bashcompletiondir
	bashcompletiondir = $(sharedir)/bash-completion/completions
endif
-- 
Felipe Contreras
Felipe Contreras· May 7, 2014, 10:10 UTC · re: Felipe Contreras · lore

Re: [PATCH] completion: move out of contrib

Felipe Contreras wrote:
> Yes, *if* they have been packaging them, they have a way. But what if
> they haven't been doing so?
> 
> And for the ones that have a way, now they need one hack less.

As an example of all the hacks needed by a real distribution package, here's the stuff ArchLinux packagers have to do:

  # bash completion
  mkdir -p "$pkgdir"/usr/share/bash-completion/completions/
  install -m644 ./contrib/completion/git-completion.bash "$pkgdir"/usr/share/bash-completion/completions/git
  # fancy git prompt
  mkdir -p "$pkgdir"/usr/share/git/
  install -m644 ./contrib/completion/git-prompt.sh "$pkgdir"/usr/share/git/git-prompt.sh
  # emacs
  make -C contrib/emacs prefix=/usr DESTDIR="$pkgdir" install
  # gnome credentials helper
  install -m755 contrib/credential/gnome-keyring/git-credential-gnome-keyring \
      "$pkgdir"/usr/lib/git-core/git-credential-gnome-keyring
  make -C contrib/credential/gnome-keyring clean
  # the rest of the contrib stuff
  cp -a ./contrib/* $pkgdir/usr/share/git/
  # scripts are for python 2.x
  sed -i 's|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|' \
    $(find "$pkgdir" -name '*.py') \
    "$pkgdir"/usr/share/git/gitview/gitview \
    "$pkgdir"/usr/share/git/remote-helpers/git-remote-bzr \
    "$pkgdir"/usr/share/git/remote-helpers/git-remote-hg
  sed -i 's|#![ ]*/usr/bin/python$|#!/usr/bin/python2|' \
    "$pkgdir"/usr/share/git/svn-fe/svnrdump_sim.py
  # remove perllocal.pod, .packlist, and empty directories.
  rm -rf "$pkgdir"/usr/lib/perl5
And here's what debian packagers have to do:
  # bash completion
  install -d -m0755 '$(GIT)'/etc/bash_completion.d
  install -m0644 contrib/completion/git-completion.bash \
    '$(GIT)'/etc/bash_completion.d/git
  # gitweb
  install -d -m0755 '$(GIT)'/usr/share/gitweb
  ln -s gitweb.cgi '$(GIT)'/usr/share/gitweb/index.cgi
  # contrib hooks
  install -d -m0755 '$(GIT)'/usr/share/git-core/contrib/hooks
  install -m0644 contrib/hooks/* \
    '$(GIT)'/usr/share/git-core/contrib/hooks/
  # contrib
  install -d -m0755 '$(GIT)'/usr/share/doc/git
  cp -R contrib '$(GIT)'/usr/share/doc/git/
  rm -rf '$(GIT)'/usr/share/doc/git/contrib/completion
  rm -rf '$(GIT)'/usr/share/doc/git/contrib/emacs
  find '$(GIT)'/usr/share/doc/git/contrib -type f | xargs chmod 0644
  find '$(GIT)'/usr/share/doc/git/contrib -type d | xargs chmod 0755
    # remove contrib hooks, they are now installed in
    # /usr/share/git-core/contrib, keep symlink for backward compatibility
  rm -rf '$(GIT)'/usr/share/doc/git/contrib/hooks
  ln -s ../../../git-core/contrib/hooks \
    '$(GIT)'/usr/share/doc/git/contrib/
  find '$(GIT)'/usr/share/doc/git/ -name .gitignore | xargs rm -f
If our build system was sane, they wouldn't need so many hacks.
-- 
Felipe Contreras
Junio C Hamano· May 7, 2014, 17:37 UTC · re: Felipe Contreras · lore

Re: [PATCH] completion: move out of contrib

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 17 quoted lines
> As an example of all the hacks needed by a real distribution package,
> here's the stuff ArchLinux packagers have to do:
>
>   # bash completion
>   mkdir -p "$pkgdir"/usr/share/bash-completion/completions/
>   install -m644 ./contrib/completion/git-completion.bash "$pkgdir"/usr/share/bash-completion/completions/git
>...
>
> And here's what debian packagers have to do:
>
>   # bash completion
>   install -d -m0755 '$(GIT)'/etc/bash_completion.d
>   install -m0644 contrib/completion/git-completion.bash \
>     '$(GIT)'/etc/bash_completion.d/git
>...
>
> If our build system was sane, they wouldn't need so many hacks.

I do not see how the above two examples lead to that conclusion. How would it help to blindly install to $(sharedir), or suggestion to use pkg-info when major distros do not even use one?

I would understand if the saneness you seek were for distros to agree on where things should go, or at least agree on how to find out where things should go.

The situation for completion scripts unfortunately has to be even worse than others (like gitweb) in that distros, in order to serve users (not upstream projects) better, want to package various pieces of completion scripts from different projects into a location their bash-completion package wants to see. I applaud their effort and I wish that projects they pull various completion scriptlets from can do more to help them, but I do not think a single makefile target to unconditionally install to $(sharedir) is it, and honestly speaking, the distro completion packagers could do more to help us projects to help them by at least agreeing on how to find out where they want to see our completion scripts installed.

I do not think we are there yet.
Felipe Contreras· May 7, 2014, 19:45 UTC · re: Junio C Hamano · lore

Re: [PATCH] completion: move out of contrib

Junio C Hamano wrote:
Show 18 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > As an example of all the hacks needed by a real distribution package,
> > here's the stuff ArchLinux packagers have to do:
> >
> >   # bash completion
> >   mkdir -p "$pkgdir"/usr/share/bash-completion/completions/
> >   install -m644 ./contrib/completion/git-completion.bash "$pkgdir"/usr/share/bash-completion/completions/git
> >...
> >
> > And here's what debian packagers have to do:
> >
> >   # bash completion
> >   install -d -m0755 '$(GIT)'/etc/bash_completion.d
> >   install -m0644 contrib/completion/git-completion.bash \
> >     '$(GIT)'/etc/bash_completion.d/git
> >...
> >
This is what the latest debian package does:
	# bash completion
	install -d -m0755 '$(GIT)'/usr/share/bash-completion/completions
	install -m0644 contrib/completion/git-completion.bash \
	  '$(GIT)'/usr/share/bash-completion/completions/git
	ln -s git '$(GIT)'/usr/share/bash-completion/completions/gitk
> > If our build system was sane, they wouldn't need so many hacks.
> 
> I do not see how the above two examples lead to that conclusion.
> How would it help to blindly install to $(sharedir),

It is not blind, it is the location bash-completion uses *by default*, and it's what most (all?) distributions use.

> or suggestion to use pkg-info when major distros do not even use one?

Which major distros do not ship with the pkg-config? It is part of bash-completion (as it should be part of every decent shared softare component), they all ship it.

Do you want me to go on a hunt and list all the distrubionts that ship both?

  /usr/share/bash-completion/completions/git
  /usr/share/pkgconfig/bash-completion.pc
How many distributions would it take for you to accept the facts?
> I would understand if the saneness you seek were for distros to
> agree on where things should go, or at least agree on how to find
> out where things should go.
They all gree.
> I do not think we are there yet.
You are wrong.
-- 
Felipe Contreras

← back to recent threads