{"thread":{"id":"18161","subject":"[PATCH 0/3] improve bash completion of fetch, pull, and push","startedAt":"2009-03-06T04:39:30Z","lastAt":"2009-03-11T14:57:16Z","messageCount":14,"participants":["Jay Soffian","Sverre Rabbelier","Shawn O. Pearce","Nanako Shiraishi"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"107135","messageId":"cover.1236314073.git.jaysoffian@gmail.com","threadId":"18161","inReplyTo":null,"subject":"[PATCH 0/3] improve bash completion of fetch, pull, and push","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T04:39:30Z","receivedAt":"2009-03-06T04:39:30Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Mar 5, 2009 at 6:15 PM, Markus Heidelberg <markus.heidelberg@web.de> wrote:\n> Sverre Rabbelier, 05.03.2009:\n>> Heya,\n>>\n>> Observe:\n>> $ git push ori<tab>\n>>   git push origin\n>>\n>> $ git push -f ori<tab>\n>>   git push -f origin/\n>>\n>> Something weird going on there, or is this intentional and am I\n>> missing something?\n>\n> Something similar happens with fetch and pull. They only complete the\n> remote name, when exactly 2 words are existing on the command line\n> (\"git\" and the subcommand) by: if [ \"$COMP_CWORD\" = 2 ]\n>\n> Doesn't seem right.\n\nThis series is intended to fix the original issue, as well as provide\n--option completion for all three commands. And, I made a clean spot, so\nI had to clean up a couple other things.\n\nJay Soffian (3):\n  bash completion: fix completion issues with fetch, pull, and push\n  bash completion: refactor --strategy completion\n  bash completion: teach fetch, pull, and push to complete their\n    options\n\n contrib/completion/git-completion.bash |  197 +++++++++++++++++++++-----------\n 1 files changed, 130 insertions(+), 67 deletions(-)\n"},{"id":"107136","messageId":"07bd381f7984117681504ce57c1f6c40aecafed3.1236314073.git.jaysoffian@gmail.com","threadId":"18161","inReplyTo":"cover.1236314073.git.jaysoffian@gmail.com","subject":"[PATCH 1/3] bash completion: fix completion issues with fetch, pull, and push","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T04:39:31Z","receivedAt":"2009-03-06T04:39:31Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Sverre Rabbelier noticed a completion issue with push:\n\n $ git push ori<tab>\n git push origin\n\n $ git push -f ori<tab>\n git push -f origin/\n\nMarkus Heidelberg pointed out that the issue extends to fetch and pull.\n\nThe reason is that the current code naively assumes that if\nCOMP_CWORD=2, it should complete a remote name, otherwise it should\ncomplete a refspec. This assumption fails if there are any --options.\n\nThis patch fixes that issue by instead scanning COMP_CWORDS to see if\nthe remote has been completed yet (we now assume the first non-dashed\nargument is the remote). The new logic is factored into a function,\nshared by fetch, pull, and push.\n\nThe new function also properly handles '.' as the remote.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n contrib/completion/git-completion.bash |  109 +++++++++++++++++--------------\n 1 files changed, 60 insertions(+), 49 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0a3092f..b347fdd 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -383,6 +383,63 @@ __git_complete_revlist ()\n \tesac\n }\n \n+__git_complete_remote_or_refspec ()\n+{\n+\tlocal cmd=\"${COMP_WORDS[1]}\"\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tlocal i c=2 remote=\"\" pfx=\"\" lhs=1\n+\twhile [ $c -lt $COMP_CWORD ]; do\n+\t\ti=\"${COMP_WORDS[c]}\"\n+\t\tcase \"$i\" in\n+\t\t-*) ;;\n+\t\t*) remote=\"$i\"; break ;;\n+\t\tesac\n+\t\tc=$((++c))\n+\tdone\n+\tif [ -z \"$remote\" ]; then\n+\t\t__gitcomp \"$(__git_remotes)\"\n+\t\treturn\n+\tfi\n+\t[ \"$remote\" = \".\" ] && remote=\n+\tcase \"$cur\" in\n+\t*:*)\n+\t\tcase \"$COMP_WORDBREAKS\" in\n+\t\t*:*) : great ;;\n+\t\t*)   pfx=\"${cur%%:*}:\" ;;\n+\t\tesac\n+\t\tcur=\"${cur#*:}\"\n+\t\tlhs=0\n+\t\t;;\n+\t+*)\n+\t\tpfx=\"+\"\n+\t\tcur=\"${cur#+}\"\n+\t\t;;\n+\tesac\n+\tcase \"$cmd\" in\n+\tfetch)\n+\t\tif [ $lhs = 1 ]; then\n+\t\t\t__gitcomp \"$(__git_refs2 \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\telse\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\tfi\n+\t\t;;\n+\tpull)\n+\t\tif [ $lhs = 1 ]; then\n+\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\telse\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\tfi\n+\t\t;;\n+\tpush)\n+\t\tif [ $lhs = 1 ]; then\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\telse\n+\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+}\n+\n __git_all_commands ()\n {\n \tif [ -n \"$__git_all_commandlist\" ]; then\n@@ -828,25 +885,7 @@ _git_diff ()\n \n _git_fetch ()\n {\n-\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\telse\n-\t\tcase \"$cur\" in\n-\t\t*:*)\n-\t\t\tlocal pfx=\"\"\n-\t\t\tcase \"$COMP_WORDBREAKS\" in\n-\t\t\t*:*) : great ;;\n-\t\t\t*)   pfx=\"${cur%%:*}:\" ;;\n-\t\t\tesac\n-\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"${cur#*:}\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t__gitcomp \"$(__git_refs2 \"${COMP_WORDS[2]}\")\"\n-\t\t\t;;\n-\t\tesac\n-\tfi\n+\t__git_complete_remote_or_refspec\n }\n \n _git_format_patch ()\n@@ -1111,40 +1150,12 @@ _git_name_rev ()\n \n _git_pull ()\n {\n-\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\telse\n-\t\t__gitcomp \"$(__git_refs \"${COMP_WORDS[2]}\")\"\n-\tfi\n+\t__git_complete_remote_or_refspec\n }\n \n _git_push ()\n {\n-\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\n-\tif [ \"$COMP_CWORD\" = 2 ]; then\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\telse\n-\t\tcase \"$cur\" in\n-\t\t*:*)\n-\t\t\tlocal pfx=\"\"\n-\t\t\tcase \"$COMP_WORDBREAKS\" in\n-\t\t\t*:*) : great ;;\n-\t\t\t*)   pfx=\"${cur%%:*}:\" ;;\n-\t\t\tesac\n-\n-\t\t\t__gitcomp \"$(__git_refs \"${COMP_WORDS[2]}\")\" \"$pfx\" \"${cur#*:}\"\n-\t\t\t;;\n-\t\t+*)\n-\t\t\t__gitcomp \"$(__git_refs)\" + \"${cur#+}\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t__gitcomp \"$(__git_refs)\"\n-\t\t\t;;\n-\t\tesac\n-\tfi\n+\t__git_complete_remote_or_refspec\n }\n \n _git_rebase ()\n-- \n1.6.2.rc2.332.g5d21b\n"},{"id":"107137","messageId":"2d83927582e9eed004b9fd12b77105a184277229.1236314073.git.jaysoffian@gmail.com","threadId":"18161","inReplyTo":"cover.1236314073.git.jaysoffian@gmail.com","subject":"[PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T04:39:32Z","receivedAt":"2009-03-06T04:39:32Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"The code to complete --strategy was duplicated between _git_rebase and\n_git_merge, and is about to gain a third caller (_git_pull). This patch\nfactors it into its own function.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n contrib/completion/git-completion.bash |   37 ++++++++++++++++---------------\n 1 files changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b347fdd..8924185 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -440,6 +440,22 @@ __git_complete_remote_or_refspec ()\n \tesac\n }\n \n+__git_complete_strategy ()\n+{\n+\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n+\t-s|--strategy)\n+\t\t__gitcomp \"$(__git_merge_strategies)\"\n+\t\treturn 1\n+\tesac\n+\tcase \"$cur\" in\n+\t--strategy=*)\n+\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n+\t\treturn 1\n+\t\t;;\n+\tesac\n+\treturn 0\n+}\n+\n __git_all_commands ()\n {\n \tif [ -n \"$__git_all_commandlist\" ]; then\n@@ -1086,17 +1102,10 @@ _git_log ()\n \n _git_merge ()\n {\n+\t__git_complete_strategy && return\n+\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n-\t-s|--strategy)\n-\t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn\n-\tesac\n \tcase \"$cur\" in\n-\t--strategy=*)\n-\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn\n-\t\t;;\n \t--*)\n \t\t__gitcomp \"\n \t\t\t--no-commit --no-stat --log --no-log --squash --strategy\n@@ -1165,16 +1174,8 @@ _git_rebase ()\n \t\t__gitcomp \"--continue --skip --abort\"\n \t\treturn\n \tfi\n-\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n-\t-s|--strategy)\n-\t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn\n-\tesac\n+\t__git_complete_strategy && return\n \tcase \"$cur\" in\n-\t--strategy=*)\n-\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn\n-\t\t;;\n \t--*)\n \t\t__gitcomp \"--onto --merge --strategy --interactive\"\n \t\treturn\n-- \n1.6.2.rc2.332.g5d21b\n"},{"id":"107138","messageId":"5576c9f6e10a6efec0b2bbbd156a25852506cc49.1236314073.git.jaysoffian@gmail.com","threadId":"18161","inReplyTo":"cover.1236314073.git.jaysoffian@gmail.com","subject":"[PATCH 3/3] bash completion: teach fetch, pull, and push to complete their options","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T04:39:33Z","receivedAt":"2009-03-06T04:39:33Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"fetch, pull, and push didn't know their options. They do now. merge's\noptions are factored into a variable so they can be shared between\n_git_merge and _git_pull\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n contrib/completion/git-completion.bash |   61 +++++++++++++++++++++++++++++---\n 1 files changed, 56 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 8924185..3ebedea 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -387,10 +387,11 @@ __git_complete_remote_or_refspec ()\n {\n \tlocal cmd=\"${COMP_WORDS[1]}\"\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\tlocal i c=2 remote=\"\" pfx=\"\" lhs=1\n+\tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \twhile [ $c -lt $COMP_CWORD ]; do\n \t\ti=\"${COMP_WORDS[c]}\"\n \t\tcase \"$i\" in\n+\t\t--all|--mirror) [ \"$cmd\" = \"push\" ] && no_complete_refspec=1 ;;\n \t\t-*) ;;\n \t\t*) remote=\"$i\"; break ;;\n \t\tesac\n@@ -400,6 +401,10 @@ __git_complete_remote_or_refspec ()\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\treturn\n \tfi\n+\tif [ $no_complete_refspec = 1 ]; then\n+\t\tCOMPREPLY=()\n+\t\treturn\n+\tfi\n \t[ \"$remote\" = \".\" ] && remote=\n \tcase \"$cur\" in\n \t*:*)\n@@ -899,8 +904,20 @@ _git_diff ()\n \t__git_complete_file\n }\n \n+__git_fetch_options=\"\n+\t--quiet --verbose --append --upload-pack --force --keep --depth=\n+\t--tags --no-tags\n+\"\n+\n _git_fetch ()\n {\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--*)\n+\t\t__gitcomp \"$__git_fetch_options\"\n+\t\treturn\n+\t\t;;\n+\tesac\n \t__git_complete_remote_or_refspec\n }\n \n@@ -1100,6 +1117,11 @@ _git_log ()\n \t__git_complete_revlist\n }\n \n+__git_merge_options=\"\n+\t--no-commit --no-stat --log --no-log --squash --strategy\n+\t--commit --stat --no-squash --ff --no-ff\n+\"\n+\n _git_merge ()\n {\n \t__git_complete_strategy && return\n@@ -1107,10 +1129,7 @@ _git_merge ()\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \tcase \"$cur\" in\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--no-commit --no-stat --log --no-log --squash --strategy\n-\t\t\t--commit --stat --no-squash --ff --no-ff\n-\t\t\t\"\n+\t\t__gitcomp \"$__git_merge_options\"\n \t\treturn\n \tesac\n \t__gitcomp \"$(__git_refs)\"\n@@ -1159,11 +1178,43 @@ _git_name_rev ()\n \n _git_pull ()\n {\n+\t__git_complete_strategy && return\n+\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--rebase --no-rebase\n+\t\t\t$__git_merge_options\n+\t\t\t$__git_fetch_options\n+\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n \t__git_complete_remote_or_refspec\n }\n \n _git_push ()\n {\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n+\t--repo)\n+\t\t__gitcomp \"$(__git_remotes)\"\n+\t\treturn\n+\tesac\n+\tcase \"$cur\" in\n+\t--repo=*)\n+\t\t__gitcomp \"$(__git_remotes)\" \"\" \"${cur##--repo=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--all --mirror --tags --dry-run --force --verbose\n+\t\t\t--receive-pack= --repo=\n+\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n \t__git_complete_remote_or_refspec\n }\n \n-- \n1.6.2.rc2.332.g5d21b\n"},{"id":"107152","messageId":"fabb9a1e0903052243o286e76c1mf70dbcb9b3daca6c@mail.gmail.com","threadId":"18161","inReplyTo":"cover.1236314073.git.jaysoffian@gmail.com","subject":"Re: [PATCH 0/3] improve bash completion of fetch, pull, and push","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-03-06T06:43:04Z","receivedAt":"2009-03-06T06:43:04Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Fri, Mar 6, 2009 at 05:39, Jay Soffian <jaysoffian@gmail.com> wrote:\n> This series is intended to fix the original issue, as well as provide\n> --option completion for all three commands. And, I made a clean spot, so\n> I had to clean up a couple other things.\n\nThanks, I can't comment on the quality of the patch, but I'm glad you\nwent through the effort of fixing this :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"107215","messageId":"20090306155814.GG16213@spearce.org","threadId":"18161","inReplyTo":"07bd381f7984117681504ce57c1f6c40aecafed3.1236314073.git.jaysoffian@gmail.com","subject":"Re: [PATCH 1/3] bash completion: fix completion issues with fetch, pull, and push","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-06T15:58:14Z","receivedAt":"2009-03-06T15:58:14Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> wrote:\n> Sverre Rabbelier noticed a completion issue with push:\n> \n>  $ git push ori<tab>\n>  git push origin\n> \n>  $ git push -f ori<tab>\n>  git push -f origin/\n> \n> Markus Heidelberg pointed out that the issue extends to fetch and pull.\n> \n> The reason is that the current code naively assumes that if\n> COMP_CWORD=2, it should complete a remote name, otherwise it should\n> complete a refspec. This assumption fails if there are any --options.\n> \n> This patch fixes that issue by instead scanning COMP_CWORDS to see if\n> the remote has been completed yet (we now assume the first non-dashed\n> argument is the remote). The new logic is factored into a function,\n> shared by fetch, pull, and push.\n> \n> The new function also properly handles '.' as the remote.\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n\n> ---\n>  contrib/completion/git-completion.bash |  109 +++++++++++++++++--------------\n>  1 files changed, 60 insertions(+), 49 deletions(-)\n\n-- \nShawn.\n"},{"id":"107217","messageId":"20090306160452.GH16213@spearce.org","threadId":"18161","inReplyTo":"2d83927582e9eed004b9fd12b77105a184277229.1236314073.git.jaysoffian@gmail.com","subject":"Re: [PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-06T16:04:52Z","receivedAt":"2009-03-06T16:04:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> wrote:\n> The code to complete --strategy was duplicated between _git_rebase and\n> _git_merge, and is about to gain a third caller (_git_pull). This patch\n> factors it into its own function.\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n\nLooks OK to me, but I had to squash this in to get it to work.\nWithout this the patch breaks git merge completion entirely:\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9e16576..80d464b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -449,15 +449,15 @@ __git_complete_strategy ()\n \tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n \t-s|--strategy)\n \t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn 1\n+\t\treturn 0\n \tesac\n \tcase \"$cur\" in\n \t--strategy=*)\n \t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn 1\n+\t\treturn 0\n \t\t;;\n \tesac\n-\treturn 0\n+\treturn 1\n }\n \n __git_all_commands ()\n@@ -1111,9 +1111,8 @@ _git_log ()\n \n _git_merge ()\n {\n-\t__git_complete_strategy && return\n-\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\t__git_complete_strategy && return\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n\n> ---\n>  contrib/completion/git-completion.bash |   37 ++++++++++++++++---------------\n>  1 files changed, 19 insertions(+), 18 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index b347fdd..8924185 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -440,6 +440,22 @@ __git_complete_remote_or_refspec ()\n>  \tesac\n>  }\n>  \n> +__git_complete_strategy ()\n> +{\n> +\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n> +\t-s|--strategy)\n> +\t\t__gitcomp \"$(__git_merge_strategies)\"\n> +\t\treturn 1\n> +\tesac\n> +\tcase \"$cur\" in\n> +\t--strategy=*)\n> +\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n> +\t\treturn 1\n> +\t\t;;\n> +\tesac\n> +\treturn 0\n> +}\n> +\n>  __git_all_commands ()\n>  {\n>  \tif [ -n \"$__git_all_commandlist\" ]; then\n> @@ -1086,17 +1102,10 @@ _git_log ()\n>  \n>  _git_merge ()\n>  {\n> +\t__git_complete_strategy && return\n> +\n>  \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n> -\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n> -\t-s|--strategy)\n> -\t\t__gitcomp \"$(__git_merge_strategies)\"\n> -\t\treturn\n> -\tesac\n>  \tcase \"$cur\" in\n> -\t--strategy=*)\n> -\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n> -\t\treturn\n> -\t\t;;\n>  \t--*)\n>  \t\t__gitcomp \"\n>  \t\t\t--no-commit --no-stat --log --no-log --squash --strategy\n> @@ -1165,16 +1174,8 @@ _git_rebase ()\n>  \t\t__gitcomp \"--continue --skip --abort\"\n>  \t\treturn\n>  \tfi\n> -\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n> -\t-s|--strategy)\n> -\t\t__gitcomp \"$(__git_merge_strategies)\"\n> -\t\treturn\n> -\tesac\n> +\t__git_complete_strategy && return\n>  \tcase \"$cur\" in\n> -\t--strategy=*)\n> -\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n> -\t\treturn\n> -\t\t;;\n>  \t--*)\n>  \t\t__gitcomp \"--onto --merge --strategy --interactive\"\n>  \t\treturn\n> -- \n> 1.6.2.rc2.332.g5d21b\n> \n\n-- \nShawn.\n"},{"id":"107219","messageId":"76718490903060812q2e7b2eefg5f25c9845f678959@mail.gmail.com","threadId":"18161","inReplyTo":"20090306160452.GH16213@spearce.org","subject":"Re: [PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T16:12:01Z","receivedAt":"2009-03-06T16:12:01Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Fri, Mar 6, 2009 at 11:04 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Jay Soffian <jaysoffian@gmail.com> wrote:\n>> The code to complete --strategy was duplicated between _git_rebase and\n>> _git_merge, and is about to gain a third caller (_git_pull). This patch\n>> factors it into its own function.\n>>\n>> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n>\n> Looks OK to me, but I had to squash this in to get it to work.\n> Without this the patch breaks git merge completion entirely:\n\nWeird, I had it completely backwards but it seemed to work. Probably\nbecause I was sourcing the new completion into my running shell; I'll\nmake sure to startup a new shell next time.\n\nWith the squash (assuming Junio doesn't mind), is it acked-by you or\nshould I resend?\n\nj.\n"},{"id":"107221","messageId":"20090306161558.GI16213@spearce.org","threadId":"18161","inReplyTo":"5576c9f6e10a6efec0b2bbbd156a25852506cc49.1236314073.git.jaysoffian@gmail.com","subject":"Re: [PATCH 3/3] bash completion: teach fetch, pull, and push to complete their options","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-06T16:15:58Z","receivedAt":"2009-03-06T16:15:58Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> wrote:\n> fetch, pull, and push didn't know their options. They do now. merge's\n> options are factored into a variable so they can be shared between\n> _git_merge and _git_pull\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\nbut I think this patch depends on 2/3 in the series to be fixed first.\n\n> ---\n>  contrib/completion/git-completion.bash |   61 +++++++++++++++++++++++++++++---\n>  1 files changed, 56 insertions(+), 5 deletions(-)\n\n-- \nShawn.\n"},{"id":"107222","messageId":"20090306161657.GJ16213@spearce.org","threadId":"18161","inReplyTo":"76718490903060812q2e7b2eefg5f25c9845f678959@mail.gmail.com","subject":"Re: [PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-06T16:16:57Z","receivedAt":"2009-03-06T16:16:57Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> wrote:\n> On Fri, Mar 6, 2009 at 11:04 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > Jay Soffian <jaysoffian@gmail.com> wrote:\n> >> The code to complete --strategy was duplicated between _git_rebase and\n> >> _git_merge, and is about to gain a third caller (_git_pull). This patch\n> >> factors it into its own function.\n> >>\n> >> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> >\n> > Looks OK to me, but I had to squash this in to get it to work.\n> > Without this the patch breaks git merge completion entirely:\n> \n> Weird, I had it completely backwards but it seemed to work. Probably\n> because I was sourcing the new completion into my running shell; I'll\n> make sure to startup a new shell next time.\n> \n> With the squash (assuming Junio doesn't mind), is it acked-by you or\n> should I resend?\n\nSorry, yes, with the squash it is Ack'd.\n\n-- \nShawn.\n"},{"id":"107225","messageId":"1236357044-55479-1-git-send-email-jaysoffian@gmail.com","threadId":"18161","inReplyTo":"20090306161657.GJ16213@spearce.org","subject":"Re: [PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-06T16:30:44Z","receivedAt":"2009-03-06T16:30:44Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"The code to complete --strategy was duplicated between _git_rebase and\n_git_merge, and is about to gain a third caller (_git_pull). This patch\nfactors it into its own function.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nHow about like this intead? This way 3/3 doesn't need to be adjusted. The\ninterdiff is:\n\n---snip---\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9e16576..056e43e 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -449,15 +449,16 @@ __git_complete_strategy ()\n \tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n \t-s|--strategy)\n \t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn 1\n+\t\treturn 0\n \tesac\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \tcase \"$cur\" in\n \t--strategy=*)\n \t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn 1\n+\t\treturn 0\n \t\t;;\n \tesac\n-\treturn 0\n+\treturn 1\n }\n \n __git_all_commands ()\n---snap---\n\n\n contrib/completion/git-completion.bash |   38 ++++++++++++++++---------------\n 1 files changed, 20 insertions(+), 18 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e8c4be2..056e43e 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -444,6 +444,23 @@ __git_complete_remote_or_refspec ()\n \tesac\n }\n \n+__git_complete_strategy ()\n+{\n+\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n+\t-s|--strategy)\n+\t\t__gitcomp \"$(__git_merge_strategies)\"\n+\t\treturn 0\n+\tesac\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--strategy=*)\n+\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n+\t\treturn 0\n+\t\t;;\n+\tesac\n+\treturn 1\n+}\n+\n __git_all_commands ()\n {\n \tif [ -n \"${__git_all_commandlist-}\" ]; then\n@@ -1095,17 +1112,10 @@ _git_log ()\n \n _git_merge ()\n {\n+\t__git_complete_strategy && return\n+\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n-\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n-\t-s|--strategy)\n-\t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn\n-\tesac\n \tcase \"$cur\" in\n-\t--strategy=*)\n-\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn\n-\t\t;;\n \t--*)\n \t\t__gitcomp \"\n \t\t\t--no-commit --no-stat --log --no-log --squash --strategy\n@@ -1174,16 +1184,8 @@ _git_rebase ()\n \t\t__gitcomp \"--continue --skip --abort\"\n \t\treturn\n \tfi\n-\tcase \"${COMP_WORDS[COMP_CWORD-1]}\" in\n-\t-s|--strategy)\n-\t\t__gitcomp \"$(__git_merge_strategies)\"\n-\t\treturn\n-\tesac\n+\t__git_complete_strategy && return\n \tcase \"$cur\" in\n-\t--strategy=*)\n-\t\t__gitcomp \"$(__git_merge_strategies)\" \"\" \"${cur##--strategy=}\"\n-\t\treturn\n-\t\t;;\n \t--*)\n \t\t__gitcomp \"--onto --merge --strategy --interactive\"\n \t\treturn\n-- \n1.6.2.rc2.332.g5d21b\n"},{"id":"107226","messageId":"20090306163233.GL16213@spearce.org","threadId":"18161","inReplyTo":"1236357044-55479-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 2/3] bash completion: refactor --strategy completion","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-06T16:32:33Z","receivedAt":"2009-03-06T16:32:33Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> wrote:\n> The code to complete --strategy was duplicated between _git_rebase and\n> _git_merge, and is about to gain a third caller (_git_pull). This patch\n> factors it into its own function.\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> ---\n> How about like this intead? This way 3/3 doesn't need to be adjusted. The\n> interdiff is:\n\nYup, that works too!\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n \n>  contrib/completion/git-completion.bash |   38 ++++++++++++++++---------------\n>  1 files changed, 20 insertions(+), 18 deletions(-)\n\n-- \nShawn.\n"},{"id":"107663","messageId":"20090311190227.6117@nanako3.lavabit.com","threadId":"18161","inReplyTo":"20090306155814.GG16213@spearce.org","subject":"Re: [PATCH 1/3] bash completion: fix completion issues with fetch, pull, and push","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-03-11T10:02:27Z","receivedAt":"2009-03-11T10:02:27Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Shawn O. Pearce <spearce@spearce.org>:\n\n> Jay Soffian <jaysoffian@gmail.com> wrote:\n>> Sverre Rabbelier noticed a completion issue with push:\n>> \n>>  $ git push ori<tab>\n>>  git push origin\n>> \n>>  $ git push -f ori<tab>\n>>  git push -f origin/\n>> \n>> Markus Heidelberg pointed out that the issue extends to fetch and pull.\n>> \n>> The reason is that the current code naively assumes that if\n>> COMP_CWORD=2, it should complete a remote name, otherwise it should\n>> complete a refspec. This assumption fails if there are any --options.\n>> \n>> This patch fixes that issue by instead scanning COMP_CWORDS to see if\n>> the remote has been completed yet (we now assume the first non-dashed\n>> argument is the remote). The new logic is factored into a function,\n>> shared by fetch, pull, and push.\n>> \n>> The new function also properly handles '.' as the remote.\n>> \n>> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n>\n> Acked-by: Shawn O. Pearce <spearce@spearce.org>\n\nWhile people's attention is on the completion, there is one case I wish the completion worked better.\n\"git log origin..mas[TAB]\" and \"git log origin...mas[TAB]\" work as expected, but the same completion does not work for \"git diff\". I don't miss the two-dot format but it's often useful to say \"git diff origin...master\".\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"107695","messageId":"76718490903110757j3b90dcffx4b81d2a02427008b@mail.gmail.com","threadId":"18161","inReplyTo":"20090311190227.6117@nanako3.lavabit.com","subject":"Re: [PATCH 1/3] bash completion: fix completion issues with fetch, pull, and push","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-11T14:57:16Z","receivedAt":"2009-03-11T14:57:16Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 11, 2009 at 6:02 AM, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> While people's attention is on the completion, there is one case I wish the completion worked better.\n> \"git log origin..mas[TAB]\" and \"git log origin...mas[TAB]\" work as expected, but the same completion does not work for \"git diff\". I don't miss the two-dot format but it's often useful to say \"git diff origin...master\".\n\nI just looked and realized to fix this properly, __git_complete_file\nand __git_complete_revlist need some refactoring, along with the\nfunctions that use them.\n\nSo I'll add it to my todo list, since it's more than 5 minutes of\navailable time I have right now.\n\nj.\n"}]}