Skip to content

Commit e6d40d6

Browse files
dschoJunio C Hamano
authored andcommitted
diff --check: fix off by one error
When parsing the diff line starting with '@@', the line number of the '+' file is parsed. For the subsequent line parses, the line number should therefore be incremented after the parse, not before it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent ec72220 commit e6d40d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
825825
if (line[0] == '+') {
826826
int i, spaces = 0;
827827

828-
data->lineno++;
829-
830828
/* check space before tab */
831829
for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++)
832830
if (line[i] == ' ')
@@ -841,6 +839,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
841839
if (isspace(line[len - 1]))
842840
printf("%s:%d: white space at end: %.*s\n",
843841
data->filename, data->lineno, (int)len, line);
842+
843+
data->lineno++;
844844
} else if (line[0] == ' ')
845845
data->lineno++;
846846
else if (line[0] == '@') {

0 commit comments

Comments
 (0)