From c8717148d02c48340ffd6a01ca52c31fa374bf3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 22 Apr 2016 20:01:32 +0700 Subject: [PATCH] worktree.c: avoid referencing to worktrees[i] multiple times MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- worktree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worktree.c b/worktree.c index dc092a7100..927905b7a1 100644 --- a/worktree.c +++ b/worktree.c @@ -229,10 +229,12 @@ const struct worktree *find_shared_symref(const char *symref, worktrees = get_worktrees(); for (i = 0; worktrees[i]; i++) { + struct worktree *wt = worktrees[i]; + strbuf_reset(&path); strbuf_reset(&sb); strbuf_addf(&path, "%s/%s", - get_worktree_git_dir(worktrees[i]), + get_worktree_git_dir(wt), symref); 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)) { - existing = worktrees[i]; + existing = wt; break; } } -- 2.47.1