Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-04-22 16:01:32 +0300
committerJunio C Hamano <gitster@pobox.com>2016-04-23 00:09:38 +0300
commitc8717148d02c48340ffd6a01ca52c31fa374bf3c (patch)
tree705436893411041f15c31531f319cea0c1f16089 /worktree.c
parent81eff27b0fb652f80a43bdf18c18cd9bc25840df (diff)
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>
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c6
1 files 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;
}
}