{"thread":{"id":"25796","subject":"[PATCH] bash completion: add basic support for git-reflog","startedAt":"2010-11-20T17:32:48Z","lastAt":"2010-11-22T17:20:57Z","messageCount":5,"participants":["Tay Ray Chuan","SZEDER Gábor","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"156254","messageId":"1290274368-3212-1-git-send-email-rctay89@gmail.com","threadId":"25796","inReplyTo":null,"subject":"[PATCH] bash completion: add basic support for git-reflog","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-11-20T17:32:48Z","receivedAt":"2010-11-20T17:32:48Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Add basic completion for the three subcommands - show, expire, delete.\nTry completing refs for these too.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n contrib/completion/git-completion.bash |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f710469..4007ca1 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1632,6 +1632,22 @@ _git_rebase ()\n \t__gitcomp \"$(__git_refs)\"\n }\n \n+_git_reflog ()\n+{\n+\tlocal SUB_CMDS=(show delete expire)\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD-1]}\"\n+\n+\tfor val in ${SUB_CMDS[*]}; do\n+\t\tif [[ \"$val\" == \"$cur\" ]]; then\n+\t\t\t# this is a subcommand\n+\t\t\t__gitcomp \"$(__git_refs)\"\n+\t\t\treturn\n+\t\tfi\n+\tdone\n+\n+\t__gitcomp \"${SUB_CMDS[*]}\"\n+}\n+\n __git_send_email_confirm_options=\"always never auto cc compose\"\n __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n \n-- \n1.7.3.2.496.g9c54\n"},{"id":"156321","messageId":"20101122152409.GA7010@neumann","threadId":"25796","inReplyTo":"1290274368-3212-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] bash completion: add basic support for git-reflog","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-11-22T15:24:09Z","receivedAt":"2010-11-22T15:24:09Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Sun, Nov 21, 2010 at 01:32:48AM +0800, Tay Ray Chuan wrote:\n> Add basic completion for the three subcommands - show, expire, delete.\n> Try completing refs for these too.\n\nHeh, I've always thought reflog is plumbing, and that's why the\ncompletion script doesn't support it.\n\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash |   16 ++++++++++++++++\n>  1 files changed, 16 insertions(+), 0 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index f710469..4007ca1 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1632,6 +1632,22 @@ _git_rebase ()\n>  \t__gitcomp \"$(__git_refs)\"\n>  }\n>  \n> +_git_reflog ()\n> +{\n> +\tlocal SUB_CMDS=(show delete expire)\n> +\tlocal cur=\"${COMP_WORDS[COMP_CWORD-1]}\"\n> +\n> +\tfor val in ${SUB_CMDS[*]}; do\n> +\t\tif [[ \"$val\" == \"$cur\" ]]; then\n> +\t\t\t# this is a subcommand\n> +\t\t\t__gitcomp \"$(__git_refs)\"\n> +\t\t\treturn\n\nThis only looks at the previous word on the command line, and leads to\nwrong behavior when an option is used:\n\n  $ git reflog expire --verbose <TAB><TAB>\n  delete   expire   show     \n\nTo prevent this you could use the __git_find_on_cmdline() helper\nfunction and follow how other completion functions use it.\n\n\n> +\t\tfi\n> +\tdone\n> +\n> +\t__gitcomp \"${SUB_CMDS[*]}\"\n> +}\n> +\n>  __git_send_email_confirm_options=\"always never auto cc compose\"\n>  __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n>  \n> -- \n> 1.7.3.2.496.g9c54\n> \n> \n"},{"id":"156322","messageId":"AANLkTinJPQF-khzViED+ROyojEr9nHrcgwKQWsDugD7Y@mail.gmail.com","threadId":"25796","inReplyTo":"20101122152409.GA7010@neumann","subject":"Re: [PATCH] bash completion: add basic support for git-reflog","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-11-22T15:50:44Z","receivedAt":"2010-11-22T15:50:44Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\n2010/11/22 SZEDER Gábor <szeder@ira.uka.de>:\n> On Sun, Nov 21, 2010 at 01:32:48AM +0800, Tay Ray Chuan wrote:\n>> Add basic completion for the three subcommands - show, expire, delete.\n>> Try completing refs for these too.\n>\n> Heh, I've always thought reflog is plumbing, and that's why the\n> completion script doesn't support it.\n\nThat didn't really cross my mind, I just did this out of my irritation\nwith its absence.\n\n(After some checking, it's actually part of git-log, so I don't think\nit counts as plumbing.)\n\n> This only looks at the previous word on the command line, and leads to\n> wrong behavior when an option is used:\n>\n>  $ git reflog expire --verbose <TAB><TAB>\n>  delete   expire   show\n>\n> To prevent this you could use the __git_find_on_cmdline() helper\n> function and follow how other completion functions use it.\n\nYep I'll look into it.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"156325","messageId":"1290445749-4884-1-git-send-email-rctay89@gmail.com","threadId":"25796","inReplyTo":"AANLkTinJPQF-khzViED+ROyojEr9nHrcgwKQWsDugD7Y@mail.gmail.com","subject":"[PATCH] bash completion: add basic support for git-reflog","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-11-22T17:09:09Z","receivedAt":"2010-11-22T17:09:09Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"\"Promote\" the reflog command out of plumbing, so that we now run\ncompletion for it. After all, it's listed under porcelain (ancillary),\nand we do run completion for those commands.\n\nAdd basic completion for the three subcommands - show, expire, delete.\nTry completing refs for these too.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nChanged from v1: \n - picked up Gábor's suggestion on using __git_find_on_cmdline()\n   to correctly handle situations where subcommands are used with dashed\n   options.\n - don't \"hide\" reflog anymore - run completion for it too.\n\nGábor: hmm, it really seems that reflog is treated as plumbing - no completion\nis done for it. Even get-tar-commit-id (I've never used this before) is treated\nbetter than reflog. Shall do something about it!\n\n contrib/completion/git-completion.bash |   13 ++++++++++++-\n 1 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f710469..6732b1d 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -735,7 +735,6 @@ __git_list_porcelain_commands ()\n \t\tquiltimport)      : import;;\n \t\tread-tree)        : plumbing;;\n \t\treceive-pack)     : plumbing;;\n-\t\treflog)           : plumbing;;\n \t\tremote-*)         : transport;;\n \t\trepo-config)      : deprecated;;\n \t\trerere)           : plumbing;;\n@@ -1632,6 +1631,18 @@ _git_rebase ()\n \t__gitcomp \"$(__git_refs)\"\n }\n \n+_git_reflog ()\n+{\n+\tlocal subcommands=\"show delete expire\"\n+\tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n+\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\telse\n+\t\t__gitcomp \"$(__git_refs)\"\n+\tfi\n+}\n+\n __git_send_email_confirm_options=\"always never auto cc compose\"\n __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n \n-- \n1.7.3.2.493.g2b058\n"},{"id":"156328","messageId":"20101122172057.GC2084@burratino","threadId":"25796","inReplyTo":"1290445749-4884-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] bash completion: add basic support for git-reflog","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-22T17:20:57Z","receivedAt":"2010-11-22T17:20:57Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Tay Ray Chuan wrote:\n\n> Gábor: hmm, it really seems that reflog is treated as plumbing - no completion\n> is done for it.\n\nProbably because it is listed as such in command-list.txt.  I guess\nthe user-facing command for reflog expiration is meant to be \"git gc\"?\n\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1632,6 +1631,18 @@ _git_rebase ()\n>  \t__gitcomp \"$(__git_refs)\"\n>  }\n>  \n> +_git_reflog ()\n> +{\n> +\tlocal subcommands=\"show delete expire\"\n\nPeople really do seem to use these commands directly, so I'm all for\nthis.\n\nI wish there were a way to easily point the end user from \"git reflog\nshow\" to \"git log --walk-reflogs\" (to make the list of other accepted\noptions more obvious) but I can't think of one.\n\nRegards,\nJonathan\n"}]}