{"thread":{"id":"27063","subject":"[PATCH v2] git-completion: Add support for git submodule options","startedAt":"2011-04-11T17:47:52Z","lastAt":"2011-04-12T09:37:38Z","messageCount":3,"participants":["Nicolas Morey-Chaisemartin","Jens Lehmann","SZEDER Gábor"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"165631","messageId":"4DA33EC8.5040704@morey-chaisemartin.com","threadId":"27063","inReplyTo":null,"subject":"[PATCH v2] git-completion: Add support for git submodule options","fromName":"Nicolas Morey-Chaisemartin","fromEmail":"devel-git@morey-chaisemartin.com","sentAt":"2011-04-11T17:47:52Z","receivedAt":"2011-04-11T17:47:52Z","isPatch":true,"sender":{"key":"devel-git@morey-chaisemartin.com","avatar":"https://avatars.githubusercontent.com/u/108326?v=4"},"body":"Completion for git submodule only handled subcommands.\nAdd support for options of each subcommand\n\nSigned-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>\n---\nChanges:\n - Inlined local variables listing options.\n\n contrib/completion/git-completion.bash |   32 +++++++++++++++++++++++++++++++-\n 1 files changed, 31 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 840ae38..20d0cf0 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2546,7 +2546,8 @@ _git_submodule ()\n \t__git_has_doubledash && return\n \n \tlocal subcommands=\"add status init update summary foreach sync\"\n-\tif [ -z \"$(__git_find_on_cmdline \"$subcommands\")\" ]; then\n+\tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n+\tif [ -z \"$subcommand\" ]; then\n \t\tlocal cur\n \t\t_get_comp_words_by_ref -n =: cur\n \t\tcase \"$cur\" in\n@@ -2558,6 +2559,35 @@ _git_submodule ()\n \t\t\t;;\n \t\tesac\n \t\treturn\n+\telse\n+\t    local cur\n+\t    _get_comp_words_by_ref -n =: cur\n+\t    case \"$subcommand,$cur\" in\n+\t\t add,--*)\n+\t\t     __gitcomp \"--branch= --force --reference=\"\n+\t\t     ;;\n+\t\t status,--*)\n+\t\t     __gitcomp \"--cached --recursive\"\n+\t\t     ;;\n+\t\t update,--*)\n+\t\t     __gitcomp \"--init --no-fetch --rebase --reference= --merge --recursive\"\n+\t\t     ;;\n+\t\t summary,--*)\n+\t\t     __gitcomp \"--cached --files --summary-limit=\"\n+\t\t     ;;\n+\t\t summary,*)\n+\t\t     __gitcomp \"$(__git_refs)\"\n+\t\t     ;;\n+\t\t foreach,--*)\n+\t\t     __gitcomp \"--recursive\"\n+\t\t     ;;\n+\t\t sync,*)\n+\t\t     COMPREPLY=()\n+\t\t     ;;\n+\t\t *)\n+\t\t     COMPREPLY=()\n+\t\t     ;;\n+\t    esac \n \tfi\n }\n \n"},{"id":"165634","messageId":"4DA3419A.4080809@web.de","threadId":"27063","inReplyTo":"4DA33EC8.5040704@morey-chaisemartin.com","subject":"Re: [PATCH v2] git-completion: Add support for git submodule options","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2011-04-11T17:59:54Z","receivedAt":"2011-04-11T17:59:54Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 11.04.2011 19:47, schrieb Nicolas Morey-Chaisemartin:\n> Completion for git submodule only handled subcommands.\n> Add support for options of each subcommand\n> \n> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>\n\nI don't know much about the internals of completion, but I like where\nthis is heading.\n"},{"id":"165681","messageId":"20110412093738.GA6817@goldbirke","threadId":"27063","inReplyTo":"4DA33EC8.5040704@morey-chaisemartin.com","subject":"Re: [PATCH v2] git-completion: Add support for git submodule options","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-04-12T09:37:38Z","receivedAt":"2011-04-12T09:37:38Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Mon, Apr 11, 2011 at 07:47:52PM +0200, Nicolas Morey-Chaisemartin wrote:\n> Completion for git submodule only handled subcommands.\n> Add support for options of each subcommand\n> \n> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>\n> ---\n> Changes:\n>  - Inlined local variables listing options.\n>\n>  contrib/completion/git-completion.bash |   32 +++++++++++++++++++++++++++++++-\n>  1 files changed, 31 insertions(+), 1 deletions(-)\n\nThis change looks good overall, but I have a few nits, though.\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 840ae38..20d0cf0 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2546,7 +2546,8 @@ _git_submodule ()\n>  \t__git_has_doubledash && return\n>  \n>  \tlocal subcommands=\"add status init update summary foreach sync\"\n> -\tif [ -z \"$(__git_find_on_cmdline \"$subcommands\")\" ]; then\n> +\tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n> +\tif [ -z \"$subcommand\" ]; then\n>  \t\tlocal cur\n>  \t\t_get_comp_words_by_ref -n =: cur\n>  \t\tcase \"$cur\" in\n> @@ -2558,6 +2559,35 @@ _git_submodule ()\n>  \t\t\t;;\n>  \t\tesac\n>  \t\treturn\n> +\telse\n> +\t    local cur\n> +\t    _get_comp_words_by_ref -n =: cur\n\nBoth branches of the if-else statement start with the same\n\n\t    local cur\n\t    _get_comp_words_by_ref -n =: cur\n\nso these could be moved out in front of the if statement.\n\n> +\t    case \"$subcommand,$cur\" in\n> +\t\t add,--*)\n> +\t\t     __gitcomp \"--branch= --force --reference=\"\n> +\t\t     ;;\n> +\t\t status,--*)\n> +\t\t     __gitcomp \"--cached --recursive\"\n> +\t\t     ;;\n> +\t\t update,--*)\n> +\t\t     __gitcomp \"--init --no-fetch --rebase --reference= --merge --recursive\"\n> +\t\t     ;;\n> +\t\t summary,--*)\n> +\t\t     __gitcomp \"--cached --files --summary-limit=\"\n> +\t\t     ;;\n> +\t\t summary,*)\n> +\t\t     __gitcomp \"$(__git_refs)\"\n> +\t\t     ;;\n> +\t\t foreach,--*)\n> +\t\t     __gitcomp \"--recursive\"\n> +\t\t     ;;\n> +\t\t sync,*)\n> +\t\t     COMPREPLY=()\n> +\t\t     ;;\n> +\t\t *)\n> +\t\t     COMPREPLY=()\n> +\t\t     ;;\n\nThe 'sync,*' case is not necessary, because it has the same completion\nreply as the '*' case, and that case would match it anyway.\n\nAnd finally, please use tabs for indentation.\n\n\nBest,\nGábor\n"}]}