From: Jens Lehmann <Jens.Lehmann@web.de>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 4/5] diff: introduce diff.submoduleFormat configuration variable
Date: Tue, 02 Oct 2012 21:44:24 +0200 [thread overview]
Message-ID: <506B4418.2050700@web.de> (raw)
In-Reply-To: <1349196670-2844-5-git-send-email-artagnon@gmail.com>
Am 02.10.2012 18:51, schrieb Ramkumar Ramachandra:
> Introduce a diff.submoduleFormat configuration variable corresponding
> to the '--submodule' command-line option of 'git diff'.
Nice. Maybe a better name would be "diff.submodule", as this sets the
default for the "--submodule" option of diff?
And I think you should also test in t4041 that "--submodule=short"
overrides the config setting.
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
> Documentation/diff-config.txt | 7 +++++++
> Documentation/diff-options.txt | 3 ++-
> diff.c | 25 ++++++++++++++++---------
> t/t4041-diff-submodule-option.sh | 10 ++++++++++
> 4 files changed, 35 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
> index 04574f9..e445cc8 100644
> --- a/Documentation/diff-config.txt
> +++ b/Documentation/diff-config.txt
> @@ -103,6 +103,13 @@ diff.suppressBlankEmpty::
> A boolean to inhibit the standard behavior of printing a space
> before each empty output line. Defaults to false.
>
> +diff.submoduleFormat::
> + Specify the format in which differences in submodules are
> + shown. The "log" format lists the commits in the range like
> + linkgit:git-submodule[1] `summary` does. The "short" format
> + format just shows the names of the commits at the beginning
> + and end of the range. Defaults to short.
> +
> diff.wordRegex::
> A POSIX Extended Regular Expression used to determine what is a "word"
> when performing word-by-word difference calculations. Character
> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> index cf4b216..034c4e7 100644
> --- a/Documentation/diff-options.txt
> +++ b/Documentation/diff-options.txt
> @@ -170,7 +170,8 @@ any of those replacements occurred.
> the commits in the range like linkgit:git-submodule[1] `summary` does.
> Omitting the `--submodule` option or specifying `--submodule=short`,
> uses the 'short' format. This format just shows the names of the commits
> - at the beginning and end of the range.
> + at the beginning and end of the range. Can be tweaked via the
> + `diff.submoduleFormat` configuration variable.
>
> --color[=<when>]::
> Show colored diff.
> diff --git a/diff.c b/diff.c
> index 8ea40f9..4cb8dd2 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -28,6 +28,7 @@ static int diff_suppress_blank_empty;
> static int diff_use_color_default = -1;
> static const char *diff_word_regex_cfg;
> static const char *external_diff_cmd_cfg;
> +static const char *submodule_format_cfg;
> int diff_auto_refresh_index = 1;
> static int diff_mnemonic_prefix;
> static int diff_no_prefix;
> @@ -161,6 +162,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
> diff_stat_graph_width = git_config_int(var, value);
> return 0;
> }
> + if (!strcmp(var, "diff.submoduleformat"))
> + return git_config_string(&submodule_format_cfg, var, value);
> if (!strcmp(var, "diff.external"))
> return git_config_string(&external_diff_cmd_cfg, var, value);
> if (!strcmp(var, "diff.wordregex"))
> @@ -2227,15 +2230,19 @@ static void builtin_diff(const char *name_a,
> line_prefix = msgbuf->buf;
> }
>
> - if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
> - (!one->mode || S_ISGITLINK(one->mode)) &&
> - (!two->mode || S_ISGITLINK(two->mode))) {
> - const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
> - const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
> - show_submodule_summary(o->file, one ? one->path : two->path,
> - one->sha1, two->sha1, two->dirty_submodule,
> - del, add, reset);
> - return;
> + if (!DIFF_OPT_TST(o, SUBMODULE_SHORT) &&
> + ((!one->mode || S_ISGITLINK(one->mode)) &&
> + (!two->mode || S_ISGITLINK(two->mode)))) {
> + if (DIFF_OPT_TST(o, SUBMODULE_LOG) ||
> + (submodule_format_cfg &&
> + !strcmp(submodule_format_cfg, "log"))) {
> + const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
> + const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
> + show_submodule_summary(o->file, one ? one->path : two->path,
> + one->sha1, two->sha1, two->dirty_submodule,
> + del, add, reset);
> + return;
> + }
> }
>
> if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
> index 6c01d0c..ed4f3a8 100755
> --- a/t/t4041-diff-submodule-option.sh
> +++ b/t/t4041-diff-submodule-option.sh
> @@ -43,6 +43,16 @@ EOF
> test_cmp expected actual
> "
>
> +test_expect_success 'added submodule, set diff.submoduleFormat' "
> + git config diff.submoduleFormat log &&
> + git add sm1 &&
> + git diff --cached >actual &&
> + cat >expected <<-EOF &&
> +Submodule sm1 0000000...$head1 (new submodule)
> +EOF
> + test_cmp expected actual
> +"
> +
> commit_file sm1 &&
> head2=$(add_file sm1 foo3)
>
>
next prev parent reply other threads:[~2012-10-02 19:44 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
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 [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=506B4418.2050700@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).