[Outreachy] [PATCH] blame: Convert pickaxe_blame defined constants to enums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Convert pickaxe_blame preprocessor constants in blame.h to an enum.
Also replace previous instances of the constants with the new enum values.

Signed-off-by: Wambui Karuga <wambui.karugax@xxxxxxxxx>
---
 blame.c         |  8 ++++----
 blame.h         | 12 +++++++-----
 builtin/blame.c | 17 ++++++++---------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/blame.c b/blame.c
index 36a2e7ef11..4ad86d1217 100644
--- a/blame.c
+++ b/blame.c
@@ -2183,8 +2183,8 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
 	 * and this code needs to be after diff_setup_done(), which
 	 * usually makes find-copies-harder imply copy detection.
 	 */
-	if ((opt & PICKAXE_BLAME_COPY_HARDEST)
-	    || ((opt & PICKAXE_BLAME_COPY_HARDER)
+	if ((opt & BLAME_COPY_HARDEST)
+	    || ((opt & BLAME_COPY_HARDER)
 		&& (!porigin || strcmp(target->path, porigin->path))))
 		diff_opts.flags.find_copies_harder = 1;
 
@@ -2429,7 +2429,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
 	/*
 	 * Optionally find moves in parents' files.
 	 */
-	if (opt & PICKAXE_BLAME_MOVE) {
+	if (opt & BLAME_MOVE) {
 		filter_small(sb, &toosmall, &origin->suspects, sb->move_score);
 		if (origin->suspects) {
 			for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
@@ -2448,7 +2448,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
 	/*
 	 * Optionally find copies from parents' files.
 	 */
-	if (opt & PICKAXE_BLAME_COPY) {
+	if (opt & BLAME_COPY) {
 		if (sb->copy_score > sb->move_score)
 			filter_small(sb, &toosmall, &origin->suspects, sb->copy_score);
 		else if (sb->copy_score < sb->move_score) {
diff --git a/blame.h b/blame.h
index 4a9e1270b0..a4bbf3a8c5 100644
--- a/blame.h
+++ b/blame.h
@@ -8,14 +8,16 @@
 #include "prio-queue.h"
 #include "diff.h"
 
-#define PICKAXE_BLAME_MOVE		01
-#define PICKAXE_BLAME_COPY		02
-#define PICKAXE_BLAME_COPY_HARDER	04
-#define PICKAXE_BLAME_COPY_HARDEST	010
-
 #define BLAME_DEFAULT_MOVE_SCORE	20
 #define BLAME_DEFAULT_COPY_SCORE	40
 
+enum pickaxe_blame_action {
+	BLAME_MOVE = 01,
+	BLAME_COPY,
+	BLAME_COPY_HARDER = 04,
+	BLAME_COPY_HARDEST = 010,
+};
+
 /*
  * One blob in a commit that is being suspected
  */
diff --git a/builtin/blame.c b/builtin/blame.c
index b6534d4dea..fb71517b5c 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -771,11 +771,11 @@ static int blame_copy_callback(const struct option *option, const char *arg, int
 	 * -C -C -C enables copy from existing files for
 	 *          everybody
 	 */
-	if (*opt & PICKAXE_BLAME_COPY_HARDER)
-		*opt |= PICKAXE_BLAME_COPY_HARDEST;
-	if (*opt & PICKAXE_BLAME_COPY)
-		*opt |= PICKAXE_BLAME_COPY_HARDER;
-	*opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;
+	if (*opt & BLAME_COPY_HARDER)
+		*opt |= BLAME_COPY_HARDEST;
+	if (*opt & BLAME_COPY)
+		*opt |= BLAME_COPY_HARDER;
+	*opt |= BLAME_COPY | BLAME_MOVE;
 
 	if (arg)
 		blame_copy_score = parse_score(arg);
@@ -788,8 +788,7 @@ static int blame_move_callback(const struct option *option, const char *arg, int
 
 	BUG_ON_OPT_NEG(unset);
 
-	*opt |= PICKAXE_BLAME_MOVE;
-
+	*opt |= BLAME_MOVE;
 	if (arg)
 		blame_move_score = parse_score(arg);
 	return 0;
@@ -993,8 +992,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	blame_date_width -= 1; /* strip the null */
 
 	if (revs.diffopt.flags.find_copies_harder)
-		opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
-			PICKAXE_BLAME_COPY_HARDER);
+		opt |= (BLAME_COPY | BLAME_MOVE |
+			BLAME_COPY_HARDER);
 
 	/*
 	 * We have collected options unknown to us in argv[1..unk]
-- 
2.23.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux