git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 9/10] Allow completion of --committer and --author arguments to git log.

From
Shawn Pearce <spearce@spearce.org>
Date
Nov 27, 2006, 20:49 UTC
Message-ID
<20061127204913.GB7331@spearce.org>
In-Reply-To
<7vy7pwfxp8.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 13 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > This is just a cute hack, but we can (easily) complete the parameter
> > to --author or --committer in bash by asking for all possible authors
> > or committers in this project from git log and offering them up as
> > valid choices.
> 
> Easily but slowly ;-).  Try this in the kernel repository
> 
> 	git log --author=Andre<TAB>
> 
> and watch the paint dry.  You might want to have an extra shell
> to run top before you hit the TAB key.

When I put that in there I was thinking about how slowly that would run on the kernel repository. But I think its useful for git commit --author, even if it is a tad turtleish. I'm considering creating a cache of names under .git/ and only dynamically generate the log entries which are newer than the cache head. That way we're only wading through the most recent commits to build up the completion set.

Apparently the bottleneck is bash. If I add in | sort | uniq to the end of the sed then I can generate author completions in about 7 seconds for the kernel repository. Without them it is taking about 30 seconds. (Both approximate as I just counted it out in my head.)

You can also see this in top. We spend a bit of time in both git and sed, then suddenly bash takes over for a while as it makes the resulting list unique.

Using perl (instead of sed | sort | uniq) appears to improve things slightly, but I'm getting some odd results that I don't have time to debug right now.

> It indeed is cute, but I think most people would wonder if the
> terminal went dead, especially without any progress indicators.
Yes.  And in completion support mode you cannot give progress.  :-(
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 14 of 19 in “Hide plumbing/transport commands from bash completion.”
  1. 2/10 Hide plumbing/transport commands from bash completion.Shawn O. Pearce, Nov 27, 2006
  2. 3/10 Teach bash how to complete options for git-name-rev.Shawn O. Pearce, Nov 27, 2006
  3. 4/10 Add current branch in PS1 support to git-completion.bash.Shawn O. Pearce, Nov 27, 2006
  4. SeanNov 27, 2006
  5. 5/10 Teach bash how to complete git-format-patch.Shawn O. Pearce, Nov 27, 2006
  6. Jakub NarebskiNov 27, 2006
  7. 6/10 Teach bash how to complete git-cherry-pick.Shawn O. Pearce, Nov 27, 2006
  8. 7/10 Teach bash how to complete git-rebase.Shawn O. Pearce, Nov 27, 2006
  9. 8/10 Teach bash about git log/show/whatchanged options.Shawn O. Pearce, Nov 27, 2006
  10. 9/10 Allow completion of --committer and --author arguments to git log.Shawn O. Pearce, Nov 27, 2006
  11. Nicolas VilzNov 27, 2006
  12. Shawn PearceNov 27, 2006
  13. Junio C HamanoNov 27, 2006
  14. Shawn PearceNov 27, 2006
  15. 10/10 Support bash completion of refs/remote.Shawn O. Pearce, Nov 27, 2006
  16. Shawn PearceNov 27, 2006
  17. SeanNov 27, 2006
  18. Shawn PearceNov 27, 2006
  19. SeanNov 27, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.