From: Jeff King <peff@peff.net>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>, Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 2/3] diff: introduce diff.submodule configuration variable
Date: Tue, 13 Nov 2012 00:33:36 -0500 [thread overview]
Message-ID: <20121113053336.GA10995@sigill.intra.peff.net> (raw)
In-Reply-To: <1352653146-3932-3-git-send-email-artagnon@gmail.com>
On Sun, Nov 11, 2012 at 10:29:05PM +0530, Ramkumar Ramachandra wrote:
> +static int parse_submodule_params(struct diff_options *options, const char *value,
> + struct strbuf *errmsg)
> +{
> + if (!strcmp(value, "log"))
> + DIFF_OPT_SET(options, SUBMODULE_LOG);
> + else if (!strcmp(value, "short"))
> + DIFF_OPT_CLR(options, SUBMODULE_LOG);
> + else {
> + strbuf_addf(errmsg, _("'%s'"), value);
> + return 1;
> + }
> + return 0;
> +}
I think "-1" would be the more normal error return.
> @@ -223,6 +238,15 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
> return 0;
> }
>
> + if (!strcmp(var, "diff.submodule")) {
Shouldn't this be in git_diff_ui_config so it does not affect scripts
calling plumbing?
> + struct strbuf errmsg = STRBUF_INIT;
> + if (parse_submodule_params(&default_diff_options, value, &errmsg))
> + warning(_("Unknown value for 'diff.submodule' config variable: %s"),
> + errmsg.buf);
> + strbuf_release(&errmsg);
> + return 0;
> + }
Hmm. This strbuf error handling strikes me as very clunky, considering
that it does not pass any useful information out of the parse function
(it always just adds '$value' to the error string). Wouldn't it be
simpler to just have parse_submodule_params return -1, and then let the
caller warn or generate an error as appropriate?
-Peff
next prev parent reply other threads:[~2012-11-13 5:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-11 16:59 [PATCH v3 0/3] Introduce diff.submodule Ramkumar Ramachandra
2012-11-11 16:59 ` [PATCH 1/3] Documentation: move diff.wordRegex from config.txt to diff-config.txt Ramkumar Ramachandra
2012-11-11 16:59 ` [PATCH 2/3] diff: introduce diff.submodule configuration variable Ramkumar Ramachandra
2012-11-13 5:33 ` Jeff King [this message]
2012-11-13 15:45 ` Ramkumar Ramachandra
2012-11-13 16:27 ` Junio C Hamano
2012-11-11 16:59 ` [PATCH 3/3] submodule: display summary header in bold Ramkumar Ramachandra
2012-11-13 5:44 ` Jeff King
2012-11-13 5:17 ` [PATCH v3 0/3] Introduce diff.submodule Ramkumar Ramachandra
-- strict thread matches above, loose matches on Subject: below --
2012-11-01 10:43 [PATCH v2 " Ramkumar Ramachandra
2012-11-01 10:43 ` [PATCH 2/3] diff: introduce diff.submodule configuration variable Ramkumar Ramachandra
2012-11-08 20:51 ` Jeff King
2012-11-11 14:50 ` Ramkumar Ramachandra
2012-11-11 15:09 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121113053336.GA10995@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Jens.Lehmann@web.de \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).