From: Wambui Karuga <wambui.karugax@gmail.com>
To: git@vger.kernel.org
Cc: jonathantanmy@google.com, Wambui Karuga <wambui.karugax@gmail.com>
Subject: [Outreachy] [PATCH] blame: Convert pickaxe_blame defined constants to enums
Date: Thu, 10 Oct 2019 14:52:30 +0300 [thread overview]
Message-ID: <20191010115230.10623-1-wambui.karugax@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2019-10-10 11:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 11:52 Wambui Karuga [this message]
2019-10-10 18:44 ` [Outreachy] [PATCH] blame: Convert pickaxe_blame defined constants to enums Jonathan Tan
2019-10-11 4:13 ` Junio C Hamano
2019-10-11 18:44 ` Jonathan Tan
2019-10-12 0:30 ` Junio C Hamano
2019-10-14 18:27 ` Jonathan Tan
2019-10-14 19:37 ` Wambui Karuga
2019-10-14 21:46 ` Jonathan Tan
2019-10-15 12:06 ` Wambui Karuga
2019-10-15 8:45 ` SZEDER Gábor
2019-10-11 8:52 ` Wambui Karuga
2019-10-11 18:48 ` Jonathan Tan
2019-10-11 20:04 ` Wambui Karuga
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=20191010115230.10623-1-wambui.karugax@gmail.com \
--to=wambui.karugax@gmail.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@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.
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).