{"thread":{"id":"32140","subject":"[RFC/PATCH v2 1/8] completion: trivial test improvement","startedAt":"2012-11-18T10:56:45Z","lastAt":"2012-11-18T10:56:53Z","messageCount":9,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":2,"patchTotal":8},"messages":[{"id":"203474","messageId":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":null,"subject":"[RFC/PATCH v2 0/8] completion: compgen/compadd cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:45Z","receivedAt":"2012-11-18T10:56:45Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nThese were hinted by SZEDER, so I went ahead and implemented the changes trying\nto keep in mind the new zsh completion werapper. The resulting code should be\nmore efficient, and a known breakage is fixed.\n\nThe first two patches are transplanted from another patch series which most\nlikely is not going to use them.\n\nI also borrowed the tests from another patch series from SZEDER, but they are\nnot meant to be applied through this series.\n\nSZEDER implemented some of this, but I prefer my version of the patches.\n\nFelipe Contreras (8):\n  completion: trivial test improvement\n  completion: get rid of empty COMPREPLY assignments\n  completion: add new __gitcompadd helper\n  tmp: completion: add SZEDER's tests\n  completion: get rid of compgen\n  tmp: completion: mark SZEDER's tests as fixed\n  completion: get rid of __gitcomp_1\n  completion: small optimization\n\n contrib/completion/git-completion.bash | 77 ++++++++++++----------------------\n t/t9902-completion.sh                  | 66 ++++++++++++++++++++++++++++-\n 2 files changed, 91 insertions(+), 52 deletions(-)\n\n-- \n1.8.0\n"},{"id":"203473","messageId":"1353236213-13471-2-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 1/8] completion: trivial test improvement","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:46Z","receivedAt":"2012-11-18T10:56:46Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Instead of passing a dummy \"\", let's check if the last character is a\nspace, and then move the _cword accordingly.\n\nApparently we were passing \"\" all the way to compgen, which fortunately\nexpanded it to nothing.\n\nLets do the right thing though.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t9902-completion.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 8fa025f..79a2453 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -50,6 +50,7 @@ run_completion ()\n \tlocal -a COMPREPLY _words\n \tlocal _cword\n \t_words=( $1 )\n+\ttest \"${1: -1}\" == ' ' && _words+=('')\n \t(( _cword = ${#_words[@]} - 1 ))\n \t__git_wrap__git_main && print_comp\n }\n@@ -156,7 +157,7 @@ test_expect_success '__gitcomp - suffix' '\n '\n \n test_expect_success 'basic' '\n-\trun_completion \"git \\\"\\\"\" &&\n+\trun_completion \"git \" &&\n \t# built-in\n \tgrep -q \"^add \\$\" out &&\n \t# script\n-- \n1.8.0\n"},{"id":"203476","messageId":"1353236213-13471-3-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 2/8] completion: get rid of empty COMPREPLY assignments","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:47Z","receivedAt":"2012-11-18T10:56:47Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There's no functional reason for those, the only purpose they are\nsupposed to serve is to say \"we don't provide any words here\", but even\nfor that it's not used consitently.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 27 ---------------------------\n 1 file changed, 27 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex bc0657a..c2fb061 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -238,7 +238,6 @@ __gitcomp ()\n \n \tcase \"$cur_\" in\n \t--*=)\n-\t\tCOMPREPLY=()\n \t\t;;\n \t*)\n \t\tlocal IFS=$'\\n'\n@@ -486,7 +485,6 @@ __git_complete_remote_or_refspec ()\n \t\t\tcase \"$cmd\" in\n \t\t\tpush) no_complete_refspec=1 ;;\n \t\t\tfetch)\n-\t\t\t\tCOMPREPLY=()\n \t\t\t\treturn\n \t\t\t\t;;\n \t\t\t*) ;;\n@@ -502,7 +500,6 @@ __git_complete_remote_or_refspec ()\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@@ -776,7 +773,6 @@ _git_am ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_apply ()\n@@ -796,7 +792,6 @@ _git_apply ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_add ()\n@@ -811,7 +806,6 @@ _git_add ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_archive ()\n@@ -856,7 +850,6 @@ _git_bisect ()\n \t\t__gitcomp_nl \"$(__git_refs)\"\n \t\t;;\n \t*)\n-\t\tCOMPREPLY=()\n \t\t;;\n \tesac\n }\n@@ -969,7 +962,6 @@ _git_clean ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_clone ()\n@@ -993,7 +985,6 @@ _git_clone ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_commit ()\n@@ -1027,7 +1018,6 @@ _git_commit ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_describe ()\n@@ -1152,7 +1142,6 @@ _git_fsck ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_gc ()\n@@ -1163,7 +1152,6 @@ _git_gc ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_gitk ()\n@@ -1240,7 +1228,6 @@ _git_init ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_ls_files ()\n@@ -1259,7 +1246,6 @@ _git_ls_files ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_ls_remote ()\n@@ -1375,7 +1361,6 @@ _git_mergetool ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_merge_base ()\n@@ -1391,7 +1376,6 @@ _git_mv ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_name_rev ()\n@@ -1681,7 +1665,6 @@ _git_config ()\n \t\treturn\n \t\t;;\n \t*.*)\n-\t\tCOMPREPLY=()\n \t\treturn\n \t\t;;\n \tesac\n@@ -2061,7 +2044,6 @@ _git_remote ()\n \t\t__gitcomp \"$c\"\n \t\t;;\n \t*)\n-\t\tCOMPREPLY=()\n \t\t;;\n \tesac\n }\n@@ -2105,7 +2087,6 @@ _git_rm ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_shortlog ()\n@@ -2174,8 +2155,6 @@ _git_stash ()\n \t\t*)\n \t\t\tif [ -z \"$(__git_find_on_cmdline \"$save_opts\")\" ]; then\n \t\t\t\t__gitcomp \"$subcommands\"\n-\t\t\telse\n-\t\t\t\tCOMPREPLY=()\n \t\t\tfi\n \t\t\t;;\n \t\tesac\n@@ -2188,14 +2167,12 @@ _git_stash ()\n \t\t\t__gitcomp \"--index --quiet\"\n \t\t\t;;\n \t\tshow,--*|drop,--*|branch,--*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tshow,*|apply,*|drop,*|pop,*|branch,*)\n \t\t\t__gitcomp_nl \"$(git --git-dir=\"$(__gitdir)\" stash list \\\n \t\t\t\t\t| sed -n -e 's/:.*//p')\"\n \t\t\t;;\n \t\t*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tesac\n \tfi\n@@ -2312,7 +2289,6 @@ _git_svn ()\n \t\t\t__gitcomp \"--revision= --parent\"\n \t\t\t;;\n \t\t*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tesac\n \tfi\n@@ -2337,13 +2313,10 @@ _git_tag ()\n \n \tcase \"$prev\" in\n \t-m|-F)\n-\t\tCOMPREPLY=()\n \t\t;;\n \t-*|tag)\n \t\tif [ $f = 1 ]; then\n \t\t\t__gitcomp_nl \"$(__git_tags)\"\n-\t\telse\n-\t\t\tCOMPREPLY=()\n \t\tfi\n \t\t;;\n \t*)\n-- \n1.8.0\n"},{"id":"203475","messageId":"1353236213-13471-4-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 3/8] completion: add new __gitcompadd helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:48Z","receivedAt":"2012-11-18T10:56:48Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The idea is to never touch the COMPREPLY variable directly.\n\nThis allows other completion systems override __gitcompadd, and do\nsomething different instead.\n\nAlso, this allows the simplification of the completion tests (separate\npatch).\n\nThere should be no functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 13 ++++++++-----\n 1 file changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c2fb061..19e18a8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -225,6 +225,11 @@ _get_comp_words_by_ref ()\n fi\n fi\n \n+__gitcompadd ()\n+{\n+\tCOMPREPLY=($(compgen -W \"$1\" -P \"$2\" -S \"$4\" -- \"$3\"))\n+}\n+\n # Generates completion reply with compgen, appending a space to possible\n # completion words, if necessary.\n # It accepts 1 to 4 arguments:\n@@ -241,9 +246,7 @@ __gitcomp ()\n \t\t;;\n \t*)\n \t\tlocal IFS=$'\\n'\n-\t\tCOMPREPLY=($(compgen -P \"${2-}\" \\\n-\t\t\t-W \"$(__gitcomp_1 \"${1-}\" \"${4-}\")\" \\\n-\t\t\t-- \"$cur_\"))\n+\t\t__gitcompadd \"$(__gitcomp_1 \"${1-}\" \"${4-}\")\" \"${2-}\" \"$cur_\" \"\"\n \t\t;;\n \tesac\n }\n@@ -260,7 +263,7 @@ __gitcomp ()\n __gitcomp_nl ()\n {\n \tlocal IFS=$'\\n'\n-\tCOMPREPLY=($(compgen -P \"${2-}\" -S \"${4- }\" -W \"$1\" -- \"${3-$cur}\"))\n+\t__gitcompadd \"$1\" \"${2-}\" \"${3-$cur}\" \"${4- }\"\n }\n \n __git_heads ()\n@@ -1605,7 +1608,7 @@ _git_config ()\n \t\tlocal remote=\"${prev#remote.}\"\n \t\tremote=\"${remote%.fetch}\"\n \t\tif [ -z \"$cur\" ]; then\n-\t\t\tCOMPREPLY=(\"refs/heads/\")\n+\t\t\t__gitcompadd \"refs/heads/\"\n \t\t\treturn\n \t\tfi\n \t\t__gitcomp_nl \"$(__git_refs_remotes \"$remote\")\"\n-- \n1.8.0\n"},{"id":"203477","messageId":"1353236213-13471-5-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 4/8] tmp: completion: add SZEDER's tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:49Z","receivedAt":"2012-11-18T10:56:49Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Separate patch series, but the results are relevant.\n\n+ modifications from me.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t9902-completion.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 61 insertions(+)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 79a2453..35fc31b 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -73,6 +73,24 @@ test_completion_long ()\n \n newline=$'\\n'\n \n+# Test __gitcomp_nl\n+# Arguments are:\n+# 1: current word (cur)\n+# -: the rest are passed to __gitcomp_nl\n+test_gitcomp_nl ()\n+{\n+\tlocal -a COMPREPLY &&\n+\tsed -e 's/Z$//' > expected &&\n+\tcur=\"$1\" &&\n+\tshift &&\n+\t__gitcomp_nl \"$@\" &&\n+\tprint_comp &&\n+\tcp expected out /tmp\n+\ttest_cmp expected out\n+}\n+\n+invalid_variable_name=\"${foo.bar}\"\n+\n test_expect_success '__gitcomp - trailing space - options' '\n \tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n \t--reuse-message=Z\n@@ -156,6 +174,49 @@ test_expect_success '__gitcomp - suffix' '\n \ttest_cmp expected out\n '\n \n+test_expect_failure '__gitcomp - doesnt fail because of invalid variable name' '\n+\t__gitcomp \"$invalid_variable_name\"\n+'\n+\n+read -r -d \"\" refs <<-\\EOF\n+maint\n+master\n+next\n+pu\n+EOF\n+\n+test_expect_success '__gitcomp_nl - trailing space' '\n+\ttest_gitcomp_nl \"m\" \"$refs\" <<-EOF\n+\tmaint Z\n+\tmaster Z\n+\tEOF\n+'\n+\n+test_expect_success '__gitcomp_nl - prefix' '\n+\ttest_gitcomp_nl \"--fixup=m\" \"$refs\" \"--fixup=\" \"m\" <<-EOF\n+\t--fixup=maint Z\n+\t--fixup=master Z\n+\tEOF\n+'\n+\n+test_expect_success '__gitcomp_nl - suffix' '\n+\ttest_gitcomp_nl \"branch.ma\" \"$refs\" \"branch.\" \"ma\" \".\" <<-\\EOF\n+\tbranch.maint.Z\n+\tbranch.master.Z\n+\tEOF\n+'\n+\n+test_expect_success '__gitcomp_nl - no suffix' '\n+\ttest_gitcomp_nl \"ma\" \"$refs\" \"\" \"ma\" \"\" <<-\\EOF\n+\tmaintZ\n+\tmasterZ\n+\tEOF\n+'\n+\n+test_expect_failure '__gitcomp_nl - doesnt fail because of invalid variable name' '\n+\t__gitcomp_nl \"$invalid_variable_name\"\n+'\n+\n test_expect_success 'basic' '\n \trun_completion \"git \" &&\n \t# built-in\n-- \n1.8.0\n"},{"id":"203478","messageId":"1353236213-13471-6-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 5/8] completion: get rid of compgen","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:50Z","receivedAt":"2012-11-18T10:56:50Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The functionality we use from compgen is not much, we can do the same\nmanually, with drastical improvements in speed, specially when dealing\nwith only a few rods.\n\nThis patch also has the sideffect that brekage reported by Jeroen Meijer\nand SZEDER Gábor gets fixed because we no longer expand the resulting\nwords.\n\nOther solutions with awk and sed are possible and more efficient when\ndealing with tens of thousands of words. But is rarely the case. For the\ncommon cases, this solution is faster.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 15 ++++++++++-----\n t/t9902-completion.sh                  |  2 +-\n 2 files changed, 11 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 19e18a8..0b72f24 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -227,11 +227,16 @@ fi\n \n __gitcompadd ()\n {\n-\tCOMPREPLY=($(compgen -W \"$1\" -P \"$2\" -S \"$4\" -- \"$3\"))\n+\tlocal i=0\n+\tfor x in $1; do\n+\t\tif [[ \"$x\" == \"$3\"* ]]; then\n+\t\t\tCOMPREPLY[i++]=\"$2$x$4\"\n+\t\tfi\n+\tdone\n }\n \n-# Generates completion reply with compgen, appending a space to possible\n-# completion words, if necessary.\n+# Generates completion reply, appending a space to possible completion words,\n+# if necessary.\n # It accepts 1 to 4 arguments:\n # 1: List of possible completion words.\n # 2: A prefix to be added to each possible completion word (optional).\n@@ -251,8 +256,8 @@ __gitcomp ()\n \tesac\n }\n \n-# Generates completion reply with compgen from newline-separated possible\n-# completion words by appending a space to all of them.\n+# Generates completion reply from newline-separated possible completion words\n+# by appending a space to all of them.\n # It accepts 1 to 4 arguments:\n # 1: List of possible completion words, separated by a single newline.\n # 2: A prefix to be added to each possible completion word (optional).\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 35fc31b..7fb5b50 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -340,7 +340,7 @@ test_expect_success 'complete tree filename with spaces' '\n \tEOF\n '\n \n-test_expect_failure 'complete tree filename with metacharacters' '\n+test_expect_success 'complete tree filename with metacharacters' '\n \techo content >\"name with \\${meta}\" &&\n \tgit add . &&\n \tgit commit -m meta &&\n-- \n1.8.0\n"},{"id":"203479","messageId":"1353236213-13471-7-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 6/8] tmp: completion: mark SZEDER's tests as fixed","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:51Z","receivedAt":"2012-11-18T10:56:51Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t9902-completion.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 7fb5b50..4e2f4fb 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -174,7 +174,7 @@ test_expect_success '__gitcomp - suffix' '\n \ttest_cmp expected out\n '\n \n-test_expect_failure '__gitcomp - doesnt fail because of invalid variable name' '\n+test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '\n \t__gitcomp \"$invalid_variable_name\"\n '\n \n@@ -213,7 +213,7 @@ test_expect_success '__gitcomp_nl - no suffix' '\n \tEOF\n '\n \n-test_expect_failure '__gitcomp_nl - doesnt fail because of invalid variable name' '\n+test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' '\n \t__gitcomp_nl \"$invalid_variable_name\"\n '\n \n-- \n1.8.0\n"},{"id":"203480","messageId":"1353236213-13471-8-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 7/8] completion: get rid of __gitcomp_1","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:52Z","receivedAt":"2012-11-18T10:56:52Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There's no point in calling a separate function that is only used in one\nplace. Specially considering that there's no need to call compgen, and\nwe traverse the words ourselves both in __gitcompadd, and __gitcomp_1.\n\nSo lets squash the functions together, and traverse only once.\n\nThis improves performance.\n\nNo functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 26 +++++++++++---------------\n 1 file changed, 11 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0b72f24..82ea7b1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -56,19 +56,6 @@ __gitdir ()\n \tfi\n }\n \n-__gitcomp_1 ()\n-{\n-\tlocal c IFS=$' \\t\\n'\n-\tfor c in $1; do\n-\t\tc=\"$c$2\"\n-\t\tcase $c in\n-\t\t--*=*|*.) ;;\n-\t\t*) c=\"$c \" ;;\n-\t\tesac\n-\t\tprintf '%s\\n' \"$c\"\n-\tdone\n-}\n-\n # The following function is based on code from:\n #\n #   bash_completion - programmable completion functions for bash 3.2+\n@@ -250,8 +237,17 @@ __gitcomp ()\n \t--*=)\n \t\t;;\n \t*)\n-\t\tlocal IFS=$'\\n'\n-\t\t__gitcompadd \"$(__gitcomp_1 \"${1-}\" \"${4-}\")\" \"${2-}\" \"$cur_\" \"\"\n+\t\tlocal c i=0 IFS=$' \\t\\n'\n+\t\tfor c in $1; do\n+\t\t\tc=\"$c${4-}\"\n+\t\t\tcase $c in\n+\t\t\t--*=*|*.) ;;\n+\t\t\t*) c=\"$c \" ;;\n+\t\t\tesac\n+\t\t\tif [[ $c == \"$cur_\"* ]]; then\n+\t\t\t\tCOMPREPLY[i++]=\"${2-}$c\"\n+\t\t\tfi\n+\t\tdone\n \t\t;;\n \tesac\n }\n-- \n1.8.0\n"},{"id":"203481","messageId":"1353236213-13471-9-git-send-email-felipe.contreras@gmail.com","threadId":"32140","inReplyTo":"1353236213-13471-1-git-send-email-felipe.contreras@gmail.com","subject":"[RFC/PATCH v2 8/8] completion: small optimization","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T10:56:53Z","receivedAt":"2012-11-18T10:56:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No need to calculate a new $c with a space if we are not going to do\nanything it with it.\n\nThere should be no functional changes, except that a word \"foo \" with no\nsuffixes can't be matched. But $cur cannot have a space at the end\nanyway. So it's safe.\n\nBased on the code from SZEDER Gábor.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 82ea7b1..e5f862c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -240,11 +240,11 @@ __gitcomp ()\n \t\tlocal c i=0 IFS=$' \\t\\n'\n \t\tfor c in $1; do\n \t\t\tc=\"$c${4-}\"\n-\t\t\tcase $c in\n-\t\t\t--*=*|*.) ;;\n-\t\t\t*) c=\"$c \" ;;\n-\t\t\tesac\n \t\t\tif [[ $c == \"$cur_\"* ]]; then\n+\t\t\t\tcase $c in\n+\t\t\t\t--*=*|*.) ;;\n+\t\t\t\t*) c=\"$c \" ;;\n+\t\t\t\tesac\n \t\t\t\tCOMPREPLY[i++]=\"${2-}$c\"\n \t\t\tfi\n \t\tdone\n-- \n1.8.0\n"}]}