builtin/apply: avoid parameter shadowing 'linenr' global
Let's just rename the global 'state_linenr' as it will become
'state->linenr' in a following patch.
This also avoid errors when compiling with -Wshadow and makes
it safer to later move global variables into a "state" struct.
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Christian Couder9 years agocommitted byJunio C Hamano
die(_("unable to find filename in patch at line %d"), linenr);
die(_("unable to find filename in patch at line %d"), state_linenr);
}
static int gitdiff_hdrend(const char *line, struct patch *patch)
@ -937,17 +937,17 @@ static void gitdiff_verify_name(const char *line, int isnull, char **name, int s
@@ -937,17 +937,17 @@ static void gitdiff_verify_name(const char *line, int isnull, char **name, int s
char *another;
if (isnull)
die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"),
*name, linenr);
*name, state_linenr);
another = find_name(line, NULL, state_p_value, TERM_TAB);
if (!another || memcmp(another, *name, len + 1))
die((side == DIFF_NEW_NAME) ?
_("git apply: bad git-diff - inconsistent new filename on line %d") :
_("git apply: bad git-diff - inconsistent old filename on line %d"), linenr);
_("git apply: bad git-diff - inconsistent old filename on line %d"), state_linenr);
free(another);
} else {
/* expect "/dev/null" */
if (memcmp("/dev/null", line, 9) || line[9] != '\n')
die(_("git apply: bad git-diff - expected /dev/null on line %d"), linenr);
die(_("git apply: bad git-diff - expected /dev/null on line %d"), state_linenr);
}
}
@ -1272,8 +1272,8 @@ static int parse_git_header(const char *line, int len, unsigned int size, struct
@@ -1272,8 +1272,8 @@ static int parse_git_header(const char *line, int len, unsigned int size, struct
line += len;
size -= len;
linenr++;
for (offset = len ; size > 0 ; offset += len, size -= len, line += len, linenr++) {
state_linenr++;
for (offset = len ; size > 0 ; offset += len, size -= len, line += len, state_linenr++) {
static const struct opentry {
const char *str;
int (*fn)(const char *, struct patch *);
@ -1440,7 +1440,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
@@ -1440,7 +1440,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
patch->is_new = patch->is_delete = -1;
patch->old_mode = patch->new_mode = 0;
patch->old_name = patch->new_name = NULL;
for (offset = 0; size > 0; offset += len, size -= len, line += len, linenr++) {
for (offset = 0; size > 0; offset += len, size -= len, line += len, state_linenr++) {
unsigned long nextlen;
len = linelen(line, size);
@ -1461,7 +1461,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
@@ -1461,7 +1461,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
if (parse_fragment_header(line, len, &dummy) < 0)
continue;
die(_("patch fragment without header at line %d: %.*s"),
linenr, (int)len-1, line);
state_linenr, (int)len-1, line);
}
if (size < len + 6)
@ -1482,13 +1482,13 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
@@ -1482,13 +1482,13 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
"git diff header lacks filename information when removing "
"%d leading pathname components (line %d)",
state_p_value),
state_p_value, linenr);
state_p_value, state_linenr);
patch->old_name = xstrdup(patch->def_name);
patch->new_name = xstrdup(patch->def_name);
}
if (!patch->is_delete && !patch->new_name)
die("git diff header lacks filename information "
"(line %d)", linenr);
"(line %d)", state_linenr);
patch->is_toplevel_relative = 1;
*hdrsize = git_hdr_len;
return offset;
@ -1510,7 +1510,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc
@@ -1510,7 +1510,7 @@ static int find_header(const char *line, unsigned long size, int *hdrsize, struc