Skip to content

Commit a46d1f7

Browse files
Martin Ågrengitster
authored andcommitted
worktree: use skip_prefix to parse target
Instead of checking for "refs/heads/" using `starts_with()`, then skipping past "refs/heads/" using `strlen()`, just use `skip_prefix()`. In `is_worktree_being_rebased()`, we can adjust the indentation while we're here and lose a pair of parentheses which isn't needed and which might even make the reader wonder what they're missing and why that grouping is there. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb07bd4 commit a46d1f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

worktree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ int is_worktree_being_rebased(const struct worktree *wt,
352352

353353
memset(&state, 0, sizeof(state));
354354
found_rebase = wt_status_check_rebase(wt, &state) &&
355-
((state.rebase_in_progress ||
356-
state.rebase_interactive_in_progress) &&
357-
state.branch &&
358-
starts_with(target, "refs/heads/") &&
359-
!strcmp(state.branch, target + strlen("refs/heads/")));
355+
(state.rebase_in_progress ||
356+
state.rebase_interactive_in_progress) &&
357+
state.branch &&
358+
skip_prefix(target, "refs/heads/", &target) &&
359+
!strcmp(state.branch, target);
360360
wt_status_state_free_buffers(&state);
361361
return found_rebase;
362362
}
@@ -370,8 +370,8 @@ int is_worktree_being_bisected(const struct worktree *wt,
370370
memset(&state, 0, sizeof(state));
371371
found_bisect = wt_status_check_bisect(wt, &state) &&
372372
state.branch &&
373-
starts_with(target, "refs/heads/") &&
374-
!strcmp(state.branch, target + strlen("refs/heads/"));
373+
skip_prefix(target, "refs/heads/", &target) &&
374+
!strcmp(state.branch, target);
375375
wt_status_state_free_buffers(&state);
376376
return found_bisect;
377377
}

0 commit comments

Comments
 (0)