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

Re: [PATCH v1 1/2] worktree: do not pass strbuf by value

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 9, 2026, 14:48 UTC
Message-ID
<xmqqh5qp6oun.fsf@gitster.g>
In-Reply-To
<20260308180359.31188-2-deveshigurgaon@gmail.com>
Deveshi Dwivedi <deveshigurgaon@gmail.com> writes:
> The function only needs the string values, not the strbuf machinery.
> Switch it to take const char * and update all callers to pass .buf.
Makes perfect sense.  Thanks for noticing and fixing these.
Show 7 quoted lines
> -		write_worktree_linking_files(dotgit, gitdir, use_relative_paths);
> +		write_worktree_linking_files(dotgit.buf, gitdir.buf, use_relative_paths);
> ...
> -void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir,
> +void write_worktree_linking_files(const char *dotgit, const char *gitdir,
>  				  int use_relative_paths)
>  {

This updated function signature makes it plenty clear that the function does not modify anything in gitdir, so the caller shouldn't be affected. Nice.

Previous: Deveshi DwivediNext: Jeff King
Message 3 of 8 in “avoid unnecessary strbuf_split*() and strbuf-by-value usage”
  1. 0/2 avoid unnecessary strbuf_split*() and strbuf-by-value usageDeveshi Dwivedi, Mar 8, 2026
  2. 1/2 worktree: do not pass strbuf by valueDeveshi Dwivedi, Mar 8, 2026
  3. Junio C HamanoMar 9, 2026
  4. coccinelle to catch pass-by-value?, was: [PATCH v1 1/2] worktree: do not pass strbuf by valueJeff King, Mar 9, 2026
  5. 2/2 list-objects-filter-options: avoid strbuf_split_str()Deveshi Dwivedi, Mar 8, 2026
  6. Junio C HamanoMar 9, 2026
  7. Jeff KingMar 9, 2026
  8. Jeff KingMar 9, 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.