Commit graph

9 commits

Author SHA1 Message Date
Vijay Misal dbf68bac59
fix(is-git-repo): recognize bare repositories (#1266)
* 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.

* Fix ruff lint failures in scripts/checkstyle.py

This PR's new Ruff CI job surfaced pre-existing style issues (unsorted
imports, deprecated typing.List/Dict, nested ifs, bare exit()) in
checkstyle.py. Cleaned these up so the newly added lint job passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 14:15:48 +08:00
Edwin Kofler 82daeb7c94
fix: No longer pollute env with GREP_OPTIONS 2023-01-30 21:00:39 -08:00
Tobias Fendin b2743d785f Consider init.defaultBranch in git_extra_default_branch, changed default
branch to main.
2021-12-29 13:57:12 +01:00
spacewander 964663f1a4 change: migrate default branch
Close #877.
2020-09-23 16:19:41 +08:00
Xavier Krantz 80e93704eb Fixed mktemp template to support busybox (and Alpine linux) 2018-02-05 12:33:18 +01:00
spacewander 64b4a599e8 Check commit existed before running some commands 2017-01-27 18:58:16 +08:00
Kylie McClain 336501382e helper/reset-env: helper to prevent GREP_OPTIONS from causing issues 2015-04-08 18:50:41 -04:00
spacewander 32aee50bc6 extra mktemp into git_extra_mktemp
now we can put all utility functions to git-extra-utility
2015-02-05 14:22:49 +08:00
spacewander d9724f3b46 use mixin to add 'is git repo' check for some commands
When those commands are used outside a git repo, 'Not a git repo!' will be
printed to stderr
2014-09-25 00:41:43 +08:00