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

Git status performance on PS (command prompt)

From
MGMark Gaiser <markg85@gmail.com>
Date
Feb 12, 2017, 15:53 UTC
Message-ID
<CAPd6JnGC3yeDo_sB+H+UKvh-PbiC2qySC=EbaRNLbkkwYkJM4A@mail.gmail.com>
Hi,

I'm using ZSH with some fancy prompt. In that prompt is also a quick git status overview (some symbols indicating if the branch is up to date, if there are changes, etc..

The commands that are being executed to fetch the information:

For the file status: git status --porcelain

For the repository status: git status --porcelain -b

On small repositories (or even medium sized ones) this is fast, no problems there. But on larger repositories this is notably slow (i'm taking QtBase as an example now, but the same is true for much of the Qt repositories, or chromium or even the linux kernel itself). It's no problem if it's slow when you do "git status" on the command line. That can be expected to take a little while on large repositories. But in zsh prompts the call to git isn't asynchronous [1] so any slowdown will be noticed as the prompt simply doesn't completely show till after the command.

I did a bit of profiling in git to figure out where this slowdown comes from. Callgrind tells me that "read_directory_recursive" takes up ~62% of the time. Within that call the function "last_exclude_matching_from_list" takes up 49% of the time it takes to run "git status --porcelain -b".

I don't really know how this code is supposed to work (i'm a git user, not a git developer), so i hope someone might be able to investigate this further. I can however apply patches to git locally and help out with testing.

Also, is there perhaps a command out there that might be better suited for the git status i want to show in the prompt? What i have now is merely from one of the oh-my-zsh themes.

Best regards, Mark

p.s. please keep me in cc, i'm not subscribed to this list.

[1] Most prompts don't have async support, but there are prompts that do provide this: https://github.com/sindresorhus/pure I guess that would be a better solution for me in the short term. Still, having the status being made faster would be beneficial.

Next: brian m. carlson
Message 1 of 3 in “Git status performance on PS (command prompt)”
  1. Mark GaiserFeb 12, 2017
  2. brian m. carlsonFeb 12, 2017
  3. Christian CouderFeb 13, 2017

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.