Skip to content

Commit d6c88c4

Browse files
tgummerergitster
authored andcommitted
apply: only pass required data to skip_tree_prefix
Currently the 'skip_tree_prefix()' 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 5af4087 commit d6c88c4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

apply.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,17 +1137,17 @@ static int gitdiff_unrecognized(struct apply_state *state,
11371137
* Skip p_value leading components from "line"; as we do not accept
11381138
* absolute paths, return NULL in that case.
11391139
*/
1140-
static const char *skip_tree_prefix(struct apply_state *state,
1140+
static const char *skip_tree_prefix(int p_value,
11411141
const char *line,
11421142
int llen)
11431143
{
11441144
int nslash;
11451145
int i;
11461146

1147-
if (!state->p_value)
1147+
if (!p_value)
11481148
return (llen && line[0] == '/') ? NULL : line;
11491149

1150-
nslash = state->p_value;
1150+
nslash = p_value;
11511151
for (i = 0; i < llen; i++) {
11521152
int ch = line[i];
11531153
if (ch == '/' && --nslash <= 0)
@@ -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, first.buf, first.len);
1187+
cp = skip_tree_prefix(state->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, sp.buf, sp.len);
1204+
cp = skip_tree_prefix(state->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, second, line + llen - second);
1215+
cp = skip_tree_prefix(state->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, line, llen);
1230+
name = skip_tree_prefix(state->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, sp.buf, sp.len);
1246+
np = skip_tree_prefix(state->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, name + len + 1,
1290+
second = skip_tree_prefix(state->p_value, name + len + 1,
12911291
line_len - (len + 1));
12921292
if (!second)
12931293
return NULL;

0 commit comments

Comments
 (0)