From: Jacob Keller <jacob.keller@gmail.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: Git mailing list <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 3/3] diff: use skip_to_opt_val()
Date: Wed, 6 Dec 2017 16:16:43 -0800 [thread overview]
Message-ID: <CA+P7+xqD80v=CsbT003b7czro4CZ77CJMppAhbQOPo1ssqTsKA@mail.gmail.com> (raw)
In-Reply-To: <20171203170415.15939-3-chriscool@tuxfamily.org>
On Sun, Dec 3, 2017 at 9:04 AM, Christian Couder
<christian.couder@gmail.com> wrote:
> From: Christian Couder <christian.couder@gmail.com>
>
> Let's simplify diff option parsing using skip_to_opt_val().
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> diff.c | 22 ++++++++--------------
> 1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 2ebe2227b4..067b498187 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4508,17 +4508,11 @@ int diff_opt_parse(struct diff_options *options,
> options->output_format |= DIFF_FORMAT_NUMSTAT;
> else if (!strcmp(arg, "--shortstat"))
> options->output_format |= DIFF_FORMAT_SHORTSTAT;
> - else if (!strcmp(arg, "-X") || !strcmp(arg, "--dirstat"))
> - return parse_dirstat_opt(options, "");
> - else if (skip_prefix(arg, "-X", &arg))
> - return parse_dirstat_opt(options, arg);
> - else if (skip_prefix(arg, "--dirstat=", &arg))
> + else if (skip_prefix(arg, "-X", &arg) || skip_to_opt_val(arg, "--dirstat", &arg))
> return parse_dirstat_opt(options, arg);
> else if (!strcmp(arg, "--cumulative"))
> return parse_dirstat_opt(options, "cumulative");
> - else if (!strcmp(arg, "--dirstat-by-file"))
> - return parse_dirstat_opt(options, "files");
> - else if (skip_prefix(arg, "--dirstat-by-file=", &arg)) {
> + else if (skip_to_opt_val(arg, "--dirstat-by-file", &arg)) {
> parse_dirstat_opt(options, "files");
> return parse_dirstat_opt(options, arg);
> }
> @@ -4540,13 +4534,13 @@ int diff_opt_parse(struct diff_options *options,
> return stat_opt(options, av);
>
> /* renames options */
> - else if (starts_with(arg, "-B") || starts_with(arg, "--break-rewrites=") ||
> - !strcmp(arg, "--break-rewrites")) {
> + else if (starts_with(arg, "-B") ||
> + skip_to_opt_val(arg, "--break-rewrites", &optarg)) {
> if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
> return error("invalid argument to -B: %s", arg+2);
> }
> - else if (starts_with(arg, "-M") || starts_with(arg, "--find-renames=") ||
> - !strcmp(arg, "--find-renames")) {
> + else if (starts_with(arg, "-M") ||
> + skip_to_opt_val(arg, "--find-renames", &optarg)) {
> if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
> return error("invalid argument to -M: %s", arg+2);
> options->detect_rename = DIFF_DETECT_RENAME;
> @@ -4554,8 +4548,8 @@ int diff_opt_parse(struct diff_options *options,
> else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
> options->irreversible_delete = 1;
> }
> - else if (starts_with(arg, "-C") || starts_with(arg, "--find-copies=") ||
> - !strcmp(arg, "--find-copies")) {
> + else if (starts_with(arg, "-C") ||
> + skip_to_opt_val(arg, "--find-copies", &optarg)) {
> if (options->detect_rename == DIFF_DETECT_COPY)
> options->flags.find_copies_harder = 1;
> if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
> --
> 2.15.1.271.g1a4e40aa5d.dirty
>
This causes a regression in the --relative option which prevents it
from working properly.
If I have a repository with a modified file in a subdirectory, such as:
a/file
then git diff-index --relative --name-only HEAD from within "a" will
return "a/file" instead of "file"
This breaks git completion, (among other things).
Thanks,
Jake
next prev parent reply other threads:[~2017-12-07 0:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-03 17:04 [PATCH 1/3] git-compat-util: introduce skip_to_opt_val() Christian Couder
2017-12-03 17:04 ` [PATCH 2/3] index-pack: use skip_to_opt_val() Christian Couder
2017-12-03 17:04 ` [PATCH 3/3] diff: " Christian Couder
2017-12-07 0:16 ` Jacob Keller [this message]
2017-12-07 0:18 ` Jacob Keller
2017-12-07 6:26 ` Christian Couder
2017-12-03 18:45 ` [PATCH 1/3] git-compat-util: introduce skip_to_opt_val() Junio C Hamano
2017-12-03 20:34 ` Christian Couder
2017-12-03 22:48 ` Junio C Hamano
2017-12-04 7:59 ` Christian Couder
2017-12-04 13:35 ` 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
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='CA+P7+xqD80v=CsbT003b7czro4CZ77CJMppAhbQOPo1ssqTsKA@mail.gmail.com' \
--to=jacob.keller@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).