git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 10/20] diff-parseopt: convert --[no-]follow
Date: Tue,  5 Mar 2019 19:30:16 +0700	[thread overview]
Message-ID: <20190305123026.7266-11-pclouds@gmail.com> (raw)
In-Reply-To: <20190305123026.7266-1-pclouds@gmail.com>

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/diff.c b/diff.c
index 689dc11684..ad813ea418 100644
--- a/diff.c
+++ b/diff.c
@@ -4986,6 +4986,21 @@ static int diff_opt_find_renames(const struct option *opt,
 	return 0;
 }
 
+static int diff_opt_follow(const struct option *opt,
+			   const char *arg, int unset)
+{
+	struct diff_options *options = opt->value;
+
+	BUG_ON_OPT_ARG(arg);
+	if (unset) {
+		options->flags.follow_renames = 0;
+		options->flags.default_follow_renames = 0;
+	} else {
+		options->flags.follow_renames = 1;
+	}
+	return 0;
+}
+
 static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
 					     const struct option *opt,
 					     const char *arg, int unset)
@@ -5172,6 +5187,9 @@ static void prep_parse_options(struct diff_options *options)
 			      0, PARSE_OPT_NONEG),
 		OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
 			 N_("use empty blobs as rename source")),
+		OPT_CALLBACK_F(0, "follow", options, NULL,
+			       N_("continue listing the history of a file beyond renames"),
+			       PARSE_OPT_NOARG, diff_opt_follow),
 
 		OPT_GROUP(N_("Diff algorithm options")),
 		OPT_BIT(0, "minimal", &options->xdl_opts,
@@ -5250,12 +5268,7 @@ int diff_opt_parse(struct diff_options *options,
 		return ac;
 
 	/* flags options */
-	if (!strcmp(arg, "--follow"))
-		options->flags.follow_renames = 1;
-	else if (!strcmp(arg, "--no-follow")) {
-		options->flags.follow_renames = 0;
-		options->flags.default_follow_renames = 0;
-	} else if (skip_to_optional_arg_default(arg, "--color", &arg, "always")) {
+	if (skip_to_optional_arg_default(arg, "--color", &arg, "always")) {
 		int value = git_config_colorbool(NULL, arg);
 		if (value < 0)
 			return error("option `color' expects \"always\", \"auto\", or \"never\"");
-- 
2.21.0.rc1.337.gdf7f8d0522


  parent reply	other threads:[~2019-03-05 12:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 12:30 [PATCH 00/20] nd/diff-parseopt part 3 Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 01/20] diff-parseopt: convert --[no-]indent-heuristic Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 02/20] diff-parseopt: convert --patience Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 03/20] diff-parseopt: convert --histogram Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 04/20] diff-parseopt: convert --diff-algorithm Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 05/20] diff-parseopt: convert --anchored Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 06/20] diff-parseopt: convert --binary Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 07/20] diff-parseopt: convert --full-index Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 08/20] diff-parseopt: convert -a|--text Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 09/20] diff-parseopt: convert -R Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` Nguyễn Thái Ngọc Duy [this message]
2019-03-05 12:30 ` [PATCH 11/20] diff-parseopt: convert --[no-]color Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 12/20] diff-parseopt: convert --word-diff Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 13/20] diff-parseopt: convert --word-diff-regex Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 14/20] diff-parseopt: convert --color-words Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 15/20] diff-parseopt: convert --exit-code Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 16/20] diff-parseopt: convert --quiet Nguyễn Thái Ngọc Duy
2019-03-05 15:42   ` Eric Sunshine
2019-03-06  9:25     ` Duy Nguyen
2019-03-05 12:30 ` [PATCH 17/20] diff-parseopt: convert --ext-diff Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 18/20] diff-parseopt: convert --textconv Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 19/20] diff-parseopt: convert --ignore-submodules Nguyễn Thái Ngọc Duy
2019-03-05 12:30 ` [PATCH 20/20] diff-parseopt: convert --submodule Nguyễn Thái Ngọc Duy

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=20190305123026.7266-11-pclouds@gmail.com \
    --to=pclouds@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).