diff mbox series

refs: exit early from the loop if it is not a main worktree

Message ID pull.1848.git.git.1734488445457.gitgitgadget@gmail.com (mailing list archive)
State New
Headers show
Series refs: exit early from the loop if it is not a main worktree | expand

Commit Message

Seija Kijin Dec. 18, 2024, 2:20 a.m. UTC
From: Seija Kijin <doremylover123@gmail.com>

The is_main_worktree function just checks for !wt->id,
but the compiler doesn't know this as it is in a different
file, so just exit out early.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    refs: exit early from the loop if it is not a main worktree
    
    The is_main_worktree function just checks for !wt->id, but the compiler
    doesn't know this as it is in a different file, so just exit out early.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1848%2FAreaZR%2Fexit-early-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1848/AreaZR/exit-early-v1
Pull-Request: https://github.com/git/git/pull/1848

 refs.c | 1 +
 1 file changed, 1 insertion(+)


base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086
diff mbox series

Patch

diff --git a/refs.c b/refs.c
index 8b713692359..cce63a618d7 100644
--- a/refs.c
+++ b/refs.c
@@ -2791,6 +2791,7 @@  static int has_worktrees(void)
 		if (is_main_worktree(worktrees[i]))
 			continue;
 		ret = 1;
+		break;
 	}
 
 	free_worktrees(worktrees);