summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2019-07-08 16:33:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-07-09 18:29:02 (GMT)
commitd6c88c4fdc1ce189e4abad56f9e3b16d2f831867 (patch)
treed5de22698057b2bdd16c291ffd1612eae3ed60d6 /apply.c
parent5af40877a4354156b311060eb6594cb5159e0577 (diff)
downloadgit-d6c88c4fdc1ce189e4abad56f9e3b16d2f831867.zip
git-d6c88c4fdc1ce189e4abad56f9e3b16d2f831867.tar.gz
git-d6c88c4fdc1ce189e4abad56f9e3b16d2f831867.tar.bz2
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 <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/apply.c b/apply.c
index ad476c6..743b995 100644
--- a/apply.c
+++ b/apply.c
@@ -1137,17 +1137,17 @@ static int gitdiff_unrecognized(struct apply_state *state,
* Skip p_value leading components from "line"; as we do not accept
* absolute paths, return NULL in that case.
*/
-static const char *skip_tree_prefix(struct apply_state *state,
+static const char *skip_tree_prefix(int p_value,
const char *line,
int llen)
{
int nslash;
int i;
- if (!state->p_value)
+ if (!p_value)
return (llen && line[0] == '/') ? NULL : line;
- nslash = state->p_value;
+ nslash = p_value;
for (i = 0; i < llen; i++) {
int ch = line[i];
if (ch == '/' && --nslash <= 0)
@@ -1184,7 +1184,7 @@ static char *git_header_name(struct apply_state *state,
goto free_and_fail1;
/* strip the a/b prefix including trailing slash */
- cp = skip_tree_prefix(state, first.buf, first.len);
+ cp = skip_tree_prefix(state->p_value, first.buf, first.len);
if (!cp)
goto free_and_fail1;
strbuf_remove(&first, 0, cp - first.buf);
@@ -1201,7 +1201,7 @@ static char *git_header_name(struct apply_state *state,
if (*second == '"') {
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail1;
- cp = skip_tree_prefix(state, sp.buf, sp.len);
+ cp = skip_tree_prefix(state->p_value, sp.buf, sp.len);
if (!cp)
goto free_and_fail1;
/* They must match, otherwise ignore */
@@ -1212,7 +1212,7 @@ static char *git_header_name(struct apply_state *state,
}
/* unquoted second */
- cp = skip_tree_prefix(state, second, line + llen - second);
+ cp = skip_tree_prefix(state->p_value, second, line + llen - second);
if (!cp)
goto free_and_fail1;
if (line + llen - cp != first.len ||
@@ -1227,7 +1227,7 @@ static char *git_header_name(struct apply_state *state,
}
/* unquoted first name */
- name = skip_tree_prefix(state, line, llen);
+ name = skip_tree_prefix(state->p_value, line, llen);
if (!name)
return NULL;
@@ -1243,7 +1243,7 @@ static char *git_header_name(struct apply_state *state,
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail2;
- np = skip_tree_prefix(state, sp.buf, sp.len);
+ np = skip_tree_prefix(state->p_value, sp.buf, sp.len);
if (!np)
goto free_and_fail2;
@@ -1287,7 +1287,7 @@ static char *git_header_name(struct apply_state *state,
*/
if (!name[len + 1])
return NULL; /* no postimage name */
- second = skip_tree_prefix(state, name + len + 1,
+ second = skip_tree_prefix(state->p_value, name + len + 1,
line_len - (len + 1));
if (!second)
return NULL;