Skip to content

Commit 85c3713

Browse files
tgummerergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d6c88c4 commit 85c3713

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apply.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ static const char *skip_tree_prefix(int p_value,
11641164
* creation or deletion of an empty file. In any of these cases,
11651165
* both sides are the same name under a/ and b/ respectively.
11661166
*/
1167-
static char *git_header_name(struct apply_state *state,
1167+
static char *git_header_name(int p_value,
11681168
const char *line,
11691169
int llen)
11701170
{
@@ -1184,7 +1184,7 @@ static char *git_header_name(struct apply_state *state,
11841184
goto free_and_fail1;
11851185

11861186
/* 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);
11881188
if (!cp)
11891189
goto free_and_fail1;
11901190
strbuf_remove(&first, 0, cp - first.buf);
@@ -1201,7 +1201,7 @@ static char *git_header_name(struct apply_state *state,
12011201
if (*second == '"') {
12021202
if (unquote_c_style(&sp, second, NULL))
12031203
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);
12051205
if (!cp)
12061206
goto free_and_fail1;
12071207
/* They must match, otherwise ignore */
@@ -1212,7 +1212,7 @@ static char *git_header_name(struct apply_state *state,
12121212
}
12131213

12141214
/* 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);
12161216
if (!cp)
12171217
goto free_and_fail1;
12181218
if (line + llen - cp != first.len ||
@@ -1227,7 +1227,7 @@ static char *git_header_name(struct apply_state *state,
12271227
}
12281228

12291229
/* unquoted first name */
1230-
name = skip_tree_prefix(state->p_value, line, llen);
1230+
name = skip_tree_prefix(p_value, line, llen);
12311231
if (!name)
12321232
return NULL;
12331233

@@ -1243,7 +1243,7 @@ static char *git_header_name(struct apply_state *state,
12431243
if (unquote_c_style(&sp, second, NULL))
12441244
goto free_and_fail2;
12451245

1246-
np = skip_tree_prefix(state->p_value, sp.buf, sp.len);
1246+
np = skip_tree_prefix(p_value, sp.buf, sp.len);
12471247
if (!np)
12481248
goto free_and_fail2;
12491249

@@ -1287,7 +1287,7 @@ static char *git_header_name(struct apply_state *state,
12871287
*/
12881288
if (!name[len + 1])
12891289
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,
12911291
line_len - (len + 1));
12921292
if (!second)
12931293
return NULL;
@@ -1333,7 +1333,7 @@ static int parse_git_header(struct apply_state *state,
13331333
* or removing or adding empty files), so we get
13341334
* the default name from the header.
13351335
*/
1336-
patch->def_name = git_header_name(state, line, len);
1336+
patch->def_name = git_header_name(state->p_value, line, len);
13371337
if (patch->def_name && state->root.len) {
13381338
char *s = xstrfmt("%s%s", state->root.buf, patch->def_name);
13391339
free(patch->def_name);

0 commit comments

Comments
 (0)