{"thread":{"id":"43315","subject":"Re: [PATCH 1/10] Teach git-completion.bash how to complete git-merge.","startedAt":"2006-11-27T08:40:47Z","lastAt":"2006-11-27T20:12:36Z","messageCount":3,"participants":["Shawn Pearce","Junio C Hamano","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"297096","messageId":"20061127084047.GA19745@spearce.org","threadId":"43315","inReplyTo":null,"subject":"[PATCH 1/10] Teach git-completion.bash how to complete git-merge.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-27T08:40:47Z","receivedAt":"2006-11-27T08:40:47Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Now that git-merge is high-level Porcelain users are going to expect\nto be able to use it from the command line, in which case we really\nshould also be able to complete ref names as parameters.\n\nI'm also including completion support for the merge strategies\nthat are supported by git-merge.sh, should the user wish to use a\ndifferent strategy than their default.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |   30 ++++++++++++++++++++++++++++++\n 1 files changed, 30 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex a43a177..28bd0e3 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -81,6 +81,16 @@ __git_remotes ()\n \tdone\n }\n \n+__git_merge_strategies ()\n+{\n+\tsed -n \"/^all_strategies='/{\n+\t\ts/^all_strategies='//\n+\t\ts/'//\n+\t\tp\n+\t\tq\n+\t\t}\" \"$(git --exec-path)/git-merge\"\n+}\n+\n __git_complete_file ()\n {\n \tlocal pfx ls ref cur=\"${COMP_WORDS[COMP_CWORD]}\"\n@@ -240,6 +250,24 @@ _git_log ()\n \tesac\n }\n \n+_git_merge ()\n+{\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--*)\n+\t\tCOMPREPLY=($(compgen -W \"\n+\t\t\t--no-commit --no-summary --squash\n+\t\t\t\" -- \"$cur\"))\n+\t\treturn\n+\tesac\n+\tif [ $COMP_CWORD -gt 1 -a X-s = \"X${COMP_WORDS[COMP_CWORD-1]}\" ]\n+\tthen\n+\t\tCOMPREPLY=($(compgen -W \"$(__git_merge_strategies)\" -- \"$cur\"))\n+\telse\n+\t\tCOMPREPLY=($(compgen -W \"$(__git_refs)\" -- \"$cur\"))\n+\tfi\n+}\n+\n _git_merge_base ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n@@ -348,6 +376,7 @@ _git ()\n \tlog)         _git_log ;;\n \tls-remote)   _git_ls_remote ;;\n \tls-tree)     _git_ls_tree ;;\n+\tmerge)       _git_merge;;\n \tmerge-base)  _git_merge_base ;;\n \tpull)        _git_pull ;;\n \tpush)        _git_push ;;\n@@ -376,6 +405,7 @@ complete -o default -o nospace -F _git_fetch git-fetch\n complete -o default -o nospace -F _git_log git-log\n complete -o default            -F _git_ls_remote git-ls-remote\n complete -o default -o nospace -F _git_ls_tree git-ls-tree\n+complete -o default            -F _git_merge git-merge\n complete -o default            -F _git_merge_base git-merge-base\n complete -o default -o nospace -F _git_pull git-pull\n complete -o default -o nospace -F _git_push git-push\n-- \n1.4.4.1.ge3fb\n"},{"id":"296180","messageId":"7vlklwhffb.fsf@assigned-by-dhcp.cox.net","threadId":"43315","inReplyTo":"20061127084047.GA19745@spearce.org","subject":"Re: [PATCH 1/10] Teach git-completion.bash how to complete git-merge.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-27T19:12:40Z","receivedAt":"2006-11-27T19:12:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> +__git_merge_strategies ()\n> +{\n> +\tsed -n \"/^all_strategies='/{\n> +\t\ts/^all_strategies='//\n> +\t\ts/'//\n> +\t\tp\n> +\t\tq\n> +\t\t}\" \"$(git --exec-path)/git-merge\"\n> +}\n> +\n\nShouldn't we load and compute this once and keep the result in a\nvariable (say $__git_merge_strategies)?\n"},{"id":"294327","messageId":"20061127201236.GA7331@spearce.org","threadId":"43315","inReplyTo":"7vlklwhffb.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/10] Teach git-completion.bash how to complete git-merge.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-27T20:12:36Z","receivedAt":"2006-11-27T20:12:36Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > +__git_merge_strategies ()\n> > +{\n> > +\tsed -n \"/^all_strategies='/{\n> > +\t\ts/^all_strategies='//\n> > +\t\ts/'//\n> > +\t\tp\n> > +\t\tq\n> > +\t\t}\" \"$(git --exec-path)/git-merge\"\n> > +}\n> > +\n> \n> Shouldn't we load and compute this once and keep the result in a\n> variable (say $__git_merge_strategies)?\n\nSure.  See my latest 4 patch series.  :-)\n \n-- \n"}]}