ks/precompute-completion

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Nieder
Date: Wednesday, November 11, 2009 - 3:08 pm

Hi,


As a distro user, I don’t think I would be able to use it until there
is a command to update the installed completion, to call after adding
a new git command to my $PATH.  This could mean:

 - git-completion.bash.generate learns to read the .in file and
   write the completion script to arbitrary paths (or just always
   uses stdin and stdout?)

 - distros install git-completion.bash.{generate,in} to /usr/share/git-core

 - distros install a simple completion script to /etc/bash_completion.d
   that passes the buck, e.g.

-- %< --
# bash completion support for core Git.
#
# Run update-git-completion to generate these files.
#
__git_user_completion=~/.cache/git-core/git-completion.bash
__git_system_completion=/var/cache/git-core/git-completion.bash

if test -r "$__git_user_completion"
then
	. "$__git_user_completion"
elif test -r "$__git_system_completion"
then
	. "$__git_system_completion"
fi
-- >% --

 - new update-git-completion script, something like this:

-- %< --
#!/bin/sh
USAGE="update-git-completion {--system | --user | <filename>}"
datadir=/usr/share/git-core
die() {
	echo >&2 "$*"
	exit 1
}

if ! test $# -eq 1
then
	die "usage: $USAGE"
fi

if test "$1" = "--system"
then
	output=/var/cache/git-core/git-completion.bash
elif test "$1" = "--user"
then
	output=$HOME/.cache/git-core/git-completion.bash
else
	output=$1
fi

rm -f "$output+" || die "cannot remove $output+"
sh "$datadir"/git-completion.bash.generate \
	< "$datadir"/git-completion.bash.in \
	> "$output+" || die "failed to generate completion script"
bash -n "$output+" || {
	rm -f "$output+"
	die "generated script fails syntax check"
}
mv -f "$output+" "$output" || {
	rm -f "$output+"
	die "failed to install completion script"
}
-- >% --

Thoughts?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
excerpts from tomorrow's &quot;What's cooking&quot; draft, Junio C Hamano, (Wed Nov 11, 2:34 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Sverre Rabbelier, (Wed Nov 11, 10:57 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Nicolas Sebrecht, (Wed Nov 11, 11:42 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Daniel Barkalow, (Wed Nov 11, 11:45 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Nicolas Sebrecht, (Wed Nov 11, 2:26 pm)
ks/precompute-completion, Jonathan Nieder, (Wed Nov 11, 3:08 pm)
[PATCH] give priority to progress messages, Nicolas Pitre, (Wed Nov 11, 3:24 pm)
Re: ks/precompute-completion, Stephen Boyd, (Thu Nov 12, 11:40 pm)
Re: ks/precompute-completion, Jonathan Nieder, (Fri Nov 13, 12:06 am)
Re: ks/precompute-completion, Stephen Boyd, (Fri Nov 13, 12:12 am)
[PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 1:50 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 2:03 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 3:29 am)
Re: [PATCH] Speed up bash completion loading, Stephen Boyd, (Fri Nov 13, 1:43 pm)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 3:35 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 4:01 am)
Re: [PATCH] Speed up bash completion loading, SZEDER =?iso-8859-1? ..., (Sat Nov 14, 7:43 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 12:33 pm)
Re: [PATCH] Speed up bash completion loading, Stephen Boyd, (Sat Nov 14, 4:46 pm)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Sverre Rabbelier, (Sat Nov 14, 7:07 pm)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 11:50 pm)
Re: [PATCH] Speed up bash completion loading, Junio C Hamano, (Sun Nov 15, 2:05 am)
[PATCH v2] Speed up bash completion loading, Jonathan Nieder, (Sun Nov 15, 3:29 am)
Re: [PATCH v2] Speed up bash completion loading, Shawn O. Pearce, (Sun Nov 15, 6:55 pm)
Re: [PATCH v2] Speed up bash completion loading, Stephen Boyd, (Mon Nov 16, 1:28 am)
[PATCH v3] Speed up bash completion loading, Jonathan Nieder, (Tue Nov 17, 5:49 pm)
Re: [PATCH v3] Speed up bash completion loading, Shawn O. Pearce, (Tue Nov 17, 5:59 pm)