Skip to content

Commit e17ca92

Browse files
pcloudsgitster
authored andcommitted
completion: drop the hard coded list of config vars
The new help option --config-for-completion is a machine friendlier version of --config where all the placeholders and wildcards are dropped, leaving only the good, completable prefixes for git-completion.bash to consume. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 431bb23 commit e17ca92

File tree

4 files changed

+49
-331
lines changed

4 files changed

+49
-331
lines changed

builtin/help.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static struct option builtin_help_options[] = {
4747
OPT_HIDDEN_BOOL(0, "exclude-guides", &exclude_guides, N_("exclude guides")),
4848
OPT_BOOL('g', "guides", &show_guides, N_("print list of useful guides")),
4949
OPT_BOOL('c', "config", &show_config, N_("print all configuration variable names")),
50+
OPT_SET_INT_F(0, "config-for-completion", &show_config, "", 2, PARSE_OPT_HIDDEN),
5051
OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN),
5152
OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"),
5253
HELP_FORMAT_WEB),
@@ -447,8 +448,14 @@ int cmd_help(int argc, const char **argv, const char *prefix)
447448
}
448449

449450
if (show_config) {
451+
int for_human = show_config == 1;
452+
453+
if (!for_human) {
454+
list_config_help(for_human);
455+
return 0;
456+
}
450457
setup_pager();
451-
list_config_help();
458+
list_config_help(for_human);
452459
printf("\n%s\n", _("'git help config' for more information"));
453460
return 0;
454461
}

contrib/completion/git-completion.bash

Lines changed: 9 additions & 326 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,13 @@ __git_config_get_set_variables ()
19861986
__git config $config_file --name-only --list
19871987
}
19881988

