{"thread":{"id":"8008","subject":"[PATCH] Teach bash to complete branch names in some places.","startedAt":"2007-05-06T23:13:57Z","lastAt":"2007-05-07T01:11:08Z","messageCount":2,"participants":["Yann Dirson","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"41272","messageId":"20070506231357.31547.25929.stgit@gandelf.nowhere.earth","threadId":"8008","inReplyTo":null,"subject":"[PATCH] Teach bash to complete branch names in some places.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-06T23:13:57Z","receivedAt":"2007-05-06T23:13:57Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis patch causes bash completion to look for branch names instead of\npatch names for \"branch\" and \"rebase\".\n\nUnfortunately, the current completion framework does not seem flexible\nenough to get branch completion after \"-b\" flags, but I feel things\nare already better this way.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stgit-completion.bash |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stgit-completion.bash b/contrib/stgit-completion.bash\nindex 760fc2f..d497098 100644\n--- a/contrib/stgit-completion.bash\n+++ b/contrib/stgit-completion.bash\n@@ -98,6 +98,12 @@ _all_other_patches ()\n         | grep -v \"^$(cat $g/patches/$b/current 2> /dev/null)$\"\n }\n \n+_all_branches ()\n+{\n+    local g=$(_gitdir)\n+    [ \"$g\" ] && (cd .git/patches/ && echo *)\n+}\n+\n # List the command options\n _cmd_options ()\n {\n@@ -137,6 +143,11 @@ _complete_patch_range_options ()\n     COMPREPLY=($(compgen -W \"$options\" -- \"$cur\"))\n }\n \n+_complete_branch ()\n+{\n+     COMPREPLY=($(compgen -W \"$(_cmd_options $1) $($2)\" -- \"${COMP_WORDS[COMP_CWORD]}\"))\n+}\n+\n # Generate completions for options from the given list.\n _complete_options ()\n {\n@@ -211,6 +222,9 @@ _stg ()\n         sync)   _stg_patches $command _applied_patches ;;\n         # working-copy commands\n         diff)   _stg_patches_options $command _applied_patches \"-r --range\" ;;\n+\t# commands that usually raher accept branches\n+\tbranch) _complete_branch $command _all_branches ;;\n+\trebase) _complete_branch $command _all_branches ;;\n         # all the other commands\n         *)      _stg_common $command ;;\n     esac\n"},{"id":"41278","messageId":"20070507011108.GA28137@diana.vm.bytemark.co.uk","threadId":"8008","inReplyTo":"20070506231357.31547.25929.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH] Teach bash to complete branch names in some places.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-05-07T01:11:08Z","receivedAt":"2007-05-07T01:11:08Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-05-07 01:13:57 +0200, Yann Dirson wrote:\n\n> Unfortunately, the current completion framework does not seem\n> flexible enough to get branch completion after \"-b\" flags, but I\n> feel things are already better this way.\n\nPerhaps another round of stealing stuff from git's bash completion is\nin order?\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}