{"thread":{"id":"30254","subject":"[PATCH v2] completion: add new git_complete helper","startedAt":"2012-04-15T21:20:14Z","lastAt":"2012-04-22T12:58:48Z","messageCount":40,"participants":["Felipe Contreras","Jonathan Nieder","Junio C Hamano","SZEDER Gábor","Ville Skyttä"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"189360","messageId":"1334524814-13581-1-git-send-email-felipe.contreras@gmail.com","threadId":"30254","inReplyTo":null,"subject":"[PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-15T21:20:14Z","receivedAt":"2012-04-15T21:20:14Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This simplifies the completions, and makes it easier to define aliases:\n\n git_complete gf git_fetch\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nSince v2:\n\n * Remove stuff related to aliases fixes; should work on top of master\n\n contrib/completion/git-completion.bash |   68 +++++++++++++++-----------------\n t/t9902-completion.sh                  |    2 +-\n 2 files changed, 32 insertions(+), 38 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 31f714d..abb4ccb 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2603,21 +2603,6 @@ _git ()\n {\n \tlocal i c=1 command __git_dir\n \n-\tif [[ -n ${ZSH_VERSION-} ]]; then\n-\t\temulate -L bash\n-\t\tsetopt KSH_TYPESET\n-\n-\t\t# workaround zsh's bug that leaves 'words' as a special\n-\t\t# variable in versions < 4.3.12\n-\t\ttypeset -h words\n-\n-\t\t# workaround zsh's bug that quotes spaces in the COMPREPLY\n-\t\t# array if IFS doesn't contain spaces.\n-\t\ttypeset -h IFS\n-\tfi\n-\n-\tlocal cur words cword prev\n-\t_get_comp_words_by_ref -n =: cur words cword prev\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n \t\tcase \"$i\" in\n@@ -2663,22 +2648,6 @@ _git ()\n \n _gitk ()\n {\n-\tif [[ -n ${ZSH_VERSION-} ]]; then\n-\t\temulate -L bash\n-\t\tsetopt KSH_TYPESET\n-\n-\t\t# workaround zsh's bug that leaves 'words' as a special\n-\t\t# variable in versions < 4.3.12\n-\t\ttypeset -h words\n-\n-\t\t# workaround zsh's bug that quotes spaces in the COMPREPLY\n-\t\t# array if IFS doesn't contain spaces.\n-\t\ttypeset -h IFS\n-\tfi\n-\n-\tlocal cur words cword prev\n-\t_get_comp_words_by_ref -n =: cur words cword prev\n-\n \t__git_has_doubledash && return\n \n \tlocal g=\"$(__gitdir)\"\n@@ -2699,16 +2668,41 @@ _gitk ()\n \t__git_complete_revlist\n }\n \n-complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \\\n-\t|| complete -o default -o nospace -F _git git\n-complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \\\n-\t|| complete -o default -o nospace -F _gitk gitk\n+foo_wrap ()\n+{\n+\tif [[ -n ${ZSH_VERSION-} ]]; then\n+\t\temulate -L bash\n+\t\tsetopt KSH_TYPESET\n+\n+\t\t# workaround zsh's bug that leaves 'words' as a special\n+\t\t# variable in versions < 4.3.12\n+\t\ttypeset -h words\n+\n+\t\t# workaround zsh's bug that quotes spaces in the COMPREPLY\n+\t\t# array if IFS doesn't contain spaces.\n+\t\ttypeset -h IFS\n+\tfi\n+\tlocal cur words cword prev\n+\t_get_comp_words_by_ref -n =: cur words cword prev\n+\tfoo \"$@\"\n+}\n+\n+git_complete ()\n+{\n+\tlocal name=\"${2-$1}\"\n+\teval \"$(typeset -f foo_wrap | sed -e \"s/foo/_$name/\")\"\n+\tcomplete -o bashdefault -o default -o nospace -F _${name}_wrap $1 2>/dev/null \\\n+\t\t|| complete -o default -o nospace -F _${name}_wrap $1\n+}\n+\n+git_complete git\n+git_complete gitk\n \n # The following are necessary only for Cygwin, and only are needed\n # when the user has tab-completed the executable name and consequently\n # included the '.exe' suffix.\n #\n if [ Cygwin = \"$(uname -o 2>/dev/null)\" ]; then\n-complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \\\n-\t|| complete -o default -o nospace -F _git git.exe\n+git_complete git.exe git\n fi\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 7bd37f5..0f1a9ec 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -63,7 +63,7 @@ run_completion ()\n \tlocal _cword\n \t_words=( $1 )\n \t(( _cword = ${#_words[@]} - 1 ))\n-\t_git && print_comp\n+\t_git_wrap && print_comp\n }\n \n test_completion ()\n-- \n1.7.10\n"},{"id":"189362","messageId":"20120415213718.GB5813@burratino","threadId":"30254","inReplyTo":"1334524814-13581-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-15T21:37:18Z","receivedAt":"2012-04-15T21:37:18Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> This simplifies the completions, and makes it easier to define aliases:\n>\n>  git_complete gf git_fetch\n\nSounds neat.  Unfortunately users could already be using a function\nwith some other purpose named git_complete in their .profile and this\nwould override it.  The completion script has so far stuck to a\nlimited namespace:\n\n\t_git_*\t(completion functions)\n\t__git_*\t(everything else, including public interfaces like __git_ps1)\n\nA name like __git_complete should work, presumably.\n\nHope that helps,\nJonathan\n"},{"id":"189389","messageId":"CAMP44s0PWAV=nD1xnAFMx8OPby88W2jKwDGtiUFY4LA93D-gAw@mail.gmail.com","threadId":"30254","inReplyTo":"20120415213718.GB5813@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T10:49:56Z","receivedAt":"2012-04-16T10:49:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 12:37 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> This simplifies the completions, and makes it easier to define aliases:\n>>\n>>  git_complete gf git_fetch\n>\n> Sounds neat.  Unfortunately users could already be using a function\n> with some other purpose named git_complete in their .profile and this\n> would override it.  The completion script has so far stuck to a\n> limited namespace:\n>\n>        _git_*  (completion functions)\n>        __git_* (everything else, including public interfaces like __git_ps1)\n>\n> A name like __git_complete should work, presumably.\n\nPerhaps it's time to avoid the __ prefix for public interfaces;\notherwise how would people know they are public?\n\n-- \nFelipe Contreras\n"},{"id":"189420","messageId":"7vaa2by8nj.fsf@alter.siamese.dyndns.org","threadId":"30254","inReplyTo":"CAMP44s0PWAV=nD1xnAFMx8OPby88W2jKwDGtiUFY4LA93D-gAw@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-16T15:54:24Z","receivedAt":"2012-04-16T15:54:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Mon, Apr 16, 2012 at 12:37 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> The completion script has so far stuck to a limited namespace:\n>>\n>>        _git_*  (completion functions)\n>>        __git_* (everything else, including public interfaces like __git_ps1)\n>>\n>> A name like __git_complete should work, presumably.\n>\n> Perhaps it's time to avoid the __ prefix for public interfaces;\n> otherwise how would people know they are public?\n\nWe could do the same as __git_ps1, no?  People know to use it already;\nthey know it is public.\n\nI am OK with introducing git_ps1 while keeping __git_ps1 as an equivalent\nand declare that git_$anything will be the surface interface for end users\nto *use* the machinery we provide, though.  Then git_complete could be\nintroduced without __git_complete equivalent.  Probably _git_$name has to\nstay an implementation detail (i.e. the users can use it but it is their\nresponsibility to update their using script when the implementation\nchanges).\n"},{"id":"189421","messageId":"20120416160001.GK5813@burratino","threadId":"30254","inReplyTo":"CAMP44s0PWAV=nD1xnAFMx8OPby88W2jKwDGtiUFY4LA93D-gAw@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T16:00:01Z","receivedAt":"2012-04-16T16:00:01Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> Perhaps it's time to avoid the __ prefix for public interfaces;\n> otherwise how would people know they are public?\n\nI'm happy as long as all the identifiers the script exports start with\nan underscore, as that is the usual convention for completion scripts.\nWithin that namespace, if people want to use ___git or _git__ for\nprivate things or something, I don't mind.\n\nIf __git_ps1 is moved to a separate script library, it seems fine for\nit to provide a git_ps1 identifier with no leading underscores when it\nis not being implicitly included by the completion script.\n\nJonathan\n"},{"id":"189426","messageId":"20120416160729.GM5813@burratino","threadId":"30254","inReplyTo":"7vaa2by8nj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T16:07:29Z","receivedAt":"2012-04-16T16:07:29Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> I am OK with introducing git_ps1 while keeping __git_ps1 as an equivalent\n> and declare that git_$anything will be the surface interface for end users\n> to *use* the machinery we provide, though.\n\nThe problem is that completion scripts are often included implicitly\nin .profile through the bash completion machinery.  Users do not have\nto explicitly ask for them, so there is no reason for users to expect\nthat the function name \"more_cowbell\" is dangerous to use in .profile\nbecause some day the completion script for the \"more\" command will\nstart using it.\n\nBecause of these considerations, the convention is that every\nidentifier provided by a completion script, including public ones,\nstarts with an underscore.\n"},{"id":"189430","messageId":"7vzkabwsav.fsf@alter.siamese.dyndns.org","threadId":"30254","inReplyTo":"20120416160729.GM5813@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-16T16:32:56Z","receivedAt":"2012-04-16T16:32:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Because of these considerations, the convention is that every\n> identifier provided by a completion script, including public ones,\n> starts with an underscore.\n\nOK.\n"},{"id":"189450","messageId":"CAMP44s2_VYNFeBi9GPa9CeqT=oRmSq1J1XaSP+aKgC6bJ55Lfg@mail.gmail.com","threadId":"30254","inReplyTo":"20120416160729.GM5813@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T20:04:52Z","receivedAt":"2012-04-16T20:04:52Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 7:07 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Junio C Hamano wrote:\n>\n>> I am OK with introducing git_ps1 while keeping __git_ps1 as an equivalent\n>> and declare that git_$anything will be the surface interface for end users\n>> to *use* the machinery we provide, though.\n>\n> The problem is that completion scripts are often included implicitly\n> in .profile through the bash completion machinery.  Users do not have\n> to explicitly ask for them, so there is no reason for users to expect\n> that the function name \"more_cowbell\" is dangerous to use in .profile\n> because some day the completion script for the \"more\" command will\n> start using it.\n\nSure, that's why we would have _git_cowbell instead, so for *most* of\nfunctions the user would have no trouble, it would *only* be\ngit_completion the one without prefix, and I think the name is quite\nsafe. There's quite likely few, probably nobody, actually using that\nfunction name in their profiles.\n\nAlso, the script would now be loaded only *after*, the user types 'git\n<TAB>'. And there's already a bunch of functions that are already\nexported by just having bash completion: have(), quote(), dequote(),\nquote_readline(). And there's at least one script that uses a function\nwithout a prefix: ri_get_methods()\n\nI would like to see a completion script that actually has a function\nsupposed to be exported and that still uses the _ prefix anyway.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189454","messageId":"20120416200941.GD12613@burratino","threadId":"30254","inReplyTo":"CAMP44s2_VYNFeBi9GPa9CeqT=oRmSq1J1XaSP+aKgC6bJ55Lfg@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T20:09:41Z","receivedAt":"2012-04-16T20:09:41Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> I would like to see a completion script that actually has a function\n> supposed to be exported and that still uses the _ prefix anyway.\n\nThe /etc/bash_completion library itself exports lots and lots of\nfunctions with a _ prefix.\n"},{"id":"189457","messageId":"CAMP44s0CVsmHw4jQqHvZMi342V8-Yh2zYYcAE_5EHu5OAiktcw@mail.gmail.com","threadId":"30254","inReplyTo":"20120416200941.GD12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T20:30:59Z","receivedAt":"2012-04-16T20:30:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 11:09 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> I would like to see a completion script that actually has a function\n>> supposed to be exported and that still uses the _ prefix anyway.\n>\n> The /etc/bash_completion library itself exports lots and lots of\n> functions with a _ prefix.\n\nWe are not making a bash_completion library; I mean a bash completion\nscript (other than the library).\n\n-- \nFelipe Contreras\n"},{"id":"189458","messageId":"20120416203320.GF12613@burratino","threadId":"30254","inReplyTo":"CAMP44s0CVsmHw4jQqHvZMi342V8-Yh2zYYcAE_5EHu5OAiktcw@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T20:33:20Z","receivedAt":"2012-04-16T20:33:20Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n> On Mon, Apr 16, 2012 at 11:09 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Felipe Contreras wrote:\n\n>>> I would like to see a completion script that actually has a function\n>>> supposed to be exported and that still uses the _ prefix anyway.\n>>\n>> The /etc/bash_completion library itself exports lots and lots of\n>> functions with a _ prefix.\n>\n> We are not making a bash_completion library; I mean a bash completion\n> script (other than the library).\n\nOk.  If you refuse to put two and two together, then I will (as usual\nwhen this happens) just be a little passive aggressive and annoyed and\nlet you talk to other people.\n\nCheers,\nJonathan\n"},{"id":"189459","messageId":"CAMP44s0Q2A_oKJx27ct9W__KVQkQxzst3H7gq6sZDhrCLDQaag@mail.gmail.com","threadId":"30254","inReplyTo":"20120416203320.GF12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T20:42:07Z","receivedAt":"2012-04-16T20:42:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 11:33 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>> On Mon, Apr 16, 2012 at 11:09 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>> Felipe Contreras wrote:\n>\n>>>> I would like to see a completion script that actually has a function\n>>>> supposed to be exported and that still uses the _ prefix anyway.\n>>>\n>>> The /etc/bash_completion library itself exports lots and lots of\n>>> functions with a _ prefix.\n>>\n>> We are not making a bash_completion library; I mean a bash completion\n>> script (other than the library).\n>\n> Ok.  If you refuse to put two and two together, then I will (as usual\n> when this happens) just be a little passive aggressive and annoyed and\n> let you talk to other people.\n\nJust to be clear; we are making a completion script for the 'git'\ncommand, so if we are looking for guidance on what other 'foo' command\ncompletion scripts do, the bash completion library itself is not good\nguidance.\n\nMy gut feeling is that there's no completion script that exports\nfunctions meant to be used directly by the user, so there's really no\nguidance for this.\n\nNow, even if you use the bash completion library, it still does export\nfunctions without a prefix, so why take the ones with prefix as a\nrule, and ignore the other ones? It seems like there's no real\nguideline for what gets a prefix and what doesn't, even in the bash\ncompletion library itself, which I don't think should be used a\nguideline anyway.\n\nThe closest relative of 'git_complete' would be 'complete', both of\ncourse are meant for public usage. I have not seen any other functions\nthat are similar.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189460","messageId":"20120416204641.GH12613@burratino","threadId":"30254","inReplyTo":"CAMP44s0Q2A_oKJx27ct9W__KVQkQxzst3H7gq6sZDhrCLDQaag@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T20:46:41Z","receivedAt":"2012-04-16T20:46:41Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> Now, even if you use the bash completion library, it still does export\n> functions without a prefix\n\nAre you sure?  \"complete\" is a bash builtin and has nothing to do with\nthe bash completion library except that the latter uses it.\n"},{"id":"189461","messageId":"7v7gxftn78.fsf@alter.siamese.dyndns.org","threadId":"30254","inReplyTo":"20120416203320.GF12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-16T20:51:23Z","receivedAt":"2012-04-16T20:51:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Felipe Contreras wrote:\n>> On Mon, Apr 16, 2012 at 11:09 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>>> Felipe Contreras wrote:\n>\n>>>> I would like to see a completion script that actually has a function\n>>>> supposed to be exported and that still uses the _ prefix anyway.\n>>>\n>>> The /etc/bash_completion library itself exports lots and lots of\n>>> functions with a _ prefix.\n>>\n>> We are not making a bash_completion library; I mean a bash completion\n>> script (other than the library).\n>\n> Ok.  If you refuse to put two and two together, then I will (as usual\n> when this happens) just be a little passive aggressive and annoyed and\n> let you talk to other people.\n\nI have been assuming that bash_completion library is a sort of metaproject\nwhose sole purpose is to supply a framework for completion scripts for\nother packages like Git to be plugged easily and give niceties like lazy\nloading to avoid inflicting undue latencies to the end users.\n\nEarlier I said \"Ok\" to you based on that assumption; somebody may have his\nown git_complete that rebuilds a test integration branch (i.e. completes\nit) and having the name git_complete exported by us will indirectly affect\nher fingers if she installs bash_completion and Git package on her system.\n\nBut that assumption may not be correct, or even if it is correct, Felipe\nmay be missing that part, so it may not be \"refusing to add two and two\",\nbut could be \"learned two, but do not know the number of the other side of\naddition\".\n"},{"id":"189462","messageId":"CAMP44s23_Qx3R9TX4frM-JYNv7XT3eVbcZ_D45nEdh0rq-O8kA@mail.gmail.com","threadId":"30254","inReplyTo":"20120416204641.GH12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T20:51:33Z","receivedAt":"2012-04-16T20:51:33Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 11:46 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> Now, even if you use the bash completion library, it still does export\n>> functions without a prefix\n>\n> Are you sure?  \"complete\" is a bash builtin and has nothing to do with\n> the bash completion library except that the latter uses it.\n\nI already provided examples:\nhave(), quote(), dequote(), quote_readline()\n\n-- \nFelipe Contreras\n"},{"id":"189463","messageId":"20120416205952.GJ12613@burratino","threadId":"30254","inReplyTo":"CAMP44s23_Qx3R9TX4frM-JYNv7XT3eVbcZ_D45nEdh0rq-O8kA@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T20:59:52Z","receivedAt":"2012-04-16T20:59:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(cc-ing the bash-completion-devel list)\nFelipe Contreras wrote:\n> On Mon, Apr 16, 2012 at 11:46 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Felipe Contreras wrote:\n\n>>> Now, even if you use the bash completion library, it still does export\n>>> functions without a prefix\n>>\n>> Are you sure?  \"complete\" is a bash builtin and has nothing to do with\n>> the bash completion library except that the latter uses it.\n>\n> I already provided examples:\n> have(), quote(), dequote(), quote_readline()\n\nAh, that's what you mean.  Thanks for the pointers, and sorry to have\nmisunderstood.\n\nThere's a little oddity here.  \"have\" is clearly an unwanted backward\ncompatibility feature:\n\n\t# @deprecated should no longer be used; generally not needed with dynamically\n\t#             loaded completions, and _have is suitable for runtime use.\n\thave()\n\t[...]\n\tunset -f have\n\tunset have\n\nBut \"quote\", \"dequote\", and \"quote_readline\" do not get the same\ntreatment.  Perhaps they are for backward compatibility, too, but are\nso widely used that there is no hope of ever getting rid of them.\n\nHopefully this information helps clarify to what extent the leading\nunderscores in functions exposed by completion scripts are meant or\nare not meant as a convention.\n\nJonathan\n\n_______________________________________________\nBash-completion-devel mailing list\nBash-completion-devel@lists.alioth.debian.org\nhttp://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel"},{"id":"189464","messageId":"CAMP44s1TkE=rd8AxbBnR4a8FwY+H9MHxYOhcks9fsnuK1iL_oA@mail.gmail.com","threadId":"30254","inReplyTo":"7v7gxftn78.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T21:09:05Z","receivedAt":"2012-04-16T21:09:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Apr 16, 2012 at 11:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n> Earlier I said \"Ok\" to you based on that assumption; somebody may have his\n> own git_complete that rebuilds a test integration branch (i.e. completes\n> it) and having the name git_complete exported by us will indirectly affect\n> her fingers if she installs bash_completion and Git package on her system.\n\nShe might have had the same problem if she named it _git_complete.\nThat might be unlinkely, but I also find it unlikely that anybody\nwould have a git_complete function. In fact, I find it unlikely that\npeople would write shell functions like that; it's much easier to\nwrite scripts and put them in $PATH.\n\nEven more, I just added a foobar() function in my profile, and I also\nadded a foobar() function in /etc/bash_completion.d/git. I don't see\nmy function replaced in any way, even after typing and completing\n'git' commands. I don't know how that's possible, but that's why I\ndon't like to take these types of claims as face value.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189480","messageId":"20120416221531.GA2299@goldbirke","threadId":"30254","inReplyTo":"20120415213718.GB5813@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-16T22:15:31Z","receivedAt":"2012-04-16T22:15:31Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Sun, Apr 15, 2012 at 04:37:18PM -0500, Jonathan Nieder wrote:\n> Felipe Contreras wrote:\n> \n> > This simplifies the completions, and makes it easier to define aliases:\n> >\n> >  git_complete gf git_fetch\n> \n> Sounds neat.  Unfortunately users could already be using a function\n> with some other purpose named git_complete in their .profile and this\n> would override it.  The completion script has so far stuck to a\n> limited namespace:\n> \n> \t_git_*\t(completion functions)\n> \t__git_*\t(everything else, including public interfaces like __git_ps1)\n\nDon't forget the oddball __gitdir() function ;)\n\n> A name like __git_complete should work, presumably.\n\nAnd foo_wrap() should also fit into those namespaces.\n\n\nBest,\nGábor\n"},{"id":"189484","messageId":"CAMP44s2N9wFg5kx7jw2w6G6BQ1riX-W9cKt8kBPaofugm0OV1g@mail.gmail.com","threadId":"30254","inReplyTo":"20120416221531.GA2299@goldbirke","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T22:33:25Z","receivedAt":"2012-04-16T22:33:25Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/17 SZEDER Gábor <szeder@ira.uka.de>:\n> On Sun, Apr 15, 2012 at 04:37:18PM -0500, Jonathan Nieder wrote:\n>> Felipe Contreras wrote:\n\n>> A name like __git_complete should work, presumably.\n>\n> And foo_wrap() should also fit into those namespaces.\n\nYeah, I don't have a problem with that, just forgot about it.\n\nBut git_complete I think is different.\n\n-- \nFelipe Contreras\n"},{"id":"189487","messageId":"20120416224411.GU12613@burratino","threadId":"30254","inReplyTo":"CAMP44s1TkE=rd8AxbBnR4a8FwY+H9MHxYOhcks9fsnuK1iL_oA@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T22:44:11Z","receivedAt":"2012-04-16T22:44:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> Even more, I just added a foobar() function in my profile, and I also\n> added a foobar() function in /etc/bash_completion.d/git. I don't see\n> my function replaced in any way, even after typing and completing\n> 'git' commands. I don't know how that's possible, but that's why I\n> don't like to take these types of claims as face value.\n\nWhat version of the bash_completion library do you use?  Lazy-loading\nwas introduced in version 1.90.\n\nIf you put\n\n\tfoobar() {\n\t\techo hi\n\t}\n\t. /etc/bash_completion\n\nthen is your private foobar unclobbered?\n\nTo answer your demand before for a function in the public interface of\na completion script, not library, which respects or does not respect\nthe bash-completion convention: see the public _rpm_installed_packages\nhelper from the rpm completion script[1].\n\nIf you don't like the convention or think that I have misunderstood\nit, I can understand that and would recommend that you suggest a\ndifferent one and get it adopted and documented by the bash_completion\nproject.\n\nJonathan\n\n[1] http://lists.alioth.debian.org/pipermail/bash-completion-devel/2012-March/004359.html\n"},{"id":"189488","messageId":"CAMP44s0cdSaiCoMLk7oTHE4dies5-G0C7-RczK5OFEK=pYUW_A@mail.gmail.com","threadId":"30254","inReplyTo":"20120416224411.GU12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-16T23:04:00Z","receivedAt":"2012-04-16T23:04:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 1:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> Even more, I just added a foobar() function in my profile, and I also\n>> added a foobar() function in /etc/bash_completion.d/git. I don't see\n>> my function replaced in any way, even after typing and completing\n>> 'git' commands. I don't know how that's possible, but that's why I\n>> don't like to take these types of claims as face value.\n>\n> What version of the bash_completion library do you use?  Lazy-loading\n> was introduced in version 1.90.\n\n1.99\n\n> If you put\n>\n>        foobar() {\n>                echo hi\n>        }\n>        . /etc/bash_completion\n>\n> then is your private foobar unclobbered?\n\nYes, in that case it does, but that's not the default behavior, at\nleast not in my system, and I doubt anybody would define their\nfunctions before loading library scripts.\n\n> To answer your demand before for a function in the public interface of\n> a completion script, not library, which respects or does not respect\n> the bash-completion convention: see the public _rpm_installed_packages\n> helper from the rpm completion script[1].\n\nWhat makes you think this is public? It's under the section '# helper\nfunctions', which doesn't seem to be public. Plus, it's repeated in\nrpm, rpmbuild, and rpmbuild-md5.\n\nThe fact that somebody uses it doesn't mean it's public.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189490","messageId":"20120416230550.GV12613@burratino","threadId":"30254","inReplyTo":"CAMP44s0cdSaiCoMLk7oTHE4dies5-G0C7-RczK5OFEK=pYUW_A@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T23:05:50Z","receivedAt":"2012-04-16T23:05:50Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n> On Tue, Apr 17, 2012 at 1:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> What version of the bash_completion library do you use?  Lazy-loading\n>> was introduced in version 1.90.\n>\n> 1.99\n\nIs your git completion script installed at /etc/bash_completion.d/git,\n/usr/share/bash-completion/completions/git, or somewhere else?\n"},{"id":"189491","messageId":"20120416231626.GW12613@burratino","threadId":"30254","inReplyTo":"CAMP44s0cdSaiCoMLk7oTHE4dies5-G0C7-RczK5OFEK=pYUW_A@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T23:16:26Z","receivedAt":"2012-04-16T23:16:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> What makes you think this is public? It's under the section '# helper\n> functions', which doesn't seem to be public. Plus, it's repeated in\n> rpm, rpmbuild, and rpmbuild-md5.\n\nOk, you win.  I hadn't realized we were having a debate, but now I do,\nand you have won.\n\nCan we get back to making the completion script nicer for human\nbeings that have been using it, please?\n\nThe following summary may sound annoyed, because I am.  On the other\nhand I know you mean well and am grateful for your work.\n\nI have said that the convention for bash completion scripts is to\nprecede all exposed identifier names with an underscore.  You\nmentioned some old counterexamples that have been grandfathered in.\nYou mentioned that you do not trust me.  Your bash completion script\ngets loaded immediately instead of being lazy-loaded, probably because\nit is not in /usr/share/bash-completion/completions/.  You claimed\nthat nobody would _ever_ ask for bash completion support at the end of\ntheir .profile and after their custom functions in .profile that do\nsomething unrelated, though I used to do that for a long time and\nDebian's default .bashrc loads /etc/bash_completion at the end, too.\n\nI still maintain that namespaces are useful and we should follow the\nconventional ones when they exist.  What is the next step?\n\nJonathan\n"},{"id":"189502","messageId":"CAMP44s3OSepH_XpCcTWLN=bF0+P9fmHtyPnWdQnEocW25jHTpA@mail.gmail.com","threadId":"30254","inReplyTo":"20120416231626.GW12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T07:10:12Z","receivedAt":"2012-04-17T07:10:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 2:16 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> What makes you think this is public? It's under the section '# helper\n>> functions', which doesn't seem to be public. Plus, it's repeated in\n>> rpm, rpmbuild, and rpmbuild-md5.\n>\n> Ok, you win.  I hadn't realized we were having a debate, but now I do,\n> and you have won.\n\nI thought we were trying to agree on a good name for possibly the\nfirst (or second, depending how you count) public function. It's\nimportant to choose a good name because we can't just change it again\nin a month.\n\nYou are the one who brought the argument that even public functions\nhave the '_' prefix, so it's *your* responsibility to substantiate\nthat argument. I don't think it would be easy to find a precedent like\nthis, but you can prove me wrong by providing the evidence; so far, I\ndon't think that has happened.\n\n> Can we get back to making the completion script nicer for human\n> beings that have been using it, please?\n\nSure, but we need some sort of git_completion function if we want to\nmake it easy for people to define aliases for git commands. And this\nis a known issue that has been brought in the past.\n\n> The following summary may sound annoyed, because I am.  On the other\n> hand I know you mean well and am grateful for your work.\n>\n> I have said that the convention for bash completion scripts is to\n> precede all exposed identifier names with an underscore.  You\n> mentioned some old counterexamples that have been grandfathered in.\n> You mentioned that you do not trust me.  Your bash completion script\n> gets loaded immediately instead of being lazy-loaded, probably because\n> it is not in /usr/share/bash-completion/completions/.  You claimed\n> that nobody would _ever_ ask for bash completion support at the end of\n> their .profile and after their custom functions in .profile that do\n> something unrelated,\n\nI did not claim such thing. I said that I *doubted* it, not that it\nwas most definitely the case.\n\n> though I used to do that for a long time and\n> Debian's default .bashrc loads /etc/bash_completion at the end, too.\n\nI see. That would be troublesome indeed (if somebody chose to add the\nfunction before that line, and not at the end), *if* somehow they used\ngit_completion in their scripts.\n\n> I still maintain that namespaces are useful and we should follow the\n> conventional ones when they exist.  What is the next step?\n\nWhat about this?\n\nif ! type git_complete >/dev/null 2>&1; then\ngit_complete ()\n{\n\techo \"WARNING: This function is not meant for public use; the name\" \\\n\t\t\"might change. Use __git_complete for now.\"\n\t__git_complete \"$@\"\n}\nelse\ntype git_complete | grep -q \"WARNING\" ||\necho \"git_complete is already being used, please notify\ngit@vger.kernel.org, to\" \\\n\t\"avoid overriding this function in the future.\"\nfi\n\nWe can use that for 1.7.11, and if nobody complains remove the\nwarnings for 1.7.12.\n\n-- \nFelipe Contreras\n"},{"id":"189504","messageId":"20120417073653.GB20017@burratino","threadId":"30254","inReplyTo":"CAMP44s3OSepH_XpCcTWLN=bF0+P9fmHtyPnWdQnEocW25jHTpA@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-17T07:36:53Z","receivedAt":"2012-04-17T07:36:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> You are the one who brought the argument that even public functions\n> have the '_' prefix, so it's *your* responsibility to substantiate\n> that argument.\n\nNo, honestly it isn't my responsibility to waste time arguing with\nyou.  What kind of crazy world would work that way?\n\nAnd I did not mean to bring up any argument.  I only meant to bring up\nthe _datum_ that, at least in the context of the bash_completion\nproject, that is the current convention.  And then you started trying\nto tell me that I had the facts wrong!  You might even be right, but\nyou haven't shown any sign of trying to check that, by, say, asking\nsomeone from the bash_completion project what convention they use.\n\nI'm sick of this.  Call it whatever you want.  I don't know why you\nthink this is productive.\n\nStill annoyed,\nJonathan\n"},{"id":"189507","messageId":"CAMP44s3mnnhKXHUEMSX+d2L2Jyqr9_Q7F=3DvWb4MKxHpTRREg@mail.gmail.com","threadId":"30254","inReplyTo":"20120417073653.GB20017@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T07:56:44Z","receivedAt":"2012-04-17T07:56:44Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 10:36 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> You are the one who brought the argument that even public functions\n>> have the '_' prefix, so it's *your* responsibility to substantiate\n>> that argument.\n>\n> No, honestly it isn't my responsibility to waste time arguing with\n> you.  What kind of crazy world would work that way?\n>\n> And I did not mean to bring up any argument.  I only meant to bring up\n> the _datum_ that, at least in the context of the bash_completion\n> project, that is the current convention.  And then you started trying\n> to tell me that I had the facts wrong!  You might even be right, but\n> you haven't shown any sign of trying to check that, by, say, asking\n> someone from the bash_completion project what convention they use.\n\nI don't understand. I'm proposing the name 'git_complete', I thought\nyou were arguing against it. If you were only providing random facts,\nthen we can just ignore them, and it would be OK, right? But I'm\npretty sure you would be angry as well if I just ignored that fact.\n\nSure, it would be nice to follow bash_completion project's convention\nfor these kinds of functions, if they had any, and might be useful to\nask them what they think. But we don't *have* to. And nobody is\narguing that we should ask them. Right? Or are you?\n\n> I'm sick of this.  Call it whatever you want.  I don't know why you\n> think this is productive.\n\nWe don't have to agree on any name right now. I believe it's worth\nwaiting before deciding on a name for a public function like this, and\ntry to get some consensus.\n\nBut throwing arguments on the air, and they get angry when they get\ncounter-argued is not helpful. If we are going to discuss, lets\ndiscuss, but that doesn't seem to be what you want. You want me to\nblindly use the name you propose without saying a word? Blindly accept\nyour argument... follow orders?\n\nI took your argument seriously and looked for evidence myself, and in\nthe absence of evidence I'm still not throwing it away, I'm assuming\nit has merit and added code to make sure we don't override some user\nfunction that has the same name. That would solve the problem you\nraised, and it would help us find out if this is indeed a real issue,\nor a theoretical one, and at the same time making sure people don't\nrely too much on this function for the moment.\n\nI believe this is very scientific-like; you make a hypothesis, we make\nan experiment, and then we can find out the results, and only then\nmake a decision.\n\nI don't know what else I can do to move this forward.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189509","messageId":"20120417080622.GF20017@burratino","threadId":"30254","inReplyTo":"CAMP44s3mnnhKXHUEMSX+d2L2Jyqr9_Q7F=3DvWb4MKxHpTRREg@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-17T08:06:22Z","receivedAt":"2012-04-17T08:06:22Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> Sure, it would be nice to follow bash_completion project's convention\n> for these kinds of functions, if they had any, and might be useful to\n> ask them what they think. But we don't *have* to. And nobody is\n> arguing that we should ask them. Right? Or are you?\n\nNo, I really am not arguing that we should ask them.  Because we (or\nat least I) already know at least what their convention was a few\nyears ago.  However, I do encourage anyone curious to ask them instead\nof making up arguments about why the answer is obvious.\n\n[...]\n> But throwing arguments on the air, and they get angry when they get\n> counter-argued is not helpful. If we are going to discuss, lets\n> discuss, but that doesn't seem to be what you want. You want me to\n> blindly use the name you propose without saying a word?\n\nI do not think it is fair to call your position blind.  I really would\nbe happier if you were able to listen, and, instead of throwing out\nprotests and debating points, to talk about your real concerns.\n\nI am guessing (but you never said!) that you find the name\n__git_complete ugly.  That's fine.  I even agree.  I have mentioned\nthat there is a namespace that your proposed alternative violates.\nYour response is... to refuse to believe that what I said is true or\nrelevant?\n\nHow am I supposed to have a reasonable discussion after that?\n\nThis is not a debating floor.  When I give what I think is relevant\ninformation, I am not requesting \"please misinterpret me and shoot me\ndown\".\n\nCiao,\nJonathan\n"},{"id":"189511","messageId":"20120417082256.GA20240@burratino","threadId":"30254","inReplyTo":"CAMP44s3mnnhKXHUEMSX+d2L2Jyqr9_Q7F=3DvWb4MKxHpTRREg@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-17T08:22:56Z","receivedAt":"2012-04-17T08:22:56Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> I took your argument seriously and looked for evidence myself, and in\n> the absence of evidence I'm still not throwing it away, I'm assuming\n> it has merit and added code to make sure we don't override some user\n> function that has the same name. That would solve the problem you\n> raised\n\nAh.  All that talking, but I was not addressing your actual point.\n\nI though you didn't believe that the namespace adopted by the\nbash_completion project was \"identifiers starting with underscore,\nplus a few old identifiers that have been grandfathered in\".\n\nBut in fact, you just don't like namespace conventions.\n\nNow I'm exhausted so I have no time to explain why a project that\ninvolves implicitly including scripts from a wide variety of authors\ninto a flat namespace shared with others might end up using a\nconvention to manage that namespace.  But at least the world seems a\nlittle saner.  Sorry for the wasted time.\n\nPlease, next time just say what you mean instead of leaving me talking\nabout something irrelevant.\n"},{"id":"189530","messageId":"7vty0inys6.fsf@alter.siamese.dyndns.org","threadId":"30254","inReplyTo":"CAMP44s2N9wFg5kx7jw2w6G6BQ1riX-W9cKt8kBPaofugm0OV1g@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-17T15:50:01Z","receivedAt":"2012-04-17T15:50:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> 2012/4/17 SZEDER Gábor <szeder@ira.uka.de>:\n>> On Sun, Apr 15, 2012 at 04:37:18PM -0500, Jonathan Nieder wrote:\n>>> Felipe Contreras wrote:\n>\n>>> A name like __git_complete should work, presumably.\n>>\n>> And foo_wrap() should also fit into those namespaces.\n>\n> Yeah, I don't have a problem with that, just forgot about it.\n>\n> But git_complete I think is different.\n\nIs git_complete something the user types interactively, or is it meant to\nbe used in their .bashrc to help them complete arguments to their custom\nscripts that take arguments similar to Git Porcelains?\n"},{"id":"189532","messageId":"CAMP44s1sj27U_s3Y3nLL6pkMrPMVvTo982c85x-hH5szvprK0g@mail.gmail.com","threadId":"30254","inReplyTo":"7vty0inys6.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T16:13:14Z","receivedAt":"2012-04-17T16:13:14Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 6:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> 2012/4/17 SZEDER Gábor <szeder@ira.uka.de>:\n>>> On Sun, Apr 15, 2012 at 04:37:18PM -0500, Jonathan Nieder wrote:\n>>>> Felipe Contreras wrote:\n>>\n>>>> A name like __git_complete should work, presumably.\n>>>\n>>> And foo_wrap() should also fit into those namespaces.\n>>\n>> Yeah, I don't have a problem with that, just forgot about it.\n>>\n>> But git_complete I think is different.\n>\n> Is git_complete something the user types interactively, or is it meant to\n> be used in their .bashrc to help them complete arguments to their custom\n> scripts that take arguments similar to Git Porcelains?\n\nIt's meant for their .bashrc, but can be used interactively, exactly\nlike 'complete'. You can type 'complete -o bashdefault -o default -o\nnospace -F _git git' in the command like, but that would rarely\nhappen.\n\n-- \nFelipe Contreras\n"},{"id":"189538","messageId":"20120417175017.GC10081@goldbirke","threadId":"30254","inReplyTo":"7vty0inys6.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T17:50:17Z","receivedAt":"2012-04-17T17:50:17Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Apr 17, 2012 at 08:50:01AM -0700, Junio C Hamano wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n> \n> > 2012/4/17 SZEDER Gábor <szeder@ira.uka.de>:\n> >> On Sun, Apr 15, 2012 at 04:37:18PM -0500, Jonathan Nieder wrote:\n> >>> Felipe Contreras wrote:\n> >\n> >>> A name like __git_complete should work, presumably.\n> >>\n> >> And foo_wrap() should also fit into those namespaces.\n> >\n> > Yeah, I don't have a problem with that, just forgot about it.\n> >\n> > But git_complete I think is different.\n> \n> Is git_complete something the user types interactively, or is it meant to\n> be used in their .bashrc to help them complete arguments to their custom\n> scripts that take arguments similar to Git Porcelains?\n\nPrimarily for .bashrc, however, not for their custom scripts but to be\nable to use completion for their one-word git aliases, e.g. after an\n\n  alias gf='git fetch'\n\nthey want to do\n\n  gf o<TAB>\n\nand get 'origin' completed.\n\nHere's a relevant thread:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/185184/\n\n\nBest,\nGábor\n"},{"id":"189544","messageId":"7v4nsins1j.fsf@alter.siamese.dyndns.org","threadId":"30254","inReplyTo":"CAMP44s1sj27U_s3Y3nLL6pkMrPMVvTo982c85x-hH5szvprK0g@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-17T18:15:36Z","receivedAt":"2012-04-17T18:15:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Tue, Apr 17, 2012 at 6:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n> ...\n>>>> And foo_wrap() should also fit into those namespaces.\n>>>\n>>> Yeah, I don't have a problem with that, just forgot about it.\n>>>\n>>> But git_complete I think is different.\n>>\n>> Is git_complete something the user types interactively, or is it meant to\n>> be used in their .bashrc to help them complete arguments to their custom\n>> scripts that take arguments similar to Git Porcelains?\n>\n> It's meant for their .bashrc, but can be used interactively, exactly\n> like 'complete'. You can type 'complete -o bashdefault -o default -o\n> nospace -F _git git' in the command like, but that would rarely\n> happen.\n\nOK, then I do not think \"as a public interface it looks somewhat ugly\"\n(which I happen to think, and I am guessing that you agree with) matters.\nIt looks to me that it would be sane to follow the convention to avoid\naccidental name clashes with userspace names by naming it \"__git_complete\"\nin that case.\n"},{"id":"189570","messageId":"CAMP44s0w40ViecQsF8AeQLLxAEShC54TTyvcPVMabpOZ+DYDqQ@mail.gmail.com","threadId":"30254","inReplyTo":"7v4nsins1j.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T20:53:08Z","receivedAt":"2012-04-17T20:53:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 9:15 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Tue, Apr 17, 2012 at 6:50 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>> ...\n>>>>> And foo_wrap() should also fit into those namespaces.\n>>>>\n>>>> Yeah, I don't have a problem with that, just forgot about it.\n>>>>\n>>>> But git_complete I think is different.\n>>>\n>>> Is git_complete something the user types interactively, or is it meant to\n>>> be used in their .bashrc to help them complete arguments to their custom\n>>> scripts that take arguments similar to Git Porcelains?\n>>\n>> It's meant for their .bashrc, but can be used interactively, exactly\n>> like 'complete'. You can type 'complete -o bashdefault -o default -o\n>> nospace -F _git git' in the command like, but that would rarely\n>> happen.\n>\n> OK, then I do not think \"as a public interface it looks somewhat ugly\"\n> (which I happen to think, and I am guessing that you agree with) matters.\n> It looks to me that it would be sane to follow the convention\n\nBut that convention is for *private* functions.\n\n> to avoid\n> accidental name clashes with userspace names by naming it \"__git_complete\"\n> in that case.\n\nWhat if there are no clashes?\n\nAre you saying that even if there are no real clashes, only\nhypothetical ones, you would still prefer __git_complete?\n\nHow are people going to distinguish between public and private functions?\n\n-- \nFelipe Contreras\n"},{"id":"189571","messageId":"20120417210847.GA23492@burratino","threadId":"30254","inReplyTo":"CAMP44s0w40ViecQsF8AeQLLxAEShC54TTyvcPVMabpOZ+DYDqQ@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-17T21:08:47Z","receivedAt":"2012-04-17T21:08:47Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> How are people going to distinguish between public and private functions?\n\nThere are only two public functions.\n\nThey will be the ones provided without an __ (git_ps1 and\ngit_complete) when you source the git-prompt-and-completion-helpers\nlibrary in your .bashrc.  Neither will be exposed automatically from\nthe completion script, though synonyms with leading __ to avoid\nnamespace clashes will be.\n\nSensible?\nJonathan\n"},{"id":"189580","messageId":"20120417221444.GD10081@goldbirke","threadId":"30254","inReplyTo":"CAMP44s0w40ViecQsF8AeQLLxAEShC54TTyvcPVMabpOZ+DYDqQ@mail.gmail.com","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T22:14:44Z","receivedAt":"2012-04-17T22:14:44Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Apr 17, 2012 at 11:53:08PM +0300, Felipe Contreras wrote:\n> Are you saying that even if there are no real clashes, only\n> hypothetical ones, you would still prefer __git_complete?\n\nCan you ascertain that there are no real clashes?\n\n> How are people going to distinguish between public and private functions?\n\nBy reading the documentation, perhaps?  It was not a problem for\n__git_ps1(), so I guess it won't be a problem for __git_complete()\neither.  Assuming that it will be documented eventually, of course.\n\n\nBest,\nGábor\n"},{"id":"189583","messageId":"CAMP44s20UL4G7=Q=mhGf4coZm0CmZnLSDsKHfco8r2V8MiCYZw@mail.gmail.com","threadId":"30254","inReplyTo":"20120417221444.GD10081@goldbirke","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T22:19:12Z","receivedAt":"2012-04-17T22:19:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/18 SZEDER Gábor <szeder@ira.uka.de>:\n> On Tue, Apr 17, 2012 at 11:53:08PM +0300, Felipe Contreras wrote:\n>> Are you saying that even if there are no real clashes, only\n>> hypothetical ones, you would still prefer __git_complete?\n>\n> Can you ascertain that there are no real clashes?\n\nAfter having this code for a certain amount of time, yeah:\n\nif ! type git_complete >/dev/null 2>&1; then\ngit_complete ()\n{\n       echo \"WARNING: This function is not meant for public use; the name\" \\\n               \"might change. Use __git_complete for now.\"\n       __git_complete \"$@\"\n}\nelse\ntype git_complete | grep -q \"WARNING\" ||\necho \"git_complete is already being used, please notify\ngit@vger.kernel.org, to\" \\\n       \"avoid overriding this function in the future.\"\nfi\n\n>> How are people going to distinguish between public and private functions?\n>\n> By reading the documentation, perhaps?  It was not a problem for\n> __git_ps1(), so I guess it won't be a problem for __git_complete()\n> either.  Assuming that it will be documented eventually, of course.\n\nI guess that would do it. I would still prefer to have a different\nconvention for public functions. I feel we are being paranoid here.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189801","messageId":"4F925FBC.2030406@iki.fi","threadId":"30254","inReplyTo":"20120416205952.GJ12613@burratino","subject":"Re: [PATCH v2] completion: add new git_complete helper","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2012-04-21T07:20:28Z","receivedAt":"2012-04-21T07:20:28Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"On 2012-04-16 23:59, Jonathan Nieder wrote:\n\n> Hopefully this information helps clarify to what extent the leading\n> underscores in functions exposed by completion scripts are meant or\n> are not meant as a convention.\n\nWe've discussed what a real \"API\" or \"namespace\" of bash-completion\nwould look like, but so far nothing concrete has come out of it.\n\nhttp://thread.gmane.org/gmane.comp.shells.bash.completion.scm/2013/focus=3135\n"},{"id":"189807","messageId":"CAMP44s1dNqokGuLg3ReLAreNBM++0NxOMUUk-=AgFBUy3n=E9w@mail.gmail.com","threadId":"30254","inReplyTo":"4F925FBC.2030406@iki.fi","subject":"Re: [Bash-completion-devel] [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-21T15:41:32Z","receivedAt":"2012-04-21T15:41:32Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sat, Apr 21, 2012 at 10:20 AM, Ville Skyttä <ville.skytta@iki.fi> wrote:\n> On 2012-04-16 23:59, Jonathan Nieder wrote:\n>\n>> Hopefully this information helps clarify to what extent the leading\n>> underscores in functions exposed by completion scripts are meant or\n>> are not meant as a convention.\n>\n> We've discussed what a real \"API\" or \"namespace\" of bash-completion\n> would look like, but so far nothing concrete has come out of it.\n>\n> http://thread.gmane.org/gmane.comp.shells.bash.completion.scm/2013/focus=3135\n\nThank you for pointing this out. This means I was correct; there\nwas/is no convention for public APIs.\n\nAccording to that thread, the closest there is to a convention would\nbe to name it _GIT_complete. That would certainly avoid conflicts with\nany current namespace, so I feel it's much better than __git_complete.\n\nStill, I don't see the point in avoiding 'git_complete' and making our\nlifes more difficult. Bash public functions, like *complete*, don't\nhave any special namespace, they just snatch them, and that's the end\nof it. In the particular case of git, where would have only a couple\n(currently 2) public functions, I don't see what's the big deal.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189809","messageId":"4F92F0D2.1090609@iki.fi","threadId":"30254","inReplyTo":"CAMP44s1dNqokGuLg3ReLAreNBM++0NxOMUUk-=AgFBUy3n=E9w@mail.gmail.com","subject":"Re: [Bash-completion-devel] [PATCH v2] completion: add new git_complete helper","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2012-04-21T17:39:30Z","receivedAt":"2012-04-21T17:39:30Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"On 2012-04-21 18:41, Felipe Contreras wrote:\n\n> Still, I don't see the point in avoiding 'git_complete' and making our\n> lifes more difficult.\n\nI'm not aware of ways it'd make people's lifes more difficult, but if\ngit_complete is a function intended for completion purposes, I'd\npersonally not name it git* because it'd interfere for example with\ncompleting git<TAB> by being included in the suggested completions even\nthough it's never meant to be used that way.  Prefixing for example with\nunderscore doesn't avoid the problem completely, but makes it less\nlikely to happen.\n"},{"id":"189833","messageId":"CAMP44s10iy64dLXJtScijeQne0ufnwrmSyvdRT0Szyf9b2kCGA@mail.gmail.com","threadId":"30254","inReplyTo":"4F92F0D2.1090609@iki.fi","subject":"Re: [Bash-completion-devel] [PATCH v2] completion: add new git_complete helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-22T12:58:48Z","receivedAt":"2012-04-22T12:58:48Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/21 Ville Skyttä <ville.skytta@iki.fi>:\n> On 2012-04-21 18:41, Felipe Contreras wrote:\n>\n>> Still, I don't see the point in avoiding 'git_complete' and making our\n>> lifes more difficult.\n>\n> I'm not aware of ways it'd make people's lifes more difficult, but if\n> git_complete is a function intended for completion purposes, I'd\n> personally not name it git* because it'd interfere for example with\n> completing git<TAB> by being included in the suggested completions even\n> though it's never meant to be used that way.  Prefixing for example with\n> underscore doesn't avoid the problem completely, but makes it less\n> likely to happen.\n\nThat's actually a good point, I forgot that functions are also completed.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}