1989+
__git_config_vars=
1990+
__git_compute_config_vars ()
1991+
{
1992+
test -n "$__git_config_vars" ||
1993+
__git_config_vars="$(git help --config-for-completion | sort | uniq)"
1994+
}
1995+
19891996
_git_config ()
19901997
{
19911998
case "$prev" in
@@ -2144,332 +2151,8 @@ _git_config ()
21442151
return
21452152
;;
21462153
esac
2147-
__gitcomp "
2148-
add.ignoreErrors
2149-
advice.amWorkDir
2150-
advice.commitBeforeMerge
2151-
advice.detachedHead
2152-
advice.implicitIdentity
2153-
advice.pushAlreadyExists
2154-
advice.pushFetchFirst
2155-
advice.pushNeedsForce
2156-
advice.pushNonFFCurrent
2157-
advice.pushNonFFMatching
2158-
advice.pushUpdateRejected
2159-
advice.resolveConflict
2160-
advice.rmHints
2161-
advice.statusHints
2162-
advice.statusUoption
2163-
advice.ignoredHook
2164-
alias.
2165-
am.keepcr
2166-
am.threeWay
2167-
apply.ignorewhitespace
2168-
apply.whitespace
2169-
branch.autosetupmerge
2170-
branch.autosetuprebase
2171-
browser.
2172-
clean.requireForce
2173-
color.branch
2174-
color.branch.current
2175-
color.branch.local
2176-
color.branch.plain
2177-
color.branch.remote
2178-
color.decorate.HEAD
2179-
color.decorate.branch
2180-
color.decorate.remoteBranch
2181-
color.decorate.stash
2182-
color.decorate.tag
2183-
color.diff
2184-
color.diff.commit
2185-
color.diff.frag
2186-
color.diff.func
2187-
color.diff.meta
2188-
color.diff.new
2189-
color.diff.old
2190-
color.diff.plain
2191-
color.diff.whitespace
2192-
color.grep
2193-
color.grep.context
2194-
color.grep.filename
2195-
color.grep.function
2196-
color.grep.linenumber
2197-
color.grep.match
2198-
color.grep.selected
2199-
color.grep.separator
2200-
color.interactive
2201-
color.interactive.error
2202-
color.interactive.header
2203-
color.interactive.help
2204-
color.interactive.prompt
2205-
color.pager
2206-
color.showbranch
2207-
color.status
2208-
color.status.added
2209-
color.status.changed
2210-
color.status.header
2211-
color.status.localBranch
2212-
color.status.nobranch
2213-
color.status.remoteBranch
2214-
color.status.unmerged
2215-
color.status.untracked
2216-
color.status.updated
2217-
color.ui
2218-
commit.cleanup
2219-
commit.gpgSign
2220-
commit.status
2221-
commit.template
2222-
commit.verbose
2223-
core.abbrev
2224-
core.askpass
2225-
core.attributesfile
2226-
core.autocrlf
2227-
core.bare
2228-
core.bigFileThreshold
2229-
core.checkStat
2230-
core.commentChar
2231-
core.commitGraph
2232-
core.compression
2233-
core.createObject
2234-
core.deltaBaseCacheLimit
2235-
core.editor
2236-
core.eol
2237-
core.excludesfile
2238-
core.fileMode
2239-
core.fsyncobjectfiles
2240-
core.gitProxy
2241-
core.hideDotFiles
2242-
core.hooksPath
2243-
core.ignoreStat
2244-
core.ignorecase
2245-
core.logAllRefUpdates
2246-
core.loosecompression
2247-
core.notesRef
2248-
core.packedGitLimit
2249-
core.packedGitWindowSize
2250-
core.packedRefsTimeout
2251-
core.pager
2252-
core.precomposeUnicode
2253-
core.preferSymlinkRefs
2254-
core.preloadindex
2255-
core.protectHFS
2256-
core.protectNTFS
2257-
core.quotepath
2258-
core.repositoryFormatVersion
2259-
core.safecrlf
2260-
core.sharedRepository
2261-
core.sparseCheckout
2262-
core.splitIndex
2263-
core.sshCommand
2264-
core.symlinks
2265-
core.trustctime
2266-
core.untrackedCache
2267-
core.warnAmbiguousRefs
2268-
core.whitespace
2269-
core.worktree
2270-
credential.helper
2271-
credential.useHttpPath
2272-
credential.username
2273-
credentialCache.ignoreSIGHUP
2274-
diff.autorefreshindex
2275-
diff.external
2276-
diff.ignoreSubmodules
2277-
diff.mnemonicprefix
2278-
diff.noprefix
2279-
diff.renameLimit
2280-
diff.renames
2281-
diff.statGraphWidth
2282-
diff.submodule
2283-
diff.suppressBlankEmpty
2284-
diff.tool
2285-
diff.wordRegex
2286-
diff.algorithm
2287-
difftool.
2288-
difftool.prompt
2289-
fetch.recurseSubmodules
2290-
fetch.unpackLimit
2291-
format.attach
2292-
format.cc
2293-
format.coverLetter
2294-
format.from
2295-
format.headers
2296-
format.numbered
2297-
format.pretty
2298-
format.signature
2299-
format.signoff
2300-
format.subjectprefix
2301-
format.suffix
2302-
format.thread
2303-
format.to
2304-
gc.
2305-
gc.aggressiveDepth
2306-
gc.aggressiveWindow
2307-
gc.auto
2308-
gc.autoDetach
2309-
gc.autopacklimit
2310-
gc.logExpiry
2311-
gc.packrefs
2312-
gc.pruneexpire
2313-
gc.reflogexpire
2314-
gc.reflogexpireunreachable
2315-
gc.rerereresolved
2316-
gc.rerereunresolved
2317-
gc.worktreePruneExpire
2318-
gitcvs.allbinary
2319-
gitcvs.commitmsgannotation
2320-
gitcvs.dbTableNamePrefix
2321-
gitcvs.dbdriver
2322-
gitcvs.dbname
2323-
gitcvs.dbpass
2324-
gitcvs.dbuser
2325-
gitcvs.enabled
2326-
gitcvs.logfile
2327-
gitcvs.usecrlfattr
2328-
guitool.
2329-
gui.blamehistoryctx
2330-
gui.commitmsgwidth
2331-
gui.copyblamethreshold
2332-
gui.diffcontext
2333-
gui.encoding
2334-
gui.fastcopyblame
2335-
gui.matchtrackingbranch
2336-
gui.newbranchtemplate
2337-
gui.pruneduringfetch
2338-
gui.spellingdictionary
2339-
gui.trustmtime
2340-
help.autocorrect
2341-
help.browser
2342-
help.format
2343-
http.lowSpeedLimit
2344-
http.lowSpeedTime
2345-
http.maxRequests
2346-
http.minSessions
2347-
http.noEPSV
2348-
http.postBuffer
2349-
http.proxy
2350-
http.sslCipherList
2351-
http.sslVersion
2352-
http.sslCAInfo
2353-
http.sslCAPath
2354-
http.sslCert
2355-
http.sslCertPasswordProtected
2356-
http.sslKey
2357-
http.sslVerify
2358-
http.useragent
2359-
i18n.commitEncoding
2360-
i18n.logOutputEncoding
2361-
imap.authMethod
2362-
imap.folder
2363-
imap.host
2364-
imap.pass
2365-
imap.port
2366-
imap.preformattedHTML
2367-
imap.sslverify
2368-
imap.tunnel
2369-
imap.user
2370-
init.templatedir
2371-
instaweb.browser
2372-
instaweb.httpd
2373-
instaweb.local
2374-
instaweb.modulepath
2375-
instaweb.port
2376-
interactive.singlekey
2377-
log.date
2378-
log.decorate
2379-
log.showroot
2380-
mailmap.file
2381-
man.
2382-
man.viewer
2383-
merge.
2384-
merge.conflictstyle
2385-
merge.log
2386-
merge.renameLimit
2387-
merge.renormalize
2388-
merge.stat
2389-
merge.tool
2390-
merge.verbosity
2391-
mergetool.
2392-
mergetool.keepBackup
2393-
mergetool.keepTemporaries
2394-
mergetool.prompt
2395-
notes.displayRef
2396-
notes.rewrite.
2397-
notes.rewrite.amend
2398-
notes.rewrite.rebase
2399-
notes.rewriteMode
2400-
notes.rewriteRef
2401-
pack.compression
2402-
pack.deltaCacheLimit
2403-
pack.deltaCacheSize
2404-
pack.depth
2405-
pack.indexVersion
2406-
pack.packSizeLimit
2407-
pack.threads
2408-
pack.window
2409-
pack.windowMemory
2410-
pager.
2411-
pretty.
2412-
pull.octopus
2413-
pull.twohead
2414-
push.default
2415-
push.followTags
2416-
rebase.autosquash
2417-
rebase.stat
2418-
receive.autogc
2419-
receive.denyCurrentBranch
2420-
receive.denyDeleteCurrent
2421-
receive.denyDeletes
2422-
receive.denyNonFastForwards
2423-
receive.fsckObjects
2424-
receive.unpackLimit
2425-
receive.updateserverinfo
2426-
remote.pushdefault
2427-
remotes.
2428-
repack.usedeltabaseoffset
2429-
rerere.autoupdate
2430-
rerere.enabled
2431-
sendemail.
2432-
sendemail.aliasesfile
2433-
sendemail.aliasfiletype
2434-
sendemail.bcc
2435-
sendemail.cc
2436-
sendemail.cccmd
2437-
sendemail.chainreplyto
2438-
sendemail.confirm
2439-
sendemail.envelopesender
2440-
sendemail.from
2441-
sendemail.identity
2442-
sendemail.multiedit
2443-
sendemail.signedoffbycc
2444-
sendemail.smtpdomain
2445-
sendemail.smtpencryption
2446-
sendemail.smtppass
2447-
sendemail.smtpserver
2448-
sendemail.smtpserveroption
2449-
sendemail.smtpserverport
2450-
sendemail.smtpuser
2451-
sendemail.suppresscc
2452-
sendemail.suppressfrom
2453-
sendemail.thread
2454-
sendemail.to
2455-
sendemail.tocmd
2456-
sendemail.validate
2457-
sendemail.smtpbatchsize
2458-
sendemail.smtprelogindelay
2459-
showbranch.default
2460-
status.relativePaths
2461-
status.showUntrackedFiles
2462-
status.submodulesummary
2463-
submodule.
2464-
tar.umask
2465-
transfer.unpackLimit
2466-
url.
2467-
user.email
2468-
user.name
2469-
user.signingkey
2470-
web.browser
2471-
branch. remote.
2472-
"
2154+
__git_compute_config_vars
2155+
__gitcomp "$__git_config_vars"
24732156
}
24742157

24752158
_git_remote ()

0 commit comments

Comments
 (0)