]> git.ipfire.org Git - thirdparty/git.git/commit - fast-import.c
fast-import: refactor parsing of spaces
authorJeff King <peff@peff.net>
Wed, 18 Jun 2014 19:51:57 +0000 (15:51 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Jun 2014 17:45:19 +0000 (10:45 -0700)
commite814c39c2fe7cc915ba70c0aa6f03156a28920fc
tree0f84a280e06c7b0b030d13dc9587a9e2cec99245
parent0539cc0038ff3411da1fea342b7d6615643bff5b
fast-import: refactor parsing of spaces

When we see a file change in a commit, we expect one of:

  1. A mark.

  2. An "inline" keyword.

  3. An object sha1.

The handling of spaces is inconsistent between the three
options. Option 1 calls a sub-function which checks for the
space, but doesn't parse past it. Option 2 parses the space,
then deliberately avoids moving the pointer past it. Option
3 detects the space locally but doesn't move past it.

This is confusing, because it looks like option 1 forgets to
check for the space (it's just buried). And option 2 checks
for "inline ", but only moves strlen("inline") characters
forward, which looks like a bug but isn't.

We can make this more clear by just having each branch move
past the space as it is checked (and we can replace the
doubled use of "inline" with a call to skip_prefix).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c