Skip to content

Commit 43f46d6

Browse files
committed
Merge branch 'es/worktree-code-cleanup'
Code cleanup. * es/worktree-code-cleanup: worktree: avoid dead-code in conditional
2 parents efafdca + 5f4ee57 commit 43f46d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

worktree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ static struct worktree *get_main_worktree(void)
5050
struct strbuf worktree_path = STRBUF_INIT;
5151

5252
strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
53-
strbuf_strip_suffix(&worktree_path, "/.");
54-
if (!strbuf_strip_suffix(&worktree_path, "/.git"))
55-
strbuf_strip_suffix(&worktree_path, "/.");
53+
if (!strbuf_strip_suffix(&worktree_path, "/.git/.") && /* in .git */
54+
!strbuf_strip_suffix(&worktree_path, "/.git")) /* in worktree */
55+
strbuf_strip_suffix(&worktree_path, "/."); /* in bare repo */
5656

5757
worktree = xcalloc(1, sizeof(*worktree));
5858
worktree->path = strbuf_detach(&worktree_path, NULL);

0 commit comments

Comments
 (0)