Revision 8b0eaa41f2371cafd28324b00128405a80740b16 authored by SZEDER Gábor on 22 March 2018, 14:16:04 UTC, committed by Junio C Hamano on 22 March 2018, 17:22:09 UTC
The established way to update the completion script in an already
running shell is to simply source it again: this brings in any new
--options and features, and clears caching variables.  E.g. it clears
the variables caching the list of (all|porcelain) git commands, so
when they are later lazy-initialized again, then they will list and
cache any newly installed commmands as well.

Unfortunately, since d401f3debc (git-completion.bash: introduce
__gitcomp_builtin, 2018-02-09) and subsequent patches this doesn't
work for a lot of git commands' options.  To eliminate a lot of
hard-to-maintain hard-coded lists of options, those commits changed
the completion script to use a bunch of programmatically created and
lazy-initialized variables to cache the options of those builtin
porcelain commands that use parse-options.  These variables are not
cleared upon sourcing the completion script, therefore they continue
caching the old lists of options, even when some commands recently
learned new options or when deprecated options were removed.

Always 'unset' these variables caching the options of builtin commands
when sourcing the completion script.

Redirect 'unset's stderr to /dev/null, because ZSH's 'unset' complains
if it's invoked without any arguments, i.e. no variables caching
builtin's options are set.  This can happen, if someone were to source
the completion script twice without completing any --options in
between.  Bash stays silent in this case.

Add tests to ensure that these variables are indeed cleared when the
completion script is sourced; not just the variables caching options,
but all other caching variables, i.e. the variables caching commands,
porcelain commands and merge strategies as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 27b42d0
History
File Mode Size
add.c -rw-r--r-- 15.0 KB
am.c -rw-r--r-- 58.5 KB
annotate.c -rw-r--r-- 444 bytes
apply.c -rw-r--r-- 662 bytes
archive.c -rw-r--r-- 3.0 KB
bisect--helper.c -rw-r--r-- 4.2 KB
blame.c -rw-r--r-- 26.1 KB
branch.c -rw-r--r-- 24.6 KB
bundle.c -rw-r--r-- 1.8 KB
cat-file.c -rw-r--r-- 16.7 KB
check-attr.c -rw-r--r-- 4.5 KB
check-ignore.c -rw-r--r-- 5.0 KB
check-mailmap.c -rw-r--r-- 1.6 KB
check-ref-format.c -rw-r--r-- 2.2 KB
checkout-index.c -rw-r--r-- 6.6 KB
checkout.c -rw-r--r-- 35.2 KB
clean.c -rw-r--r-- 25.4 KB
clone.c -rw-r--r-- 33.5 KB
column.c -rw-r--r-- 1.9 KB
commit-tree.c -rw-r--r-- 3.0 KB
commit.c -rw-r--r-- 54.1 KB
config.c -rw-r--r-- 21.2 KB
count-objects.c -rw-r--r-- 4.1 KB
credential.c -rw-r--r-- 695 bytes
describe.c -rw-r--r-- 16.5 KB
diff-files.c -rw-r--r-- 2.0 KB
diff-index.c -rw-r--r-- 1.4 KB
diff-tree.c -rw-r--r-- 4.8 KB
diff.c -rw-r--r-- 11.9 KB
difftool.c -rw-r--r-- 21.0 KB
fast-export.c -rw-r--r-- 28.1 KB
fetch-pack.c -rw-r--r-- 5.4 KB
fetch.c -rw-r--r-- 39.4 KB
fmt-merge-msg.c -rw-r--r-- 18.2 KB
for-each-ref.c -rw-r--r-- 3.1 KB
fsck.c -rw-r--r-- 19.5 KB
gc.c -rw-r--r-- 12.3 KB
get-tar-commit-id.c -rw-r--r-- 1.0 KB
grep.c -rw-r--r-- 29.6 KB
hash-object.c -rw-r--r-- 4.4 KB
help.c -rw-r--r-- 12.6 KB
index-pack.c -rw-r--r-- 46.5 KB
init-db.c -rw-r--r-- 16.0 KB
interpret-trailers.c -rw-r--r-- 3.5 KB
log.c -rw-r--r-- 51.9 KB
ls-files.c -rw-r--r-- 18.8 KB
ls-remote.c -rw-r--r-- 3.1 KB
ls-tree.c -rw-r--r-- 4.9 KB
mailinfo.c -rw-r--r-- 1.7 KB
mailsplit.c -rw-r--r-- 7.3 KB
merge-base.c -rw-r--r-- 6.1 KB
merge-file.c -rw-r--r-- 3.2 KB
merge-index.c -rw-r--r-- 2.2 KB
merge-ours.c -rw-r--r-- 820 bytes
merge-recursive.c -rw-r--r-- 2.2 KB
merge-tree.c -rw-r--r-- 8.8 KB
merge.c -rw-r--r-- 43.0 KB
mktag.c -rw-r--r-- 5.2 KB
mktree.c -rw-r--r-- 5.0 KB
mv.c -rw-r--r-- 8.5 KB
name-rev.c -rw-r--r-- 12.1 KB
notes.c -rw-r--r-- 28.1 KB
pack-objects.c -rw-r--r-- 83.2 KB
pack-redundant.c -rw-r--r-- 15.0 KB
pack-refs.c -rw-r--r-- 627 bytes
patch-id.c -rw-r--r-- 4.1 KB
prune-packed.c -rw-r--r-- 1.5 KB
prune.c -rw-r--r-- 3.8 KB
pull.c -rw-r--r-- 27.5 KB
push.c -rw-r--r-- 18.5 KB
read-tree.c -rw-r--r-- 7.4 KB
rebase--helper.c -rw-r--r-- 2.8 KB
receive-pack.c -rw-r--r-- 51.0 KB
reflog.c -rw-r--r-- 18.6 KB
remote-ext.c -rw-r--r-- 4.5 KB
remote-fd.c -rw-r--r-- 1.8 KB
remote.c -rw-r--r-- 44.3 KB
repack.c -rw-r--r-- 12.2 KB
replace.c -rw-r--r-- 13.9 KB
rerere.c -rw-r--r-- 3.0 KB
reset.c -rw-r--r-- 11.3 KB
rev-list.c -rw-r--r-- 13.4 KB
rev-parse.c -rw-r--r-- 21.1 KB
revert.c -rw-r--r-- 6.3 KB
rm.c -rw-r--r-- 10.5 KB
send-pack.c -rw-r--r-- 7.7 KB
shortlog.c -rw-r--r-- 9.6 KB
show-branch.c -rw-r--r-- 22.5 KB
show-ref.c -rw-r--r-- 5.5 KB
stripspace.c -rw-r--r-- 1.5 KB
submodule--helper.c -rw-r--r-- 40.7 KB
symbolic-ref.c -rw-r--r-- 2.0 KB
tag.c -rw-r--r-- 15.1 KB
unpack-file.c -rw-r--r-- 842 bytes
unpack-objects.c -rw-r--r-- 13.6 KB
update-index.c -rw-r--r-- 32.0 KB
update-ref.c -rw-r--r-- 11.7 KB
update-server-info.c -rw-r--r-- 643 bytes
upload-archive.c -rw-r--r-- 3.1 KB
var.c -rw-r--r-- 1.7 KB
verify-commit.c -rw-r--r-- 2.4 KB
verify-pack.c -rw-r--r-- 1.9 KB
verify-tag.c -rw-r--r-- 1.9 KB
worktree.c -rw-r--r-- 16.2 KB
write-tree.c -rw-r--r-- 1.5 KB

back to top