git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Next: René Scharfe
Message 1 of 10 in “worktree add: worktree_basename() fixes”
  1. 0/4 worktree add: worktree_basename() fixesRené Scharfe, Aug 25, 2026
  2. 4/4 worktree add: let worktree_basename() return string copyRené Scharfe, Aug 25, 2026
  3. Junio C HamanoAug 25, 2026
  4. René ScharfeAug 26, 2026
  5. Junio C HamanoAug 26, 2026
  6. Junio C HamanoAug 31, 2026
  7. 3/4 worktree add: trim slashes when deriving branch name from pathRené Scharfe, Aug 25, 2026
  8. Junio C HamanoAug 25, 2026
  9. 1/4 worktree add: don't read out of bounds in worktree_basename()René Scharfe, Aug 25, 2026
  10. 2/4 worktree add: reject separator-only pathRené Scharfe, Aug 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.