[PATCH 0/4] worktree add: worktree_basename() fixes
- From
René Scharfe <l.s.r@web.de>
- Date
- Aug 25, 2026, 18:03 UTC
- Message-ID
- <20260825180350.2099-1-l.s.r@web.de>
Here's my take on solving the issues addressed by [1]. I'd prefer a reroll of that series, but in case it won't come we can use this one.
The first fix is the most important one, avoiding potential data loss. The third one starts to accept paths with trailing path separators, the fourth one simplifies the code.
worktree add: don't read out of bounds in worktree_basename() worktree add: reject separator-only path worktree add: trim slashes when deriving branch name from path worktree add: let worktree_basename() return string copy
builtin/worktree.c | 33 ++++++++++++++------------------- t/t2400-worktree-add.sh | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 19 deletions(-)
[1] https://lore.kernel.org/git/pull.2187.git.1784978348.gitgitgadget@gmail.com/
-- 2.55.0