From: Ramkumar Ramachandra Date: Fri, 09 Dec 2011 19:58:21 GMT Subject: Re: [PATCH 3/9] revert: tolerate extra spaces, tabs in insn sheet Message-ID: In-Reply-To: <20111209194003.GE20913@elie.hsd1.il.comcast.net> Hi, Jonathan Nieder wrote: > Ramkumar Ramachandra wrote: > >> +++ b/builtin/revert.c >> @@ -727,7 +727,11 @@ static struct commit *parse_insn_line(char *bol, char *eol, struct replay_opts * >>       } else >>               return NULL; >> >> +     /* Eat up extra spaces/ tabs before object name */ >> +     while (*bol == ' ' || *bol == '\t') >> +             bol += 1; >> -     end_of_object_name = bol + strcspn(bol, " \n"); > > Why not use strspn?  What happens if I use a tab immediately > after the pick/revert keyword? :facepalm: Fixed. Inter-diff: diff --git a/builtin/revert.c b/builtin/revert.c index b976562..be0686d 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -716,20 +716,22 @@ static struct commit *parse_insn_line( unsigned char commit_sha1[20]; enum replay_action action; char *end_of_object_name; - int saved, status; + int saved, status, padding; - if (!prefixcmp(bol, "pick ")) { + if (!prefixcmp(bol, "pick")) { action = CHERRY_PICK; - bol += strlen("pick "); - } else if (!prefixcmp(bol, "revert ")) { + bol += strlen("pick"); + } else if (!prefixcmp(bol, "revert")) { action = REVERT; - bol += strlen("revert "); + bol += strlen("revert"); } else return NULL; /* Eat up extra spaces/ tabs before object name */ - while (*bol == ' ' || *bol == '\t') - bol += 1; + padding = strspn(bol, " \t"); + if (!padding) + return NULL; + bol += padding; end_of_object_name = bol + strcspn(bol, " \t\n"); saved = *end_of_object_name; -- Thanks. -- Ram