Skip to content

fix(git): show a clean message when a directory is not a repository - #19

Merged
whaclaw-bot merged 1 commit into
code0xff:devfrom
whackur:dev
Aug 4, 2026
Merged

fix(git): show a clean message when a directory is not a repository#19
whaclaw-bot merged 1 commit into
code0xff:devfrom
whackur:dev

Conversation

@whaclaw-bot

Copy link
Copy Markdown
Collaborator

저장소가 아닌 디렉터리를 열었을 때 상태바가 보여주던 두 가지 문제를 함께 고칩니다. 하나만 고치면 나머지가 회귀하므로 한 커밋에 담았습니다.

1. libgit2 내부 진단이 그대로 노출됐다

git error: not a git repository: could not find repository at '/opt/data/.config/jcode'; class=Repository (6); code=NotFound (-3)

git2 0.21의 Display는 message 뒤에 ; class=…; code=…를 붙입니다. 사용자가 할 수 있는 일이 없고, 경로는 이미 앞부분에 있습니다.

format_discover_errorErrorClass::Repository + ErrorCode::NotFound 조합에서만 message()를 쓰고, 나머지(권한, 손상, 인증 등)는 to_string()을 그대로 유지합니다. bce0239가 clone 실패에서 git의 진단을 살리기로 한 결정을 뒤집지 않기 위한 것으로, 문자열 매칭이 아니라 class/code로 갈랐습니다.

discover 호출부 두 곳(diff_load::with_repo, commit_log_fetch의 워커 스레드)이 같은 헬퍼를 거치므로 어느 경로로 실패해도 문구가 같습니다. 이전에는 서로 달랐습니다.

2. 에러가 떠 있는 동안 현재 경로가 화면에서 사라졌다

notice_or_candidates가 repo 헤더를 통째로 대체했습니다. 저장소가 아닌 디렉터리는 사용자가 다른 경로를 열기 전까지 유지되는 상태라, 경로가 영구적으로 가려졌습니다.

이제 경로(회색 굵게)와 notice(빨강 굵게)가 한 줄에 함께 렌더됩니다. 행을 새로 만들지 않았습니다 — 행이 생기고 사라지면 열려 있는 모든 PTY가 리사이즈되기 때문입니다(recovery_chip 주석의 근거와 동일).

폭이 모자라면 경로를 남기고 notice를 로 자릅니다. 남은 자리가 한 칸뿐이어도 는 남겨서, 잘렸다는 사실이 보이게 했습니다 — candidate_line+N more와 같은 원칙입니다.

검증

  • format_discover_error 단위 테스트: NotFound/Repository에서 class·code 제거, 경로 보존, 다른 class는 전체 진단 유지.
  • notice 행 렌더 테스트: 경로+notice 동시 표시, 좁은 폭 절단, 한 칸만 남았을 때 유지, 자동완성 후보·헤더 폴백 무회귀.
  • cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test (1546 passed / 0 failed) 통과.

Repository::discover failing with NotFound+Repository is the only error
whose libgit2 class/code tail ('; class=Repository (6); code=NotFound
(-3)') adds nothing the user can act on — the path is already in the
message prefix.  A shared format_discover_error helper strips that tail
only for this class/code pair; all other errors (permission, corruption,
auth, …) keep the full diagnostic so clone-failure and other rich
git2::Error fields remain visible, preserving the decision in bce0239.

Both discover call sites — with_repo in diff_load and the commit-log
worker thread in commit_log_fetch — now route through the helper so the
status bar shows the same wording either way.

The notice row also stopped showing the repo path while a persistent
git error was up: notice_or_candidates replaced the entire repo header.
A non-repository directory is a persistent state, so the path was
permanently hidden.  The notice now renders alongside the path on the
same line — path in gray bold, notice in red bold — and when the two do
not fit the path is kept and the notice is truncated with an ellipsis.
No new row is added, so open PTY panes are not resized.
@whaclaw-bot
whaclaw-bot merged commit 8543b5f into code0xff:dev Aug 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants