All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, sbeller@google.com,
	Brandon Williams <bmwill@google.com>
Subject: [PATCH v2 7/4] diff: remove DIFF_OPT_CLR macro
Date: Mon, 30 Oct 2017 15:19:55 -0700	[thread overview]
Message-ID: <20171030221956.92466-3-bmwill@google.com> (raw)
In-Reply-To: <20171030221956.92466-1-bmwill@google.com>

Remove the `DIFF_OPT_SET` macro and instead set the flags directly.
This conversion is done using the following semantic patch:

	@@
	expression E;
	identifier fld;
	@@
	- DIFF_OPT_CLR(&E, fld)
	+ E.flags.fld = 0

	@@
	type T;
	T *ptr;
	identifier fld;
	@@
	- DIFF_OPT_CLR(ptr, fld)
	+ ptr->flags.fld = 0

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/blame.c   |  2 +-
 combine-diff.c    |  2 +-
 diff.c            | 30 +++++++++++++++---------------
 diff.h            |  2 --
 merge-recursive.c |  2 +-
 revision.c        |  4 ++--
 submodule.c       |  6 +++---
 7 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 76994aa64..79db9e849 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -736,7 +736,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 parse_done:
 	no_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;
 	xdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;
-	DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
+	revs.diffopt.flags.FOLLOW_RENAMES = 0;
 	argc = parse_options_end(&ctx);
 
 	if (incremental || (output_option & OUTPUT_PORCELAIN)) {
diff --git a/combine-diff.c b/combine-diff.c
index 204b0dfce..5a3a8b49b 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1414,7 +1414,7 @@ void diff_tree_combined(const struct object_id *oid,
 	diffopts = *opt;
 	copy_pathspec(&diffopts.pathspec, &opt->pathspec);
 	diffopts.flags.RECURSIVE = 1;
-	DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
+	diffopts.flags.ALLOW_EXTERNAL = 0;
 
 	/* find set of paths that everybody touches
 	 *
diff --git a/diff.c b/diff.c
index 16d33c319..0e5abb5ce 100644
--- a/diff.c
+++ b/diff.c
@@ -124,16 +124,16 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
 	for (i = 0; i < params.nr; i++) {
 		const char *p = params.items[i].string;
 		if (!strcmp(p, "changes")) {
-			DIFF_OPT_CLR(options, DIRSTAT_BY_LINE);
-			DIFF_OPT_CLR(options, DIRSTAT_BY_FILE);
+			options->flags.DIRSTAT_BY_LINE = 0;
+			options->flags.DIRSTAT_BY_FILE = 0;
 		} else if (!strcmp(p, "lines")) {
 			options->flags.DIRSTAT_BY_LINE = 1;
-			DIFF_OPT_CLR(options, DIRSTAT_BY_FILE);
+			options->flags.DIRSTAT_BY_FILE = 0;
 		} else if (!strcmp(p, "files")) {
-			DIFF_OPT_CLR(options, DIRSTAT_BY_LINE);
+			options->flags.DIRSTAT_BY_LINE = 0;
 			options->flags.DIRSTAT_BY_FILE = 1;
 		} else if (!strcmp(p, "noncumulative")) {
-			DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);
+			options->flags.DIRSTAT_CUMULATIVE = 0;
 		} else if (!strcmp(p, "cumulative")) {
 			options->flags.DIRSTAT_CUMULATIVE = 1;
 		} else if (isdigit(*p)) {
@@ -4205,7 +4205,7 @@ void diff_setup_done(struct diff_options *options)
 	    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
 		options->flags.DIFF_FROM_CONTENTS = 1;
 	else
-		DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);
+		options->flags.DIFF_FROM_CONTENTS = 0;
 
 	if (options->flags.FIND_COPIES_HARDER)
 		options->detect_rename = DIFF_DETECT_COPY;
@@ -4640,7 +4640,7 @@ int diff_opt_parse(struct diff_options *options,
 	else if (!strcmp(arg, "--rename-empty"))
 		options->flags.RENAME_EMPTY = 1;
 	else if (!strcmp(arg, "--no-rename-empty"))
-		DIFF_OPT_CLR(options, RENAME_EMPTY);
+		options->flags.RENAME_EMPTY = 0;
 	else if (!strcmp(arg, "--relative"))
 		options->flags.RELATIVE_NAME = 1;
 	else if (skip_prefix(arg, "--relative=", &arg)) {
@@ -4697,8 +4697,8 @@ int diff_opt_parse(struct diff_options *options,
 	else if (!strcmp(arg, "--follow"))
 		options->flags.FOLLOW_RENAMES = 1;
 	else if (!strcmp(arg, "--no-follow")) {
-		DIFF_OPT_CLR(options, FOLLOW_RENAMES);
-		DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);
+		options->flags.FOLLOW_RENAMES = 0;
+		options->flags.DEFAULT_FOLLOW_RENAMES = 0;
 	} else if (!strcmp(arg, "--color"))
 		options->use_color = 1;
 	else if (skip_prefix(arg, "--color=", &arg)) {
@@ -4761,13 +4761,13 @@ int diff_opt_parse(struct diff_options *options,
 	else if (!strcmp(arg, "--ext-diff"))
 		options->flags.ALLOW_EXTERNAL = 1;
 	else if (!strcmp(arg, "--no-ext-diff"))
-		DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
+		options->flags.ALLOW_EXTERNAL = 0;
 	else if (!strcmp(arg, "--textconv")) {
 		options->flags.ALLOW_TEXTCONV = 1;
 		options->flags.TEXTCONV_SET_VIA_CMDLINE = 1;
 	} else if (!strcmp(arg, "--no-textconv")) {
-		DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
-		DIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);
+		options->flags.ALLOW_TEXTCONV = 0;
+		options->flags.TEXTCONV_SET_VIA_CMDLINE = 0;
 	} else if (!strcmp(arg, "--ignore-submodules")) {
 		options->flags.OVERRIDE_SUBMODULE_CONFIG = 1;
 		handle_ignore_submodules_arg(options, "all");
@@ -4851,7 +4851,7 @@ int diff_opt_parse(struct diff_options *options,
 	else if (!strcmp(arg, "--function-context"))
 		options->flags.FUNCCONTEXT = 1;
 	else if (!strcmp(arg, "--no-function-context"))
-		DIFF_OPT_CLR(options, FUNCCONTEXT);
+		options->flags.FUNCCONTEXT = 0;
 	else if ((argcount = parse_long_opt("output", av, &optarg))) {
 		char *path = prefix_filename(prefix, optarg);
 		options->file = xfopen(path, "w");
@@ -5689,7 +5689,7 @@ void diff_flush(struct diff_options *options)
 		if (options->found_changes)
 			options->flags.HAS_CHANGES = 1;
 		else
-			DIFF_OPT_CLR(options, HAS_CHANGES);
+			options->flags.HAS_CHANGES = 0;
 	}
 }
 
@@ -5861,7 +5861,7 @@ void diffcore_std(struct diff_options *options)
 	if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)
 		options->flags.HAS_CHANGES = 1;
 	else
-		DIFF_OPT_CLR(options, HAS_CHANGES);
+		options->flags.HAS_CHANGES = 0;
 
 	options->found_follow = 0;
 }
diff --git a/diff.h b/diff.h
index 4c1af4be6..f68fcf737 100644
--- a/diff.h
+++ b/diff.h
@@ -110,8 +110,6 @@ static inline struct diff_flags diff_flags_or(const struct diff_flags *a,
 	return out;
 }
 
-#define DIFF_OPT_CLR(opts, flag)	((opts)->flags.flag = 0)
-
 #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)
 #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)
 #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)
diff --git a/merge-recursive.c b/merge-recursive.c
index e7b3df45c..9752aba4e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -541,7 +541,7 @@ static struct string_list *get_renames(struct merge_options *o,
 
 	diff_setup(&opts);
 	opts.flags.RECURSIVE = 1;
-	DIFF_OPT_CLR(&opts, RENAME_EMPTY);
+	opts.flags.RENAME_EMPTY = 0;
 	opts.detect_rename = DIFF_DETECT_RENAME;
 	opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
 			    o->diff_rename_limit >= 0 ? o->diff_rename_limit :
diff --git a/revision.c b/revision.c
index f019dd277..6bb873501 100644
--- a/revision.c
+++ b/revision.c
@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
 	}
 
 	tree_difference = REV_TREE_SAME;
-	DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
+	revs->pruning.flags.HAS_CHANGES = 0;
 	if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
 			   &revs->pruning) < 0)
 		return REV_TREE_DIFFERENT;
@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 		return 0;
 
 	tree_difference = REV_TREE_SAME;
-	DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
+	revs->pruning.flags.HAS_CHANGES = 0;
 	retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
 
 	return retval >= 0 && (tree_difference == REV_TREE_SAME);
diff --git a/submodule.c b/submodule.c
index 7e7998592..62a93bb88 100644
--- a/submodule.c
+++ b/submodule.c
@@ -402,9 +402,9 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
 void handle_ignore_submodules_arg(struct diff_options *diffopt,
 				  const char *arg)
 {
-	DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);
-	DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
-	DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);
+	diffopt->flags.IGNORE_SUBMODULES = 0;
+	diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;
+	diffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;
 
 	if (!strcmp(arg, "all"))
 		diffopt->flags.IGNORE_SUBMODULES = 1;
-- 
2.15.0.403.gc27cc4dac6-goog


  parent reply	other threads:[~2017-10-30 22:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27 22:28 [PATCH 0/3] convert diff flags to be stored in a struct Brandon Williams
2017-10-27 22:28 ` [PATCH 1/3] add: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-27 22:28 ` [PATCH 2/3] reset: " Brandon Williams
2017-10-29  1:26   ` Junio C Hamano
2017-10-30 18:06     ` Brandon Williams
2017-10-27 22:28 ` [PATCH 3/3] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-29  1:55   ` Junio C Hamano
2017-10-30  0:29     ` Junio C Hamano
2017-10-30 19:39       ` Brandon Williams
2017-10-31  2:49       ` Junio C Hamano
2017-10-30 17:49     ` Brandon Williams
2017-10-29  1:22 ` [PATCH 0/3] convert diff flags to be stored in a struct Junio C Hamano
2017-10-29  4:37   ` Stefan Beller
2017-10-30 19:46 ` [PATCH v2 0/4] " Brandon Williams
2017-10-30 19:46   ` [PATCH v2 1/4] add, reset: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-30 19:46   ` [PATCH v2 2/4] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-31  4:41     ` Junio C Hamano
2017-10-31  5:23     ` [PATCH 2.5/4] diff: avoid returning a struct by value from diff_flags_or() Junio C Hamano
2017-10-31 17:51       ` Brandon Williams
2017-10-30 19:46   ` [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline Brandon Williams
2017-10-30 20:41     ` Stefan Beller
2017-10-30 20:44       ` Brandon Williams
2017-10-30 20:48         ` Brandon Williams
2017-10-31  5:02     ` Junio C Hamano
2017-10-31  5:23     ` [PATCH 3.5/4] diff: set TEXTCONV_VIA_CMDLINE only when it is set to true Junio C Hamano
2017-10-31 17:55       ` Brandon Williams
2017-10-30 19:46   ` [PATCH v2 4/4] diff: remove touched flags Brandon Williams
2017-10-30 22:19   ` [PATCH v2 5/4] diff: remove DIFF_OPT_TST macro Brandon Williams
2017-10-30 22:19     ` [PATCH v2 6/4] diff: remove DIFF_OPT_SET macro Brandon Williams
2017-10-30 22:19     ` Brandon Williams [this message]
2017-10-30 22:19     ` [PATCH v2 8/4] diff: make struct diff_flags members lowercase Brandon Williams
2017-10-31 18:19   ` [PATCH v3 0/8] convert diff flags to be stored in a struct Brandon Williams
2017-10-31 18:19     ` [PATCH v3 1/8] add, reset: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-31 18:19     ` [PATCH v3 2/8] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-31 21:32       ` Stefan Beller
2017-11-01  1:26         ` Junio C Hamano
2017-11-01 17:11           ` Stefan Beller
2017-10-31 18:19     ` [PATCH v3 3/8] diff: add flag to indicate textconv was set via cmdline Brandon Williams
2017-10-31 18:19     ` [PATCH v3 4/8] diff: remove touched flags Brandon Williams
2017-10-31 18:19     ` [PATCH v3 5/8] diff: remove DIFF_OPT_TST macro Brandon Williams
2017-10-31 18:19     ` [PATCH v3 6/8] diff: remove DIFF_OPT_SET macro Brandon Williams
2017-10-31 18:19     ` [PATCH v3 7/8] diff: remove DIFF_OPT_CLR macro Brandon Williams
2017-10-31 21:44       ` Stefan Beller
2017-11-01  2:52         ` Junio C Hamano
2017-10-31 18:19     ` [PATCH v3 8/8] diff: make struct diff_flags members lowercase Brandon Williams
2017-10-31 21:46     ` [PATCH v3 0/8] convert diff flags to be stored in a struct Stefan Beller
2017-11-01  6:23     ` 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=20171030221956.92466-3-bmwill@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sbeller@google.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.
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.