apply: only pass required data to check_header_line
Currently the 'check_header_line()' function takes 'struct apply_state' as parameter, even though it only needs the linenr from that struct. This function is in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Gummerer committed
Jul 8, 2019 at 17:33 UTC
570fe9911b6eb5c64f22a54eb3a7590b7ba5f854
1 file changed
+4
-4
apply.c
+4
-4
@@ -1302,15 +1302,15 @@ static char *git_header_name(int p_value,
1302
}
1303
}
1304
1305
-static int check_header_line(struct apply_state *state, struct patch *patch)
1305
+static int check_header_line(int linenr, struct patch *patch)
1306
{
1307
int extensions = (patch->is_delete == 1) + (patch->is_new == 1) +
1308
(patch->is_rename == 1) + (patch->is_copy == 1);
1309
if (extensions > 1)
1310
return error(_("inconsistent header lines %d and %d"),
1311
- patch->extension_linenr, state->linenr);
1311
+ patch->extension_linenr, linenr);
1312
if (extensions && !patch->extension_linenr)
1313
- patch->extension_linenr = state->linenr;
1313
+ patch->extension_linenr = linenr;
1314
return 0;
1315
}
1316
@@ -1380,7 +1380,7 @@ static int parse_git_header(struct apply_state *state,
1380
res = p->fn(state, line + oplen, patch);
1381
if (res < 0)
1382
return -1;
1383
- if (check_header_line(state, patch))
1383
+ if (check_header_line(state->linenr, patch))
1384
return -1;
1385
if (res > 0)
1386
return offset;