Skip to content

Commit 9881b45

Browse files
Martin Ågrengitster
authored andcommitted
merge: use skip_prefix to parse config key
Instead of using `starts_with()`, the magic number 7, `strlen()` and a fair number of additions to verify the three parts of the config key "branch.<branch>.mergeoptions", use `skip_prefix()` to jump through them more explicitly. We need to introduce a new variable for this (we certainly can't modify `k` just because we see "branch."!). With `skip_prefix()` we often use quite bland names like `p` or `str`. Let's do the same. If and when this function needs to do more prefix-skipping, we'll have a generic variable ready for this. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9fadedd commit 9881b45

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

builtin/merge.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,12 @@ static void parse_branch_merge_options(char *bmo)
597597
static int git_merge_config(const char *k, const char *v, void *cb)
598598
{
599599
int status;
600+
const char *str;
600601

601-
if (branch && starts_with(k, "branch.") &&
602-
starts_with(k + 7, branch) &&
603-
!strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
602+
if (branch &&
603+
skip_prefix(k, "branch.", &str) &&
604+
skip_prefix(str, branch, &str) &&
605+
!strcmp(str, ".mergeoptions")) {
604606
free(branch_mergeoptions);
605607
branch_mergeoptions = xstrdup(v);
606608
return 0;

0 commit comments

Comments
 (0)