From: Jens Lehmann <Jens.Lehmann@web.de>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 3/5] diff: acknowledge --submodule=short command-line option
Date: Sun, 07 Oct 2012 21:49:28 +0200 [thread overview]
Message-ID: <5071DCC8.50004@web.de> (raw)
In-Reply-To: <CALkWK0mbQZjYUR73rdFP2BtOzdL9gQqxnC5fjtsCYq2F29=8qg@mail.gmail.com>
Am 07.10.2012 17:22, schrieb Ramkumar Ramachandra:
> Jens Lehmann wrote:
>> Am 02.10.2012 18:51, schrieb Ramkumar Ramachandra:
>>> Currently, the diff code does not differentiate between an explicit
>>> '--submodule=short' being passed, and no submodule option being passed
>>> on the command line. Making this differentiation will be important
>>> when the command-line option can be used to override a
>>> "diff.submoduleFormat" configuration variable introduced in the next
>>> patch.
>>
>> Wouldn't it be sufficient here to simply reset the log flag by using
>> "DIFF_OPT_CLR(options, SUBMODULE_LOG)"? This would avoid having to
>> use the last bit of the diffopt flags. And if I read the code correctly,
>> diff_opt_parse() is called by setup_revisions() which is called after
>> git_config(), so that should be safe. (And "textconv" uses the same
>> approach)
>
> How is it sufficient? In git_diff_ui_config(), I set
> submodule_format_cfg, which has nothing to do with SUBMODULE_LOG. In
> builtin_diff(), I'll have to check SUBMODULE_LOG and
> submodule_format_cfg. The tricky bit is that I should check
> submodule_format_cfg if and only if "--submodule=short" was NOT passed
> on the command line- now, that's not the same thing is checking if
> SUBMODULE_LOG is unset, because SUBMODULE_LOG is unset (or cleared) if
> no argument was passed or if "--submodule=short" is passed.
> Therefore, I need a SUBMODULE_SHORT to differentiate between the two
> cases.
>
> What am I missing?
I forgot to mention that testing submodule_format_cfg would have to
happen in cmd_diff() (between reading the config and parsing the
command line options) instead of builtin_diff(). Something like this
should do the trick (untested):
diff --git a/builtin/diff.c b/builtin/diff.c
index 9650be2..180bf44 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -297,6 +297,9 @@ 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);
+ if (submodule_format_cfg && !strcmp(submodule_format_cfg, "log"))
+ DIFF_OPT_SET(options, SUBMODULE_LOG);
+
if (nongit)
die(_("Not a git repository"));
argc = setup_revisions(argc, argv, &rev, NULL);
next prev parent reply other threads:[~2012-10-07 19:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-02 16:51 [PATCH 0/5] submodule: introduce diff.submoduleFormat Ramkumar Ramachandra
2012-10-02 16:51 ` [PATCH 1/5] Documentation: move diff.wordRegex from config.txt to diff-config.txt Ramkumar Ramachandra
2012-10-02 16:51 ` [PATCH 2/5] Documentation: sort diff-config.txt alphabetically Ramkumar Ramachandra
2012-10-02 16:51 ` [PATCH 3/5] diff: acknowledge --submodule=short command-line option Ramkumar Ramachandra
2012-10-02 19:24 ` Jens Lehmann
2012-10-07 15:22 ` Ramkumar Ramachandra
2012-10-07 19:49 ` Jens Lehmann [this message]
2012-10-07 19:55 ` Jens Lehmann
2012-10-02 16:51 ` [PATCH 4/5] diff: introduce diff.submoduleFormat configuration variable Ramkumar Ramachandra
2012-10-02 19:44 ` Jens Lehmann
2012-10-03 13:45 ` Jens Lehmann
2012-10-29 10:30 ` Ramkumar Ramachandra
2012-10-30 21:26 ` Jens Lehmann
2012-10-02 16:51 ` [PATCH 5/5] submodule: display summary header in bold Ramkumar Ramachandra
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=5071DCC8.50004@web.de \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.