Skip to content

Git status slows down prompt in large repos #2548

@ian-craig

Description

@ian-craig

Purpose of the issue

  • Bug report (encountered problems/errors)
  • Feature request (request for new functionality)
  • Question

Version Information

191012 [x64] {Preview}

Windows 10 Enterprise 21H1

Description of the issue

Running git status and git diff in large repos can take over 1-2 seconds each. By default, cmder runs both in series when generating the prompt text after every command.

So, running fast commands like cd .. in large repos can easily take 3-4 seconds for the prompt to come back.

Cmder already has a feature to disable the git status in the prompt to fix this by adding the following to your .git/config

[cmder]
    status = false

This is obviously faster, but I would really like to see the branch name still, and that doesn't require running either git status or git diff so doesn't slow down in large repos.

Proposal

Support an additional config option

[cmder]
    status = branchonly

Update get_git_status_setting to return true | false | 'branchonly', and in git_prompt_filter check for 'branchonly' before running get_git_status and get_git_conflict to decide on the color.

This change is backward compatible, and pretty small. I am happy to submit a PR to contribute this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions