worktree.c: avoid referencing to worktrees[i] multiple times
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
81eff27b0f
commit
c8717148d0
@ -229,10 +229,12 @@ const struct worktree *find_shared_symref(const char *symref,
|
|||||||
worktrees = get_worktrees();
|
worktrees = get_worktrees();
|
||||||
|
|
||||||
for (i = 0; worktrees[i]; i++) {
|
for (i = 0; worktrees[i]; i++) {
|
||||||
|
struct worktree *wt = worktrees[i];
|
||||||
|
|
||||||
strbuf_reset(&path);
|
strbuf_reset(&path);
|
||||||
strbuf_reset(&sb);
|
strbuf_reset(&sb);
|
||||||
strbuf_addf(&path, "%s/%s",
|
strbuf_addf(&path, "%s/%s",
|
||||||
get_worktree_git_dir(worktrees[i]),
|
get_worktree_git_dir(wt),
|
||||||
symref);
|
symref);
|
||||||
|
|
||||||
if (parse_ref(path.buf, &sb, NULL)) {
|
if (parse_ref(path.buf, &sb, NULL)) {
|
||||||
@ -240,7 +242,7 @@ const struct worktree *find_shared_symref(const char *symref,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(sb.buf, target)) {
|
if (!strcmp(sb.buf, target)) {
|
||||||
existing = worktrees[i];
|
existing = wt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user