* [PATCH] worktree: drop unused code from get_main_worktree()
@ 2020-02-24 1:59 Eric Sunshine
2020-02-24 6:40 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sunshine @ 2020-02-24 1:59 UTC (permalink / raw)
To: git; +Cc: Eric Sunshine
This code has been unused since fa099d2322 (worktree.c: kill parse_ref()
in favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
Just something I noticed while reviewing a patch[1] on the mailing list.
[1]: https://lore.kernel.org/git/8718facbc951614f19407afa6ca8d6110507483d.1582484231.git.gitgitgadget@gmail.com/
worktree.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/worktree.c b/worktree.c
index 5b4793caa3..33c2655534 100644
--- a/worktree.c
+++ b/worktree.c
@@ -47,15 +47,12 @@ static void add_head_info(struct worktree *wt)
static struct worktree *get_main_worktree(void)
{
struct worktree *worktree = NULL;
- struct strbuf path = STRBUF_INIT;
struct strbuf worktree_path = STRBUF_INIT;
strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
if (!strbuf_strip_suffix(&worktree_path, "/.git"))
strbuf_strip_suffix(&worktree_path, "/.");
- strbuf_addf(&path, "%s/HEAD", get_git_common_dir());
-
worktree = xcalloc(1, sizeof(*worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);
/*
@@ -69,7 +66,6 @@ static struct worktree *get_main_worktree(void)
is_bare_repository();
add_head_info(worktree);
- strbuf_release(&path);
strbuf_release(&worktree_path);
return worktree;
}
--
2.25.1.526.gf05a752211
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] worktree: drop unused code from get_main_worktree()
2020-02-24 1:59 [PATCH] worktree: drop unused code from get_main_worktree() Eric Sunshine
@ 2020-02-24 6:40 ` Jeff King
2020-02-24 20:20 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2020-02-24 6:40 UTC (permalink / raw)
To: Eric Sunshine; +Cc: git
On Sun, Feb 23, 2020 at 08:59:35PM -0500, Eric Sunshine wrote:
> This code has been unused since fa099d2322 (worktree.c: kill parse_ref()
> in favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.
Looks obviously correct, unless we are depending on some side effect of
get_git_common_dir(). And if we are, then that should be fixed. ;)
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] worktree: drop unused code from get_main_worktree()
2020-02-24 6:40 ` Jeff King
@ 2020-02-24 20:20 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-02-24 20:20 UTC (permalink / raw)
To: Jeff King; +Cc: Eric Sunshine, git
Jeff King <peff@peff.net> writes:
> On Sun, Feb 23, 2020 at 08:59:35PM -0500, Eric Sunshine wrote:
>
>> This code has been unused since fa099d2322 (worktree.c: kill parse_ref()
>> in favor of refs_resolve_ref_unsafe(), 2017-04-24), so drop it.
>
> Looks obviously correct, unless we are depending on some side effect of
> get_git_common_dir(). And if we are, then that should be fixed. ;)
Heh, get_git_common_dir() could be implemented to have some "setup"
kind of side effect for the first call to it, but what is removed is
the second call ;-) Besides, the body of get_git_common_dir() is a
mere three lines that does not have any side effect, so...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-24 20:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 1:59 [PATCH] worktree: drop unused code from get_main_worktree() Eric Sunshine
2020-02-24 6:40 ` Jeff King
2020-02-24 20:20 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).