Re: [RFC PATCH] revert: Persist per-session opts
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Jul 11, 2011, 06:12 UTC
- Message-ID
- <CALkWK0ndSWkPudM_sJnyUyh93t9JLk-t-YFQb7=WO2H_svnGdQ@mail.gmail.com>
- In-Reply-To
- <201107101002.06385.chriscool@tuxfamily.org>
Hi Christian,
Christian Couder writes:
Show 29 quoted lines
> On Saturday 09 July 2011 17:41:58 Ramkumar Ramachandra wrote:
>> Save the replay_opts struct in .git/sequencer/opts using a simple "key
>> = value" format. Parse it and populate the options structure before
>> replaying.
>
> [...]
>
>> static void format_todo(struct strbuf *buf, struct commit_list *todo_list,
>> struct replay_opts *opts)
>> {
>> @@ -733,6 +759,102 @@ error:
>> die(_("Malformed instruction sheet: %s"), git_path(SEQ_TODO_FILE));
>> }
>>
>> +static char *parse_opt_value(char *p, void *key, enum seq_opt_type type,
>> + parse_opt_cb *cb_function) {
>> + struct option opt;
>> + char *val, *cur, *end;
>> +
>> + if (!(val = strchr(p, '=')))
>> + goto error;
>> + if (!*(val + 1))
>> + goto error;
>> + if (!(end = strchr(p, '\n')))
>> + goto error;
>> + val += 2;
>
> It looks like you rely on all lines ending with \n and having a space after
> the '='. It may be a little bit too fragile.Right. Thanks for the review -- will try to reuse bits of the git-config parser.
-- Ram