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: Thu, 8 Nov 2012 15:51:10 -0500 [thread overview]
Message-ID: <20121108205110.GB8376@sigill.intra.peff.net> (raw)
In-Reply-To: <1351766630-4837-3-git-send-email-artagnon@gmail.com>
On Thu, Nov 01, 2012 at 04:13:49PM +0530, Ramkumar Ramachandra wrote:
> diff --git a/builtin/diff.c b/builtin/diff.c
> index 9650be2..6d00311 100644
> --- a/builtin/diff.c
> +++ b/builtin/diff.c
> @@ -297,6 +297,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
> DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
> DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
>
> + /* Set SUBMODULE_LOG if diff.submodule config var was set */
> + if (submodule_format_cfg && !strcmp(submodule_format_cfg, "log"))
> + DIFF_OPT_SET(&rev.diffopt, SUBMODULE_LOG);
> +
Yuck. Why is this parsing happening in cmd_diff?
Wouldn't you want it to kick in for "git log --submodule", too? It seems
like it should go into diff_setup(), and the porcelain/plumbing aspect
should be controlled by parsing it in git_diff_ui_config or
git_diff_basic_config. See how diff_no_prefix and diff_mnemonic prefix
are handled for an example.
Then you can keep the parsing logic for "log" in diff.c. And you should
factor it out into a function so that the command-line option and the
config parser can share the same code. I know it's only one line now,
but anybody who wants to add an option will have to update both places.
See the parsing of diff.dirstat for an example.
> else if (!prefixcmp(arg, "--submodule=")) {
> if (!strcmp(arg + 12, "log"))
> DIFF_OPT_SET(options, SUBMODULE_LOG);
> + if (!strcmp(arg + 12, "short"))
> + DIFF_OPT_CLR(options, SUBMODULE_LOG);
> }
Much better (although arguably should go in a separate patch). Should we
also produce an error if somebody says "--submodule=foobar"?
-Peff
next prev parent reply other threads:[~2012-11-08 20:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-01 10:43 [PATCH v2 0/3] Introduce diff.submodule Ramkumar Ramachandra
2012-11-01 10:43 ` [PATCH 1/3] Documentation: move diff.wordRegex from config.txt to diff-config.txt 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 [this message]
2012-11-11 14:50 ` Ramkumar Ramachandra
2012-11-11 15:09 ` Jeff King
2012-11-01 10:43 ` [PATCH 3/3] submodule: display summary header in bold Ramkumar Ramachandra
2012-11-01 21:10 ` [PATCH v2 0/3] Introduce diff.submodule Jens Lehmann
2012-11-04 17:58 ` Ramkumar Ramachandra
2012-11-08 20:43 ` Jeff King
-- strict thread matches above, loose matches on Subject: below --
2012-11-11 16:59 [PATCH v3 " 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
2012-11-13 15:45 ` Ramkumar Ramachandra
2012-11-13 16:27 ` Junio C Hamano
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=20121108205110.GB8376@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).