apply: only pass required data to git_header_name
Currently the 'git_header_name()' function takes 'struct apply_state' as parameter, even though it only needs the p_value 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
85c3713df5a48bbc7807fe9710fe8a22e65ea76b
1 file changed
+8
-8
apply.c
+8
-8
@@ -1164,7 +1164,7 @@ static const char *skip_tree_prefix(int p_value,
1164
* creation or deletion of an empty file. In any of these cases,
1165
* both sides are the same name under a/ and b/ respectively.
1166
*/
1167
-static char *git_header_name(struct apply_state *state,
1167
+static char *git_header_name(int p_value,
1168
const char *line,
1169
int llen)
1170
{
@@ -1184,7 +1184,7 @@ static char *git_header_name(struct apply_state *state,
1184
goto free_and_fail1;
1185
1186
/* strip the a/b prefix including trailing slash */
1187
- cp = skip_tree_prefix(state->p_value, first.buf, first.len);
1187
+ cp = skip_tree_prefix(p_value, first.buf, first.len);
1188
if (!cp)
1189
goto free_and_fail1;
1190
strbuf_remove(&first, 0, cp - first.buf);
@@ -1201,7 +1201,7 @@ static char *git_header_name(struct apply_state *state,
1201
if (*second == '"') {
1202
if (unquote_c_style(&sp, second, NULL))
1203
goto free_and_fail1;
1204
- cp = skip_tree_prefix(state->p_value, sp.buf, sp.len);
1204
+ cp = skip_tree_prefix(p_value, sp.buf, sp.len);
1205
if (!cp)
1206
goto free_and_fail1;
1207
/* They must match, otherwise ignore */
@@ -1212,7 +1212,7 @@ static char *git_header_name(struct apply_state *state,
1212
}
1213
1214
/* unquoted second */
1215
- cp = skip_tree_prefix(state->p_value, second, line + llen - second);
1215
+ cp = skip_tree_prefix(p_value, second, line + llen - second);
1216
if (!cp)
1217
goto free_and_fail1;
1218
if (line + llen - cp != first.len ||
@@ -1227,7 +1227,7 @@ static char *git_header_name(struct apply_state *state,
1227
}
1228
1229
/* unquoted first name */
1230
- name = skip_tree_prefix(state->p_value, line, llen);
1230
+ name = skip_tree_prefix(p_value, line, llen);
1231
if (!name)
1232
return NULL;
1233
@@ -1243,7 +1243,7 @@ static char *git_header_name(struct apply_state *state,
1243
if (unquote_c_style(&sp, second, NULL))
1244
goto free_and_fail2;
1245
1246
- np = skip_tree_prefix(state->p_value, sp.buf, sp.len);
1246
+ np = skip_tree_prefix(p_value, sp.buf, sp.len);
1247
if (!np)
1248
goto free_and_fail2;
1249
@@ -1287,7 +1287,7 @@ static char *git_header_name(struct apply_state *state,
1287
*/
1288
if (!name[len + 1])
1289
return NULL; /* no postimage name */
1290
- second = skip_tree_prefix(state->p_value, name + len + 1,
1290
+ second = skip_tree_prefix(p_value, name + len + 1,
1291
line_len - (len + 1));
1292
if (!second)
1293
return NULL;
@@ -1333,7 +1333,7 @@ static int parse_git_header(struct apply_state *state,
1333
* or removing or adding empty files), so we get
1334
* the default name from the header.
1335
*/
1336
- patch->def_name = git_header_name(state, line, len);
1336
+ patch->def_name = git_header_name(state->p_value, line, len);
1337
if (patch->def_name && state->root.len) {
1338
char *s = xstrfmt("%s%s", state->root.buf, patch->def_name);
1339
free(patch->def_name);