Repository: starship/starship
File: src/modules/git_status.rs (Rust)

Code before:
    }

    pub fn get_untracked(&self) -> Option<usize> {
        self.get_repo_status().map(|data| data.untracked)
    }

    pub fn get_typechanged(&self) -> Option<usize> {
        self.get_repo_status().map(|data| data.typechanged)
    }
}

/// Gets the number of files in various git states (staged, modified, deleted, etc...)
fn get_repo_status(
    context: &Context,
    repo: &context::Repo,
    config: &GitStatusConfig,
) -> Option<RepoStatus> {
    log::debug!("New repo status created");

    let mut repo_status = RepoStatus::default();

    // can't run git status against a bare repo
    if repo.repo.work_tree.is_none() {
        log::debug!("This is a bare repository, not generating git status");
        return Some(repo_status);
    }
    let mut args = vec!["status", "--porcelain=2"];

    // for performance reasons, only pass flags if necessary...
    let has_ahead_behind = !config.ahead.is_empty() || !config.behind.is_empty();
    let has_up_to_date_diverged = !config.up_to_date.is_empty() || !config.diverged.is_empty();
    if has_ahead_behind || has_up_to_date_diverged {
        args.push("--branch");
    }

    // ... and add flags that omit information the user doesn't want
    let has_untracked = !config.untracked.is_empty();
    if !has_untracked {
        args.push("--untracked-files=no");
    }
    if config.ignore_submodules {
        args.push("--ignore-submodules=dirty");
    } else if !has_untracked {
        args.push("--ignore-submodules=untracked");
    }

    let status_output = repo.exec_git(context, &args)?;
    let statuses = status_output.stdout.lines();

    statuses.for_each(|status| {
        if status.starts_with("# branch.ab ") {

Review comment (suggestion):
This should probably check if the repository kind is `Bare` per the git config. Since `git status` ignores bare repositories in general, perhaps also perform this check earlier.

Code after:
        self.get_repo_status().map(|data| data.modified)
    }

    pub fn get_staged(&self) -> Option<usize> {
        self.get_repo_status().map(|data| data.staged)
    }

    pub fn get_untracked(&self) -> Option<usize> {
        self.get_repo_status().map(|data| data.untracked)
    }

    pub fn get_typechanged(&self) -> Option<usize> {
        self.get_repo_status().map(|data| data.typechanged)
    }
}

/// Gets the number of files in various git states (staged, modified, deleted, etc...)
fn get_repo_status(
    context: &Context,
    repo: &context::Repo,
    config: &GitStatusConfig,
) -> Option<RepoStatus> {
    log::debug!("New repo status created");

    let mut repo_status = RepoStatus::default();
    let mut args = vec!["status", "--porcelain=2"];

    // for performance reasons, only pass flags if necessary...
    let has_ahead_behind = !config.ahead.is_empty() || !config.behind.is_empty();
    let has_up_to_date_diverged = !config.up_to_date.is_empty() || !config.diverged.is_empty();
    if has_ahead_behind || has_up_to_date_diverged {
        args.push("--branch");
    }

    // ... and add flags that omit information the user doesn't want
    let has_untracked = !config.untracked.is_empty();
    if !has_untracked {
        args.push("--untracked-files=no");
    }
    if config.ignore_submodules {
        args.push("--ignore-submodules=dirty");
    } else if !has_untracked {
        args.push("--ignore-submodules=untracked");
    }

    let status_output = repo.exec_git(context, &args)?;
    let statuses = status_output.stdout.lines();

    statuses.for_each(|status| {
        if status.starts_with("# branch.ab ") {
            repo_status.set_ahead_behind(status);