{"thread":{"id":"6667","subject":"[PATCH 6/8] bash: Support unique completion on git-config.","startedAt":"2007-02-04T07:38:37Z","lastAt":"2007-02-04T07:38:37Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"33543","messageId":"20070204073837.GF17603@spearce.org","threadId":"6667","inReplyTo":null,"subject":"[PATCH 6/8] bash: Support unique completion on git-config.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-04T07:38:37Z","receivedAt":"2007-02-04T07:38:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"In many cases we know a completion will be unique, but we've disabled\nbash's automatic space addition (-o nospace) so we need to do it\nourselves when necessary.\n\nThis change adds additional support for new configuration options\nadded in 1.5.0, as well as some extended completion support for\nthe color.* family of options.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |  120 ++++++++++++++++++++++----------\n 1 files changed, 82 insertions(+), 38 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 382c817..38d6121 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -64,14 +64,19 @@ __git_ps1 ()\n __gitcomp ()\n {\n \tlocal all c s=$'\\n' IFS=' '$'\\t'$'\\n'\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tif [ -n \"$2\" ]; then\n+\t\tcur=\"$3\"\n+\tfi\n \tfor c in $1; do\n-\t\tcase \"$c\" in\n-\t\t--*=*) all=\"$all$c$s\" ;;\n-\t\t*)     all=\"$all$c $s\" ;;\n+\t\tcase \"$c$4\" in\n+\t\t--*=*) all=\"$all$c$4$s\" ;;\n+\t\t*.)    all=\"$all$c$4$s\" ;;\n+\t\t*)     all=\"$all$c$4 $s\" ;;\n \t\tesac\n \tdone\n \tIFS=$s\n-\tCOMPREPLY=($(compgen -W \"$all\" -- \"${COMP_WORDS[COMP_CWORD]}\"))\n+\tCOMPREPLY=($(compgen -P \"$2\" -W \"$all\" -- \"$cur\"))\n \treturn\n }\n \n@@ -666,26 +671,40 @@ _git_config ()\n \tlocal prv=\"${COMP_WORDS[COMP_CWORD-1]}\"\n \tcase \"$prv\" in\n \tbranch.*.remote)\n-\t\tCOMPREPLY=($(compgen -W \"$(__git_remotes)\" -- \"$cur\"))\n+\t\t__gitcomp \"$(__git_remotes)\"\n \t\treturn\n \t\t;;\n \tbranch.*.merge)\n-\t\tCOMPREPLY=($(compgen -W \"$(__git_refs)\" -- \"$cur\"))\n+\t\t__gitcomp \"$(__git_refs)\"\n \t\treturn\n \t\t;;\n \tremote.*.fetch)\n \t\tlocal remote=\"${prv#remote.}\"\n \t\tremote=\"${remote%.fetch}\"\n-\t\tCOMPREPLY=($(compgen -W \"$(__git_refs_remotes \"$remote\")\" \\\n-\t\t\t-- \"$cur\"))\n+\t\t__gitcomp \"$(__git_refs_remotes \"$remote\")\"\n \t\treturn\n \t\t;;\n \tremote.*.push)\n \t\tlocal remote=\"${prv#remote.}\"\n \t\tremote=\"${remote%.push}\"\n-\t\tCOMPREPLY=($(compgen -W \"$(git --git-dir=\"$(__gitdir)\" \\\n+\t\t__gitcomp \"$(git --git-dir=\"$(__gitdir)\" \\\n \t\t\tfor-each-ref --format='%(refname):%(refname)' \\\n-\t\t\trefs/heads)\" -- \"$cur\"))\n+\t\t\trefs/heads)\"\n+\t\treturn\n+\t\t;;\n+\tpull.twohead|pull.octopus)\n+\t\t__gitcomp \"$(__git_merge_strategies)\"\n+\t\treturn\n+\t\t;;\n+\tcolor.branch|color.diff|color.status)\n+\t\t__gitcomp \"always never auto\"\n+\t\treturn\n+\t\t;;\n+\tcolor.*.*)\n+\t\t__gitcomp \"\n+\t\t\tblack red green yellow blue magenta cyan white\n+\t\t\tbold dim ul blink reverse\n+\t\t\t\"\n \t\treturn\n \t\t;;\n \t*.*)\n@@ -695,41 +714,39 @@ _git_config ()\n \tesac\n \tcase \"$cur\" in\n \t--*)\n-\t\tCOMPREPLY=($(compgen -W \"\n+\t\t__gitcomp \"\n \t\t\t--global --list --replace-all\n \t\t\t--get --get-all --get-regexp\n \t\t\t--unset --unset-all\n-\t\t\t\" -- \"$cur\"))\n+\t\t\t\"\n \t\treturn\n \t\t;;\n \tbranch.*.*)\n \t\tlocal pfx=\"${cur%.*}.\"\n \t\tcur=\"${cur##*.}\"\n-\t\tCOMPREPLY=($(compgen -P \"$pfx\" -W \"remote merge\" -- \"$cur\"))\n+\t\t__gitcomp \"remote merge\" \"$pfx\" \"$cur\"\n \t\treturn\n \t\t;;\n \tbranch.*)\n \t\tlocal pfx=\"${cur%.*}.\"\n \t\tcur=\"${cur#*.}\"\n-\t\tCOMPREPLY=($(compgen -P \"$pfx\" -S . \\\n-\t\t\t-W \"$(__git_heads)\" -- \"$cur\"))\n+\t\t__gitcomp \"$(__git_heads)\" \"$pfx\" \"$cur\" \".\"\n \t\treturn\n \t\t;;\n \tremote.*.*)\n \t\tlocal pfx=\"${cur%.*}.\"\n \t\tcur=\"${cur##*.}\"\n-\t\tCOMPREPLY=($(compgen -P \"$pfx\" -W \"url fetch push\" -- \"$cur\"))\n+\t\t__gitcomp \"url fetch push\" \"$pfx\" \"$cur\"\n \t\treturn\n \t\t;;\n \tremote.*)\n \t\tlocal pfx=\"${cur%.*}.\"\n \t\tcur=\"${cur#*.}\"\n-\t\tCOMPREPLY=($(compgen -P \"$pfx\" -S . \\\n-\t\t\t-W \"$(__git_remotes)\" -- \"$cur\"))\n+\t\t__gitcomp \"$(__git_remotes)\" \"$pfx\" \"$cur\" \".\"\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=($(compgen -W \"\n+\t__gitcomp \"\n \t\tapply.whitespace\n \t\tcore.fileMode\n \t\tcore.gitProxy\n@@ -741,40 +758,67 @@ _git_config ()\n \t\tcore.warnAmbiguousRefs\n \t\tcore.compression\n \t\tcore.legacyHeaders\n-\t\ti18n.commitEncoding\n-\t\ti18n.logOutputEncoding\n-\t\tdiff.color\n+\t\tcore.packedGitWindowSize\n+\t\tcore.packedGitLimit\n+\t\tcolor.branch\n+\t\tcolor.branch.current\n+\t\tcolor.branch.local\n+\t\tcolor.branch.remote\n+\t\tcolor.branch.plain\n \t\tcolor.diff\n-\t\tdiff.renameLimit\n-\t\tdiff.renames\n-\t\tpager.color\n+\t\tcolor.diff.plain\n+\t\tcolor.diff.meta\n+\t\tcolor.diff.frag\n+\t\tcolor.diff.old\n+\t\tcolor.diff.new\n+\t\tcolor.diff.commit\n+\t\tcolor.diff.whitespace\n \t\tcolor.pager\n-\t\tstatus.color\n \t\tcolor.status\n-\t\tlog.showroot\n-\t\tshow.difftree\n-\t\tshowbranch.default\n-\t\twhatchanged.difftree\n+\t\tcolor.status.header\n+\t\tcolor.status.added\n+\t\tcolor.status.changed\n+\t\tcolor.status.untracked\n+\t\tdiff.renameLimit\n+\t\tdiff.renames\n+\t\tfetch.unpackLimit\n+\t\tformat.headers\n+\t\tgitcvs.enabled\n+\t\tgitcvs.logfile\n+\t\tgc.reflogexpire\n+\t\tgc.reflogexpireunreachable\n+\t\tgc.rerereresolved\n+\t\tgc.rerereunresolved\n \t\thttp.sslVerify\n \t\thttp.sslCert\n \t\thttp.sslKey\n \t\thttp.sslCAInfo\n \t\thttp.sslCAPath\n \t\thttp.maxRequests\n-\t\thttp.lowSpeedLimit http.lowSpeedTime\n+\t\thttp.lowSpeedLimit\n+\t\thttp.lowSpeedTime\n \t\thttp.noEPSV\n+\t\ti18n.commitEncoding\n+\t\ti18n.logOutputEncoding\n+\t\tlog.showroot\n+\t\tmerge.summary\n+\t\tmerge.verbosity\n \t\tpack.window\n+\t\tpull.octopus\n+\t\tpull.twohead\n \t\trepack.useDeltaBaseOffset\n-\t\tpull.octopus pull.twohead\n-\t\tmerge.summary\n+\t\tshow.difftree\n+\t\tshowbranch.default\n+\t\ttar.umask\n+\t\ttransfer.unpackLimit\n \t\treceive.unpackLimit\n \t\treceive.denyNonFastForwards\n-\t\tuser.name user.email\n-\t\ttar.umask\n-\t\tgitcvs.enabled\n-\t\tgitcvs.logfile\n+\t\tuser.name\n+\t\tuser.email\n+\t\tuser.signingkey\n+\t\twhatchanged.difftree\n \t\tbranch. remote.\n-\t\" -- \"$cur\"))\n+\t\"\n }\n \n _git_reset ()\n-- \n1.5.0.rc3.22.g5057\n"}]}