Skip to content

Resolve project root in git worktrees for format - #4

Merged
nrnhines merged 1 commit into
masterfrom
hines/source-dir-worktree
Aug 31, 2026
Merged

nrnhines merged 1 commit into
masterfrom
hines/source-dir-worktree

Conversation

@nrnhines

Copy link
Copy Markdown
Member

Summary

  • bin/format (and therefore ninja format / ninja format-pr in NEURON) looked up .bbp-project.yaml via source_dir(), which used parent(git-dir) as the superproject working tree.
  • That is wrong in a linked git worktree, where git-dir is <primary>/.git/worktrees/<name>. The driver then searched .git/worktrees for the yaml, enabled no tools, and exited 0 — a silent no-op. Same class of checkout: git clone --separate-git-dir.
  • Use git rev-parse --show-superproject-working-tree (Git 2.13+; empty when not a submodule). Fall back to --show-toplevel of the module parent on older git. Never treat parent(git-dir) as a checkout path.
  • Same change in cpp/cmake/cpplib.py. Unit tests cover standalone, primary-clone submodule, linked worktree, and cwd-inside-module.

Follow-up: after this merges, NEURON will pin external/coding-conventions at the merged master tip (same two-repo order as #3 / nrn #3783). Black version / Python 3.14 is a separate issue and is not in this PR.

Test plan

  • pytest-3 --capture=no (CI) — new dev/test_lib.py cases
  • Local worktree: PYENV_VERSION=3.12 bin/format -q --lang python <one .py> from an nrn git worktree add checkout prints the Black version banner and does not print No tool enabled for task format
  • Local primary clone: same command still finds .bbp-project.yaml
  • cd into this repo and ./bin/format -q still treats coding-conventions as the project (existing development path)
  • CI on this PR: python test / format / flake8

source_dir() used parent(git-dir) as the superproject working tree.
That is wrong in a linked git worktree, where git-dir is
<primary>/.git/worktrees/<name>, so ninja format looked for
.bbp-project.yaml under .git/worktrees and enabled no tools.

Use git rev-parse --show-superproject-working-tree (Git 2.13+),
falling back to --show-toplevel of the module parent. Never treat
parent(git-dir) as a checkout path.
@nrnhines
nrnhines merged commit 4bb2c5f into master Aug 31, 2026
10 checks passed
@nrnhines
nrnhines deleted the hines/source-dir-worktree branch August 31, 2026 14:14
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.

1 participant