@@ -820,10 +820,8 @@ void remove_branch_state(struct repository *r, int verbose)
void die_if_checked_out(const char *branch, int ignore_current_worktree)
{
struct worktree **worktrees = get_worktrees();
- int i;
- for (i = 0; worktrees[i]; i++)
- {
+ for (int i = 0; worktrees[i]; i++) {
if (worktrees[i]->is_current && ignore_current_worktree)
continue;
@@ -434,17 +434,12 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
const char *symref,
const char *target)
{
- const struct worktree *existing = NULL;
- int i = 0;
- for (i = 0; worktrees[i]; i++) {
- if (is_shared_symref(worktrees[i], symref, target)) {
- existing = worktrees[i];
- break;
- }
- }
+ for (int i = 0; worktrees[i]; i++)
+ if (is_shared_symref(worktrees[i], symref, target))
+ return worktrees[i];
- return existing;
+ return NULL;
}
int submodule_uses_worktrees(const char *path)