git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v2] completion: graduate out of contrib
Date: Thu,  8 May 2014 22:53:07 -0500	[thread overview]
Message-ID: <1399607587-14127-1-git-send-email-felipe.contreras@gmail.com> (raw)

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.

We should be consistent and either we move the tests to contrib, or we
move the completions out of contrib.

Let's move them out of contrib and install them by default.

By default bash-completion installs the completions to
$(pkgdatadir)/completions, which is
$(prefix)/share/bash-completion/completions. And since most distributions do
not change this, it is obviously the right default. However,
bash-completion recommends to use pkg-config to find the right location,
so we could use that, but it's much easier to let distributions do it:

  bashcomdir=$pkg-config --variable=completionsdir bash-completion)

By default zsh looks for completions in
$(prefix)/share/zsh/site-functions.

The distributions use these locations to install Git completions:

  ArchLinux: /usr/share/bash-completion/completions/
  Debian: /usr/share/bash-completion/completions/
  Fedora: /etc/bash_completion.d/
  Ubuntu: /usr/share/bash-completion/completions/
  Mint: /usr/share/bash-completion/completions/
  OpenSuse: /etc/bash_completion.d/

However, in both Fedora and OpenSUSE their bash-completion intallations
use /usr/share/bash-completion/completions/ (they don't change the
default). So it  seems to a be a bug from the packager, since they
recommend the bash-completion location[1]

If some weird distribution has a problem with the location, they can
override 'bashcompdir' anyway.

[1] http://article.gmane.org/gmane.linux.redhat.fedora.devel/177405

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Makefile                                           | 6 ++++++
 {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, 8 insertions(+), 2 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%)

diff --git a/Makefile b/Makefile
index 52bdc95..2690903 100644
--- a/Makefile
+++ b/Makefile
@@ -379,6 +379,7 @@ gitwebdir = $(sharedir)/gitweb
 localedir = $(sharedir)/locale
 template_dir = share/git-core/templates
 htmldir = $(prefix)/share/doc/git-doc
+bashcompdir = $(sharedir)/bash-completion/completions
 ETC_GITCONFIG = $(sysconfdir)/gitconfig
 ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
 lib = lib
@@ -1582,6 +1583,8 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
 htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
 prefix_SQ = $(subst ','\'',$(prefix))
 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
+sharedir_SQ = $(subst ','\'',$(sharedir))
+bashcompdir_SQ = $(subst ','\'',$(bashcompdir))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -2345,6 +2348,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)$(bashcompdir_SQ)'/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 6efd0d9..59d2cb9 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.27.gbce2056

                 reply	other threads:[~2014-05-09  4:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399607587-14127-1-git-send-email-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).