Skip to content

optimize git status method with first commit check #1431

@dualc

Description

@dualc

Problem

The status method always uses empty tree SHA comparison even for repositories with existing commits, which is unnecessary.
this command git diff --numstat -z --cached 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is very slow when git proejct is large and is in filesystem like NFS

https://github.com/jupyterlab/jupyterlab-git/blob/861374ffa6b2edc382d37eec6185eca3b1695787/jupyterlab_git/git.py#L489C15-L489C21

Solution

Add _is_first_commit helper method to detect empty repositories and only use empty tree SHA when it's the first commit.

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