Skip to content

Commit c871714

Browse files
pcloudsgitster
authored andcommitted
worktree.c: avoid referencing to worktrees[i] multiple times
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81eff27 commit c871714

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

worktree.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,20 @@ const struct worktree *find_shared_symref(const char *symref,
229229
worktrees = get_worktrees();
230230

231231
for (i = 0; worktrees[i]; i++) {
232+
struct worktree *wt = worktrees[i];
233+
232234
strbuf_reset(&path);
233235
strbuf_reset(&sb);
234236
strbuf_addf(&path, "%s/%s",
235-
get_worktree_git_dir(worktrees[i]),
237+
get_worktree_git_dir(wt),
236238
symref);
237239

238240
if (parse_ref(path.buf, &sb, NULL)) {
239241
continue;
240242
}
241243

242244
if (!strcmp(sb.buf, target)) {
243-
existing = worktrees[i];
245+
existing = wt;
244246
break;
245247
}
246248
}

0 commit comments

Comments
 (0)