summaryrefslogtreecommitdiff
path: root/notes-utils.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-06-18 19:49:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-20 17:44:45 (GMT)
commit97313bef2a16eb8b3d40830204c20c34ba9d6554 (patch)
treee026fa21f79e4aa58e4ef5d065c097753ed9088b /notes-utils.h
parent95b567c7c3cf6b85d74b79424cdfbd40a7dee7c9 (diff)
downloadgit-97313bef2a16eb8b3d40830204c20c34ba9d6554.zip
git-97313bef2a16eb8b3d40830204c20c34ba9d6554.tar.gz
git-97313bef2a16eb8b3d40830204c20c34ba9d6554.tar.bz2
fast-import: use skip_prefix for parsing input
Fast-import does a lot of parsing of commands and dispatching to sub-functions. For example, given "option foo", we might recognize "option " using starts_with, and then hand it off to parse_option() to do the rest. However, we do not let parse_option know that we have parsed the first part already. It gets the full buffer, and has to skip past the uninteresting bits. Some functions simply add a magic constant: char *option = command_buf.buf + 7; Others use strlen: char *option = command_buf.buf + strlen("option "); And others use strchr: char *option = strchr(command_buf.buf, ' ') + 1; All of these are brittle and easy to get wrong (especially given that the starts_with call and the code that assumes the presence of the prefix are far apart). Instead, we can use skip_prefix, and just pass each handler a pointer to its arguments. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-utils.h')
0 files changed, 0 insertions, 0 deletions