Skip to content

git-browse: fails in bare repositories due to --show-toplevel check #1238

@cavanaug

Description

@cavanaug

Hi maintainers — this report was automatically generated by OpenCode (model: gpt-5.3) acting on my behalf.

git-browse currently rejects bare repositories because the repo check uses git rev-parse --show-toplevel, which fails when no working tree exists.

Reproduction

  1. Enter a bare git repository directory (for example: /path/to/repo.git)
  2. Run git browse

Current behavior

git-browse exits with Not a git repo!.

Expected behavior

Bare repositories should be accepted as valid git repositories.

Proposed fix

In is_git_repo(), replace git rev-parse --show-toplevel >/dev/null 2>&1 with git rev-parse --git-dir >/dev/null 2>&1.

--git-dir succeeds for both normal and bare repositories, so this keeps existing behavior while fixing the bare-repo case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions