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

[PATCH 1/4] worktree: drop pointless strbuf_release()

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 31, 2020, 23:32 UTC
Message-ID
<20200731233214.22131-2-sunshine@sunshineco.com>
In-Reply-To
<20200731233214.22131-1-sunshine@sunshineco.com>

The content of this strbuf is unconditionally detached several lines before the strbuf_release() and the strbuf is never touched again after that point.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
Notes:
    I'm on the fence about this change. On the one hand, I spent extra
    cycles studying the code to determine if the strbuf was used again
    after being detached. On the other hand, the strbuf_release() at the
    end of the function protects against a leak if someone ever inserts
    code which re-uses the strbuf. So, I wouldn't be bothered if this
    patch is dropped from the series.
 worktree.c | 2 --
 1 file changed, 2 deletions(-)
diff --git a/worktree.c b/worktree.c
index cba2e54598..c0df5e2c79 100644
--- a/worktree.c
+++ b/worktree.c
@@ -66,8 +66,6 @@ static struct worktree *get_main_worktree(void)
 	worktree->is_bare = (is_bare_repository_cfg == 1) ||
 		is_bare_repository();
 	add_head_info(worktree);
-
-	strbuf_release(&worktree_path);
 	return worktree;
 }
 
-- 
2.28.0.203.gce1f2e0ef1
Previous: Eric Sunshine
Message 5 of 5 in “worktree: cleanups & simplification”
  1. 0/4 worktree: cleanups & simplificationEric Sunshine, Jul 31, 2020
  2. 3/4 worktree: drop bogus and unnecessary path mungingEric Sunshine, Jul 31, 2020
  3. 2/4 worktree: drop unused code from get_linked_worktree()Eric Sunshine, Jul 31, 2020
  4. 4/4 worktree: retire special-case normalization of main worktree pathEric Sunshine, Jul 31, 2020
  5. 1/4 worktree: drop pointless strbuf_release()Eric Sunshine, Jul 31, 2020

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.