On Tue, Jan 03, 2017 at 12:30:40AM +0100, Michael Haggerty wrote: > > I think > > my next series is going to include a small sscanf-style parser to parse > > these. Right now, using constants here is going to leave it extremely > > difficult to read. Something like the following for the OIDs: > > > > strbuf_git_scanf(sb, "%h %h ", &ooid, &noid); > > > > and then following up parsing the remainder. > > Maybe something with an interface like skip_prefix wouldn't be too > obnoxious: > > const char *p = sb.buf; > if (oid_prefix(p, &ooid, &p) && > *p++ == ' ' && > oid_prefix(p, &noid, &p) && ... Yeah, I've used C code before that had a very similar interface for parsing, and when used consistently it's pretty pleasant. Something like: if (parse_oid(p, &oid, &p) && skip_whitespace(p, &p) && parse_refname(p, &refname, &p)) etc is nicer than some of the magic numbers we end up using in the various parsers (I don't think anybody needs to mass-convert, I just mean that something like parse_oid() seems like a step in a good direction). -Peff