{"thread":{"id":"52876","subject":"[PATCH] worktree: drop unused code from get_main_worktree()","startedAt":"2020-02-24T02:00:39Z","lastAt":"2020-02-24T20:20:19Z","messageCount":3,"participants":["Eric Sunshine","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"392370","messageId":"20200224015935.19190-1-sunshine@sunshineco.com","threadId":"52876","inReplyTo":null,"subject":"[PATCH] worktree: drop unused code from get_main_worktree()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-02-24T01:59:35Z","receivedAt":"2020-02-24T02:00:39Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"This code has been unused since fa099d2322 (worktree.c: kill parse_ref()\nin favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n\nJust something I noticed while reviewing a patch[1] on the mailing list.\n\n[1]: https://lore.kernel.org/git/8718facbc951614f19407afa6ca8d6110507483d.1582484231.git.gitgitgadget@gmail.com/\n\n worktree.c | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/worktree.c b/worktree.c\nindex 5b4793caa3..33c2655534 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -47,15 +47,12 @@ static void add_head_info(struct worktree *wt)\n static struct worktree *get_main_worktree(void)\n {\n \tstruct worktree *worktree = NULL;\n-\tstruct strbuf path = STRBUF_INIT;\n \tstruct strbuf worktree_path = STRBUF_INIT;\n \n \tstrbuf_add_absolute_path(&worktree_path, get_git_common_dir());\n \tif (!strbuf_strip_suffix(&worktree_path, \"/.git\"))\n \t\tstrbuf_strip_suffix(&worktree_path, \"/.\");\n \n-\tstrbuf_addf(&path, \"%s/HEAD\", get_git_common_dir());\n-\n \tworktree = xcalloc(1, sizeof(*worktree));\n \tworktree->path = strbuf_detach(&worktree_path, NULL);\n \t/*\n@@ -69,7 +66,6 @@ static struct worktree *get_main_worktree(void)\n \t\tis_bare_repository();\n \tadd_head_info(worktree);\n \n-\tstrbuf_release(&path);\n \tstrbuf_release(&worktree_path);\n \treturn worktree;\n }\n-- \n2.25.1.526.gf05a752211\n\n"},{"id":"392393","messageId":"20200224064049.GD1015967@coredump.intra.peff.net","threadId":"52876","inReplyTo":"20200224015935.19190-1-sunshine@sunshineco.com","subject":"Re: [PATCH] worktree: drop unused code from get_main_worktree()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-02-24T06:40:49Z","receivedAt":"2020-02-24T06:40:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Feb 23, 2020 at 08:59:35PM -0500, Eric Sunshine wrote:\n\n> This code has been unused since fa099d2322 (worktree.c: kill parse_ref()\n> in favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.\n\nLooks obviously correct, unless we are depending on some side effect of\nget_git_common_dir(). And if we are, then that should be fixed. ;)\n\n-Peff\n"},{"id":"392433","messageId":"xmqqh7zfpwjm.fsf@gitster-ct.c.googlers.com","threadId":"52876","inReplyTo":"20200224064049.GD1015967@coredump.intra.peff.net","subject":"Re: [PATCH] worktree: drop unused code from get_main_worktree()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-24T20:20:13Z","receivedAt":"2020-02-24T20:20:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Sun, Feb 23, 2020 at 08:59:35PM -0500, Eric Sunshine wrote:\n>\n>> This code has been unused since fa099d2322 (worktree.c: kill parse_ref()\n>> in favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.\n>\n> Looks obviously correct, unless we are depending on some side effect of\n> get_git_common_dir(). And if we are, then that should be fixed. ;)\n\nHeh, get_git_common_dir() could be implemented to have some \"setup\"\nkind of side effect for the first call to it, but what is removed is\nthe second call ;-)  Besides, the body of get_git_common_dir() is a\nmere three lines that does not have any side effect, so...\n\n"}]}