summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-07-07 05:09:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-07 05:09:19 (GMT)
commit43f46d6da57ad522cb023498cf052c86787fe5bd (patch)
tree81153146f2a4391d6f3a8031e52ecebebf499642
parentefafdca42162843e90cefdeefd8e6c244cee91f5 (diff)
parent5f4ee57ad9513f96db8d936816f5ce916b4eddcd (diff)
downloadgit-43f46d6da57ad522cb023498cf052c86787fe5bd.zip
git-43f46d6da57ad522cb023498cf052c86787fe5bd.tar.gz
git-43f46d6da57ad522cb023498cf052c86787fe5bd.tar.bz2
Merge branch 'es/worktree-code-cleanup'
Code cleanup. * es/worktree-code-cleanup: worktree: avoid dead-code in conditional
-rw-r--r--worktree.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/worktree.c b/worktree.c
index ff9b7d8..cba2e54 100644
--- a/worktree.c
+++ b/worktree.c
@@ -50,9 +50,9 @@ static struct worktree *get_main_worktree(void)
struct strbuf worktree_path = STRBUF_INIT;
strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
- strbuf_strip_suffix(&worktree_path, "/.");
- if (!strbuf_strip_suffix(&worktree_path, "/.git"))
- strbuf_strip_suffix(&worktree_path, "/.");
+ if (!strbuf_strip_suffix(&worktree_path, "/.git/.") && /* in .git */
+ !strbuf_strip_suffix(&worktree_path, "/.git")) /* in worktree */
+ strbuf_strip_suffix(&worktree_path, "/."); /* in bare repo */
worktree = xcalloc(1, sizeof(*worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);