Repository navigation
fix: propagate error from is_bare() instead of panicking - #1221
Merged
Merged
Conversation
bendrucker
marked this pull request as ready for review
February 27, 2026 04:34
Contributor
Author
|
The // Submodules: --show-toplevel succeeds (git has explicit core.worktree config)
if let Ok(out) = Cmd::new("git")
.args(["rev-parse", "--show-toplevel"])
.current_dir(&self.git_common_dir)
.context(path_to_logging_context(&self.git_common_dir))
.run()
&& out.status.success()
{
return PathBuf::from(String::from_utf8_lossy(&out.stdout).trim());
}
// --show-toplevel failed:
// 1. Bare repos (no working tree) → git_common_dir IS the repo
// 2. Normal repos from inside .git → parent is the repo
match self.is_bare() {
Ok(true) | Err(_) => self.git_common_dir.clone(),
Ok(false) => self.git_common_dir
.parent()
.expect("Git directory has no parent")
.to_path_buf(),
}Figured I'd ask before implementing (or not). |
Owner
|
thanks a lot @bendrucker ! nice spot I will merge this @worktrunk-bot could you draft the follow-up change for our review please? |
Closed
worktrunk-bot
pushed a commit
that referenced
this pull request
Feb 27, 2026
Move `--show-toplevel` check before `is_bare()` in `repo_path()` and treat `is_bare()` errors as bare. Previously `unwrap_or(false)` meant a git timeout on a bare repo would fall through to `parent()`, caching a nonsensical path. Now `Err(_)` maps to `git_common_dir`, which is correct for bare repos. For normal repos a git timeout is a bigger problem anyway, so the wrong cached path is moot. Follow-up to #1221. Co-Authored-By: Claude Opus 4.6 <[email protected]>
3 of 4 tasks
Collaborator
|
Follow-up PR: #1225 Restructures |
worktrunk-bot
pushed a commit
that referenced
this pull request
Feb 27, 2026
The `claude-code-action` requires write permission by default, which blocks reviews on PRs from external contributors (e.g. #1221). Add `allowed_non_write_users: "*"` to bypass this check. This is safe for the review workflow since it uses `pull_request_target` (runs base branch code) and the prompt is controlled by the workflow. Closes #1224 Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
is_bare()panics whengit rev-parse --is-bare-repositorytimes out because it uses.expect()on theCmd::run()result. This changes the return type toResult<bool>so the error propagates instead.I don't know why
gitwas slow in this case, but it was:Changes
is_bare()returnsResult<bool>usingget_or_try_init(doesn't cache errors, so transient timeouts retry on next call)repo_path()usesunwrap_or(false)since it returns&PathviaOnceCell<PathBuf>with many callers. CascadingResultwould be disproportionate, and the non-bare fallback handles normal repos correctlyResult, so they just add?