tj.git-extras/helper
Vijay Misal 9ccb605c18
fix(is-git-repo): recognize bare repositories
is_git_repo() used `git rev-parse --show-toplevel` to detect whether
the current directory is inside a git repository. --show-toplevel
fails for bare repositories since they have no working tree, so every
command that relies on this shared helper (e.g. `git browse`) reports
"Not a git repo!" when run from inside a bare repo, even though it
plainly is one.

Switch to `git rev-parse --git-dir`, which succeeds for both normal
and bare repositories and keeps the existing "not a repo" behavior
for non-repo directories.

Fixes #1238, reported and LGTM'd by maintainers there with this exact
fix; no PR had been opened for it yet.

Adds tests/is-git-repo.bats covering: a normal repo, a bare repo, and
a plain (non-repo) directory.
2026-08-15 07:44:48 +05:30
..
git-extra-utility Consider init.defaultBranch in git_extra_default_branch, changed default 2021-12-29 13:57:12 +01:00
has-git-commit Check commit existed before running some commands 2017-01-27 18:58:16 +08:00
is-git-repo fix(is-git-repo): recognize bare repositories 2026-08-15 07:44:48 +05:30
reset-env fix: No longer pollute env with GREP_OPTIONS 2023-01-30 21:00:39 -08:00