worktree: drop unused code from get_main_worktree()
PATCH 1/1 worktree: drop unused code from get_main_worktree()
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.
---
Just something I noticed while reviewing a patch[1] on the mailing list.
worktree.c | 4 ---- 1 file changed, 4 deletions(-)
worktree.c +0 -4
@@ -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; }
Signature · 1 line
2.25.1.526.gf05a752211
Quoted 2 lines · Eric Sunshine
This code has been unused since
fa099d2322(worktree.c: killparse_ref()in favor ofrefs_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
Quoted 7 lines · Jeff King
Quoted 2 lines · Eric Sunshine
This code has been unused since
fa099d2322(worktree.c: killparse_ref()in favor ofrefs_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...