{"thread":{"id":"25414","subject":"[PATCH] bash: support more 'git notes' subcommands and their options","startedAt":"2010-10-10T21:43:33Z","lastAt":"2010-10-10T21:43:33Z","messageCount":1,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"153187","messageId":"1286747013-8325-1-git-send-email-szeder@ira.uka.de","threadId":"25414","inReplyTo":null,"subject":"[PATCH] bash: support more 'git notes' subcommands and their options","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-10-10T21:43:33Z","receivedAt":"2010-10-10T21:43:33Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The current completion function for 'git notes' only supported the\n'edit' and 'show' subcommands and none of their options.  This patch\nadds support for all missing subcommands, options, and their arguments\n(files or refs), if any.\n\nThe code responsible for completing subcommand looks different\ncompared to the completion functions of other git commands with\nsubcommands.  This is because of the '--ref <notes-ref>' option which\ncomes before the subcommand (i.e. git notes --ref <notes-ref> add).\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |   50 ++++++++++++++++++++++++++------\n 1 files changed, 41 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6756990..d57316c 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1468,18 +1468,50 @@ _git_name_rev ()\n \n _git_notes ()\n {\n-\tlocal subcommands=\"edit show\"\n-\tif [ -z \"$(__git_find_on_cmdline \"$subcommands\")\" ]; then\n-\t\t__gitcomp \"$subcommands\"\n-\t\treturn\n-\tfi\n+\tlocal subcommands='add append copy edit list prune remove show'\n+\tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n-\t-m|-F)\n-\t\tCOMPREPLY=()\n+\tcase \"$subcommand,$cur\" in\n+\t,--*)\n+\t\t__gitcomp '--ref'\n+\t\t;;\n+\t,*)\n+\t\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n+\t\t--ref)\n+\t\t\t__gitcomp \"$(__git_refs)\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\t__gitcomp \"$subcommands --ref\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n+\tadd,--reuse-message=*|append,--reuse-message=*)\n+\t\t__gitcomp \"$(__git_refs)\" \"\" \"${cur##--reuse-message=}\"\n+\t\t;;\n+\tadd,--reedit-message=*|append,--reedit-message=*)\n+\t\t__gitcomp \"$(__git_refs)\" \"\" \"${cur##--reedit-message=}\"\n+\t\t;;\n+\tadd,--*|append,--*)\n+\t\t__gitcomp '--file= --message= --reedit-message=\n+\t\t\t\t--reuse-message='\n+\t\t;;\n+\tcopy,--*)\n+\t\t__gitcomp '--stdin'\n+\t\t;;\n+\tprune,--*)\n+\t\t__gitcomp '--dry-run --verbose'\n+\t\t;;\n+\tprune,*)\n \t\t;;\n \t*)\n-\t\t__gitcomp \"$(__git_refs)\"\n+\t\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n+\t\t-m|-F)\n+\t\t\t;;\n+\t\t*)\n+\t\t\t__gitcomp \"$(__git_refs)\"\n+\t\t\t;;\n+\t\tesac\n \t\t;;\n \tesac\n }\n-- \n1.7.3.1.148.g2fffa\n"}]}