{"thread":{"id":"45481","subject":"[PATCH 1/3] completion: put matching ctags symbol names directly into COMPREPLY","startedAt":"2017-03-23T15:38:54Z","lastAt":"2017-04-01T08:51:09Z","messageCount":9,"participants":["SZEDER Gábor","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"315097","messageId":"20170323153839.24283-2-szeder.dev@gmail.com","threadId":"45481","inReplyTo":"20170323153839.24283-1-szeder.dev@gmail.com","subject":"[PATCH 1/3] completion: put matching ctags symbol names directly into COMPREPLY","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-03-23T15:38:37Z","receivedAt":"2017-03-23T15:38:54Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The one-liner awk script in __git_match_ctag() listing ctags symbol\nnames for 'git grep <TAB>' is already smart enough to list only symbol\nnames matching the current word to be completed.\n\nExtend this helper function to accept prefix and suffix parameters to\nbe prepended and appended, respectively, to each listed symbol name in\nthe awk script, so its output won't require any additional processing\nor filtering in the completion script before being handed over to\nBash.  Use the faster __gitcomp_direct() helper instead of\n__gitcomp_nl() to fill the fully processed matching symbol names into\nBash's COMPREPLY array.\n\nRight after 'git grep <TAB>' in current git.git with 14k+ symbol names\nin the tag file, best of five:\n\n  Before:\n\n    $ time __gitcomp_nl \"$(__git_match_ctag \"\" tags)\"\n\n    real    0m0.178s\n    user    0m0.176s\n    sys     0m0.000s\n\n  After:\n\n    $ time __gitcomp_direct \"$(__git_match_ctag \"\" tags \"\" \" \")\"\n\n    real    0m0.058s\n    user    0m0.048s\n    sys     0m0.008s\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n\nNotes:\n    It's still just a simple linear search through the tags file, so there\n    are no miracles: it's still hopelessly, unusably slow e.g. in the\n    Linux repository.\n\n contrib/completion/git-completion.bash | 13 ++++++++++---\n 1 file changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 69eabc2bc..5cacb0e2e 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1518,8 +1518,15 @@ _git_gitk ()\n \t_gitk\n }\n \n-__git_match_ctag() {\n-\tawk \"/^${1//\\//\\\\/}/ { print \\$1 }\" \"$2\"\n+# Lists matching symbol names from a tag (as in ctags) file.\n+# 1: List symbol names matching this word.\n+# 2: The tag file to list symbol names from.\n+# 3: A prefix to be added to each listed symbol name (optional).\n+# 4: A suffix to be appended to each listed symbol name (optional).\n+__git_match_ctag () {\n+\tawk -v pfx=\"${3-}\" -v sfx=\"${4-}\" \"\n+\t\t/^${1//\\//\\\\/}/ { print pfx \\$1 sfx }\n+\t\t\" \"$2\"\n }\n \n _git_grep ()\n@@ -1548,7 +1555,7 @@ _git_grep ()\n \tcase \"$cword,$prev\" in\n \t2,*|*,-*)\n \t\tif test -r tags; then\n-\t\t\t__gitcomp_nl \"$(__git_match_ctag \"$cur\" tags)\"\n+\t\t\t__gitcomp_direct \"$(__git_match_ctag \"$cur\" tags \"\" \" \")\"\n \t\t\treturn\n \t\tfi\n \t\t;;\n-- \n2.12.1.498.gded7ead47\n\n"},{"id":"315098","messageId":"20170323153839.24283-1-szeder.dev@gmail.com","threadId":"45481","inReplyTo":null,"subject":"[PATCH 0/3] completion: updates to ctags symbol names","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-03-23T15:38:36Z","receivedAt":"2017-03-23T15:39:03Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"This short series \n\n  - speeds up the completion of ctags symbol names by using some of\n    the trick from the refs completion speedup series, and\n\n  - offers symbol names for 'git log -S', '-G' and '-L:', which I find\n    really convenient when digging history.\n\nIt should go on top of 'sg/completion-refs-speedup'.\n\n\nSZEDER Gábor (3):\n  completion: put matching ctags symbol names directly into COMPREPLY\n  completion: extract completing ctags symbol names into helper function\n  completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'\n\n contrib/completion/git-completion.bash | 72 +++++++++++++++++++++++++++++++---\n 1 file changed, 66 insertions(+), 6 deletions(-)\n\n-- \n2.12.1.498.gded7ead47\n\n"},{"id":"315099","messageId":"20170323153839.24283-3-szeder.dev@gmail.com","threadId":"45481","inReplyTo":"20170323153839.24283-1-szeder.dev@gmail.com","subject":"[PATCH 2/3] completion: extract completing ctags symbol names into helper function","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-03-23T15:38:38Z","receivedAt":"2017-03-23T15:39:04Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The previous commit doubled the number of __git_match_ctag()'s\npositional parameters, and, to keep the position of existing\nparameters for the sake of backwards compatibility, the prefix,\ncurrent word and suffix parameters ended up in different order than in\nother functions accepting the same parameters.  Then there is a\ncondition checking the existence of the tag file before invoking this\nfunction.\n\nWe could still live with this if there were only a single callsite,\nbut the next commit will add a few more, so it's worth providing a\ncleaner interface.\n\nAdd the wrapper function __git_complete_symbol(), which encompasses\nthe condition for checking the presence of the tag file and filling\nCOMPREPLY, and accepts '--opt=val'-style options with default values\nthat keep callsites simpler.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n contrib/completion/git-completion.bash | 33 +++++++++++++++++++++++++++++----\n 1 file changed, 29 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 5cacb0e2e..e38178022 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1529,6 +1529,34 @@ __git_match_ctag () {\n \t\t\" \"$2\"\n }\n \n+# Complete symbol names from a tag file.\n+# Usage: __git_complete_symbol [<option>]...\n+# --tags=<file>: The tag file to list symbol names from instead of the\n+#                default \"tags\".\n+# --pfx=<prefix>: A prefix to be added to each symbol name.\n+# --cur=<word>: The current symbol name to be completed.  Defaults to\n+#               the current word to be completed.\n+# --sfx=<suffix>: A suffix to be appended to each symbol name instead\n+#                 of the default space.\n+__git_complete_symbol () {\n+\tlocal tags=tags pfx=\"\" cur_=\"${cur-}\" sfx=\" \"\n+\n+\twhile test $# != 0; do\n+\t\tcase \"$1\" in\n+\t\t--tags=*)\ttags=\"${1##--tags=}\" ;;\n+\t\t--pfx=*)\tpfx=\"${1##--pfx=}\" ;;\n+\t\t--cur=*)\tcur_=\"${1##--cur=}\" ;;\n+\t\t--sfx=*)\tsfx=\"${1##--sfx=}\" ;;\n+\t\t*)\t\treturn 1 ;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+\n+\tif test -r \"$tags\"; then\n+\t\t__gitcomp_direct \"$(__git_match_ctag \"$cur_\" \"$tags\" \"$pfx\" \"$sfx\")\"\n+\tfi\n+}\n+\n _git_grep ()\n {\n \t__git_has_doubledash && return\n@@ -1554,10 +1582,7 @@ _git_grep ()\n \n \tcase \"$cword,$prev\" in\n \t2,*|*,-*)\n-\t\tif test -r tags; then\n-\t\t\t__gitcomp_direct \"$(__git_match_ctag \"$cur\" tags \"\" \" \")\"\n-\t\t\treturn\n-\t\tfi\n+\t\t__git_complete_symbol && return\n \t\t;;\n \tesac\n \n-- \n2.12.1.498.gded7ead47\n\n"},{"id":"315100","messageId":"20170323153839.24283-4-szeder.dev@gmail.com","threadId":"45481","inReplyTo":"20170323153839.24283-1-szeder.dev@gmail.com","subject":"[PATCH 3/3] completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-03-23T15:38:39Z","receivedAt":"2017-03-23T15:39:05Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Just like in the case of search patterns for 'git grep', see 29eec71f2\n(completion: match ctags symbol names in grep patterns, 2011-10-21)),\na common thing to look for using 'git log -S', '-G' and '-L:' is the\nname of a symbol.\n\nTeach the completion for 'git log' to offer ctags symbol names after\nthese options, both in stuck and in unstuck forms.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n contrib/completion/git-completion.bash | 28 ++++++++++++++++++++++++++++\n 1 file changed, 28 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e38178022..48690ad1a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1687,6 +1687,19 @@ _git_log ()\n \tif [ -f \"$__git_repo_path/MERGE_HEAD\" ]; then\n \t\tmerge=\"--merge\"\n \tfi\n+\tcase \"$prev,$cur\" in\n+\t-L,:*:*)\n+\t\treturn\t# fall back to Bash filename completion\n+\t\t;;\n+\t-L,:*)\n+\t\t__git_complete_symbol --cur=\"${cur#:}\" --sfx=\":\"\n+\t\treturn\n+\t\t;;\n+\t-G,*|-S,*)\n+\t\t__git_complete_symbol\n+\t\treturn\n+\t\t;;\n+\tesac\n \tcase \"$cur\" in\n \t--pretty=*|--format=*)\n \t\t__gitcomp \"$__git_log_pretty_formats $(__git_pretty_aliases)\n@@ -1732,6 +1745,21 @@ _git_log ()\n \t\t\t\"\n \t\treturn\n \t\t;;\n+\t-L:*:*)\n+\t\treturn\t# fall back to Bash filename completion\n+\t\t;;\n+\t-L:*)\n+\t\t__git_complete_symbol --cur=\"${cur#-L:}\" --sfx=\":\"\n+\t\treturn\n+\t\t;;\n+\t-G*)\n+\t\t__git_complete_symbol --pfx=\"-G\" --cur=\"${cur#-G}\"\n+\t\treturn\n+\t\t;;\n+\t-S*)\n+\t\t__git_complete_symbol --pfx=\"-S\" --cur=\"${cur#-S}\"\n+\t\treturn\n+\t\t;;\n \tesac\n \t__git_complete_revlist\n }\n-- \n2.12.1.498.gded7ead47\n\n"},{"id":"315215","messageId":"20170324004018.rqtcrx7oewaooizh@sigill.intra.peff.net","threadId":"45481","inReplyTo":"20170323153839.24283-3-szeder.dev@gmail.com","subject":"Re: [PATCH 2/3] completion: extract completing ctags symbol names into helper function","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-24T00:40:19Z","receivedAt":"2017-03-24T00:51:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 23, 2017 at 04:38:38PM +0100, SZEDER Gábor wrote:\n\n> The previous commit doubled the number of __git_match_ctag()'s\n> positional parameters, and, to keep the position of existing\n> parameters for the sake of backwards compatibility, the prefix,\n> current word and suffix parameters ended up in different order than in\n> other functions accepting the same parameters.  Then there is a\n> condition checking the existence of the tag file before invoking this\n> function.\n> \n> We could still live with this if there were only a single callsite,\n> but the next commit will add a few more, so it's worth providing a\n> cleaner interface.\n> \n> Add the wrapper function __git_complete_symbol(), which encompasses\n> the condition for checking the presence of the tag file and filling\n> COMPREPLY, and accepts '--opt=val'-style options with default values\n> that keep callsites simpler.\n\nNice cleanup. The resulting code in _git_grep() is much more readable.\n\nI use the same completion for \"vim -t\". Now I can cheat and switch it to\n__git_complete_symbol. :)\n\n-Peff\n"},{"id":"315217","messageId":"20170324005256.ji2wijhyqnwbpp5t@sigill.intra.peff.net","threadId":"45481","inReplyTo":"20170323153839.24283-4-szeder.dev@gmail.com","subject":"Re: [PATCH 3/3] completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-24T00:52:56Z","receivedAt":"2017-03-24T00:53:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 23, 2017 at 04:38:39PM +0100, SZEDER Gábor wrote:\n\n> Just like in the case of search patterns for 'git grep', see 29eec71f2\n> (completion: match ctags symbol names in grep patterns, 2011-10-21)),\n> a common thing to look for using 'git log -S', '-G' and '-L:' is the\n> name of a symbol.\n> \n> Teach the completion for 'git log' to offer ctags symbol names after\n> these options, both in stuck and in unstuck forms.\n\nI think this makes sense and is an improvement over the status quo.\n\nThere are two gotchas with completing \"-L\" like this:\n\n  1. You still have to come up with the filename yourself for \"-L\".\n\n  2. The function name is actually a regex, so you can get bit when your\n     function name is a subset of another.\n\nI have a script (below) which makes this easier (and I complete its\nargument using the tags file).  It's probably too gross to even go into\ncontrib, but I thought I'd share.\n\n\"log -S\" sometimes benefits from limiting by filename, too, but it\ndepends what you're doing. I don't have a gross script for that. :)\n\n-- >8 --\n#!/usr/bin/env perl\nif (!@ARGV) {\n  print STDERR \"usage: git flog [options] <function>\\n\";\n  exit 1;\n}\n\nmy $func = pop @ARGV;\nmy $file = get_file_from_tags($func);\nmy $regex = '[^A-Za-z_]' . $func . '[^A-Za-z0-9_]';\nexec qw(git log), \"-L:$regex:$file\", @ARGV;\nexit 1;\n\nsub get_file_from_tags {\n  my $token = shift;\n\n  open(my $fh, '<', 'tags')\n    or die \"unable to open tags: $!\\n\";\n  while (<$fh>) {\n    chomp;\n\n    # this isn't exactly right, as the Ex command may contain\n    # embedded tabs, but it's accurate for the token and filename,\n    # which come before, and probably good enough to match extension fields\n    # which come after\n    my @fields = split /\\t/;\n\n    next unless $fields[0] eq $token;\n\n    # only look for functions; assumes your ctags uses the \"kind\"\n    # extension field. Note also that some implementations write the \"kind:\"\n    # header and some do not. This handles both.\n    next unless grep { /^(kind:\\s*)?f$/ } @fields;\n\n    # there may be more, but we don't have any way of disambiguating,\n    # so just return the first match\n    return $fields[1];\n  }\n\n  die \"unknown token: $token\\n\";\n}\n__END__\n"},{"id":"315220","messageId":"20170324003741.vrdhdh6ze7up5kng@sigill.intra.peff.net","threadId":"45481","inReplyTo":"20170323153839.24283-2-szeder.dev@gmail.com","subject":"Re: [PATCH 1/3] completion: put matching ctags symbol names directly into COMPREPLY","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-24T00:37:41Z","receivedAt":"2017-03-24T01:04:29Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 23, 2017 at 04:38:37PM +0100, SZEDER Gábor wrote:\n\n> The one-liner awk script in __git_match_ctag() listing ctags symbol\n> names for 'git grep <TAB>' is already smart enough to list only symbol\n> names matching the current word to be completed.\n> \n> Extend this helper function to accept prefix and suffix parameters to\n> be prepended and appended, respectively, to each listed symbol name in\n> the awk script, so its output won't require any additional processing\n> or filtering in the completion script before being handed over to\n> Bash.  Use the faster __gitcomp_direct() helper instead of\n> __gitcomp_nl() to fill the fully processed matching symbol names into\n> Bash's COMPREPLY array.\n\nSeems like an easy win (well, neglecting the other 14 patches that let\nto having gitcomp_direct).\n\nI never really noticed it as particularly slow in git.git, but faster is\nalways better if it comes cheaply.\n\n> Notes:\n>     It's still just a simple linear search through the tags file, so there\n>     are no miracles: it's still hopelessly, unusably slow e.g. in the\n>     Linux repository.\n\nI just tried \"git grep foo<Tab>\" in the kernel and it was pretty fast.\nBut then I tried \"git grep <Tab>\". Ouch. So it seems like it's not the\nawk matching that's slow, but everything that comes after (and is\ndependent on how much output it produces).\n\n-Peff\n"},{"id":"315762","messageId":"20170330100656.18766-1-szeder.dev@gmail.com","threadId":"45481","inReplyTo":"20170324005256.ji2wijhyqnwbpp5t@sigill.intra.peff.net","subject":"Re: [PATCH 3/3] completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-03-30T10:06:56Z","receivedAt":"2017-03-30T10:07:37Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nOn Fri, Mar 24, 2017 at 1:52 AM, Jeff King <peff@peff.net> wrote:\n> On Thu, Mar 23, 2017 at 04:38:39PM +0100, SZEDER Gábor wrote:\n> \n> > Just like in the case of search patterns for 'git grep', see 29eec71f2\n> > (completion: match ctags symbol names in grep patterns, 2011-10-21)),\n> > a common thing to look for using 'git log -S', '-G' and '-L:' is the\n> > name of a symbol.\n> > \n> > Teach the completion for 'git log' to offer ctags symbol names after\n> > these options, both in stuck and in unstuck forms.\n> \n> I think this makes sense and is an improvement over the status quo.\n> \n> There are two gotchas with completing \"-L\" like this:\n\nReordering your gotchas for convenience...\n\n>   2. The function name is actually a regex, so you can get bit when your\n>      function name is a subset of another.\n\n... and when the longer name comes first in the given file.  Yeah, I\nwas bitten by that a few of times, too :)\n\nHowever, I found that completing symbol names can be quite helpful in\nthis case, because now I see that there are longer symbol names\nstarting with what I'm looking for while typing/completing the\ncommand, and then I can just delete the trailing ':' and add a '\\(:'\nor '\\ :' depending on language and coding style right away.  Of course\nit doesn't help, if the function name in question is the suffix or a\nsubstring in the middle of another one, but that seems to be even\nrarer, or at least I've yet to come across such a case in practice.\n\n>   1. You still have to come up with the filename yourself for \"-L\".\n\nI was already quite satisfied that both the symbol name and the \nfilename can be TAB completed...  but right, in most cases the\nfunction name uniquely determines the filename, and even when it\ndoesn't, it still significantly limits the possibilities.  Hmhm.\n\nListing the funcname:filename together is not a good idea in my\nopinion.  A small change to __git_match_ctag()'s awk script can show\nwhy:\n\n-               /^${1//\\//\\\\/}/ { print pfx \\$1 sfx }\n+               /^${1//\\//\\\\/}/ { print pfx \\$1 \\\":\\\" \\$2 sfx }\n\nThe amount of text flooding my terminal on completion is just\noverwhelming (and I haven't even tried it in a Java project :), and it\nbreaks the \"helpful\" use-case with longer matching symbol names I\ndescribed above (it's much harder to see that there are longer\nmatching symbol names and I would have to backtrack the whole filename\nto modify the funcname).  It also breaks symbol name completion for\n'-G' and '-S', of course, so further changes would be necessary to\ndeal with that.\n\nOTOH, the proof-of-concept patch at the bottom shows how we could\nstart doing filename completion based on the ctags file, and I think\nit's really convenient to use.  Alas, it doesn't work when the\nfuncname is not on its own, e.g. ends with that disambiguating '\\(:'\nfrom above, and then Bash falls back to its own filename completion.\nHowever, if I may extrapolate from my ~/.bash_history, this would\nstill help the great majority of the cases.\n\n> I have a script (below) which makes this easier (and I complete its\n> argument using the tags file).  It's probably too gross to even go into\n> contrib, but I thought I'd share.\n\nPerhaps 'git log -L' could be enhanced to just DWIM when it gets only\n'-L:func:', and show the log of that function, wherever it is defined.\nSo instead of complaining about the missing filename, it could run\n'grep <func>' with a bit of magic to find the filename where the\nmatching function is declared, and search in the history of that file.\n\nBut then again, 'git log -L' could be enhanced in so many ways...\n\n\nGábor\n\n\n -- >8 --\n\nSubject: [PATCH] [PoC] completion: list only relevant filenames after 'git log\n -L:funcname:'\n\n---\n contrib/completion/git-completion.bash | 19 +++++++++++++++++--\n 1 file changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d6f25a7e0..8b58096e4 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1678,6 +1678,13 @@ __git_log_shortlog_options=\"\n __git_log_pretty_formats=\"oneline short medium full fuller email raw format:\"\n __git_log_date_formats=\"relative iso8601 rfc2822 short local default raw\"\n \n+__git_filename_for_symbol ()\n+{\n+\tlocal symbol=\"$1\" tags=\"$2\"\n+\n+\tawk \"/^${symbol//\\//\\\\}/ { print \\$2 }\" \"$tags\"\n+}\n+\n _git_log ()\n {\n \t__git_has_doubledash && return\n@@ -1689,7 +1696,11 @@ _git_log ()\n \tfi\n \tcase \"$prev,$cur\" in\n \t-L,:*:*)\n-\t\treturn\t# fall back to Bash filename completion\n+\t\tlocal symbol=\"${cur#:}\"\n+\t\tsymbol=\"${symbol%%:*}\"\n+\t\t__gitcomp_nl \"$(__git_filename_for_symbol \"$symbol\" tags)\" \\\n+\t\t\t\"\" \"${cur#:$symbol:}\"\n+\t\treturn\n \t\t;;\n \t-L,:*)\n \t\t__git_complete_symbol --cur=\"${cur#:}\" --sfx=\":\"\n@@ -1746,7 +1757,11 @@ _git_log ()\n \t\treturn\n \t\t;;\n \t-L:*:*)\n-\t\treturn\t# fall back to Bash filename completion\n+\t\tlocal symbol=\"${cur#-L:}\"\n+\t\tsymbol=\"${symbol%%:*}\"\n+\t\t__gitcomp_nl \"$(__git_filename_for_symbol \"$symbol\" tags)\" \\\n+\t\t\t\"\" \"${cur#-L:$symbol:}\"\n+\t\treturn\n \t\t;;\n \t-L:*)\n \t\t__git_complete_symbol --cur=\"${cur#-L:}\" --sfx=\":\"\n-- \n2.12.2.453.g223d29900\n\n"},{"id":"316001","messageId":"20170401085058.y7u73x6beqgnhrcb@sigill.intra.peff.net","threadId":"45481","inReplyTo":"20170330100656.18766-1-szeder.dev@gmail.com","subject":"Re: [PATCH 3/3] completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-04-01T08:50:58Z","receivedAt":"2017-04-01T08:51:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 30, 2017 at 12:06:56PM +0200, SZEDER Gábor wrote:\n\n> >   1. You still have to come up with the filename yourself for \"-L\".\n> \n> I was already quite satisfied that both the symbol name and the \n> filename can be TAB completed...  but right, in most cases the\n> function name uniquely determines the filename, and even when it\n> doesn't, it still significantly limits the possibilities.  Hmhm.\n\nI find that I often forget which file a function is defined in,\nespecially in Git's code base (where it sometimes feels somewhat\nrandom :) ).\n\n> OTOH, the proof-of-concept patch at the bottom shows how we could\n> start doing filename completion based on the ctags file, and I think\n> it's really convenient to use.  Alas, it doesn't work when the\n> funcname is not on its own, e.g. ends with that disambiguating '\\(:'\n> from above, and then Bash falls back to its own filename completion.\n> However, if I may extrapolate from my ~/.bash_history, this would\n> still help the great majority of the cases.\n\nYeah, I think that would go a long way to solving my problem.\n\n> > I have a script (below) which makes this easier (and I complete its\n> > argument using the tags file).  It's probably too gross to even go into\n> > contrib, but I thought I'd share.\n> \n> Perhaps 'git log -L' could be enhanced to just DWIM when it gets only\n> '-L:func:', and show the log of that function, wherever it is defined.\n> So instead of complaining about the missing filename, it could run\n> 'grep <func>' with a bit of magic to find the filename where the\n> matching function is declared, and search in the history of that file.\n> \n> But then again, 'git log -L' could be enhanced in so many ways...\n\nYes, that sounds even nicer.\n\n-Peff\n"}]}