diff options
| author | hathach <[email protected]> | 2026-04-29 12:59:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-04-29 12:59:40 +0700 |
| commit | 17572a960a53e27ffa07d7d7fda3486bfcc95a2d (patch) | |
| tree | 7623400e9d0bccb646d9369d3b4cffbf2ea83cde | |
| parent | 6ba8aeff1603ae54e0fcf2309b0f19e335a16cdc (diff) | |
metrics_compare_base: use git worktree add --detach
`git worktree add <path> <branch>` fails if <branch> is already checked out
elsewhere (main repo, another worktree). --detach checks out the ref at a
detached HEAD instead of claiming the branch, making the script work
regardless of what is currently checked out.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
| -rw-r--r-- | tools/metrics_compare_base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/metrics_compare_base.py b/tools/metrics_compare_base.py index a541dae79..799a96800 100644 --- a/tools/metrics_compare_base.py +++ b/tools/metrics_compare_base.py @@ -215,7 +215,11 @@ def main(): print(f'[1/5] Setting up {args.base_branch} worktree...') if os.path.isdir(worktree_dir): run(['git', '-C', TINYUSB_ROOT, 'worktree', 'remove', '--force', worktree_dir]) - ret = run(['git', '-C', TINYUSB_ROOT, 'worktree', 'add', worktree_dir, args.base_branch]) + # --detach: check out the ref at a detached HEAD instead of trying to claim the + # branch. Lets us add a worktree of `master` even if master is already checked + # out elsewhere (main repo, another worktree). + ret = run(['git', '-C', TINYUSB_ROOT, 'worktree', 'add', '--detach', + worktree_dir, args.base_branch]) if ret.returncode != 0: print(f'Error creating worktree: {ret.stderr}') sys.exit(1) |
