From: Ben Boeckel <mathstuf@gmail.com>
To: git@vger.kernel.org
Cc: "Ben Boeckel" <mathstuf@gmail.com>, "Jeff King" <peff@peff.net>,
"Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v1 2/6] mailmap: move `git_default_mailmap_config` to `mailmap.c`
Date: Fri, 30 Jul 2021 22:42:17 -0400 [thread overview]
Message-ID: <20210731024221.2113906-3-mathstuf@gmail.com> (raw)
In-Reply-To: <20210731024221.2113906-1-mathstuf@gmail.com>
This allows mailmap-specific variables to be tracked locally in
`mailmap.c` instead of globally.
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
cache.h | 2 --
config.c | 12 +-----------
mailmap.c | 16 ++++++++++++++--
mailmap.h | 2 ++
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/cache.h b/cache.h
index 6ea1ea5854..551a6cb5cf 100644
--- a/cache.h
+++ b/cache.h
@@ -1718,8 +1718,6 @@ int author_ident_sufficiently_given(void);
extern const char *git_commit_encoding;
extern const char *git_log_output_encoding;
-extern const char *git_mailmap_file;
-extern const char *git_mailmap_blob;
/* IO helper functions */
void maybe_flush_or_die(FILE *, const char *);
diff --git a/config.c b/config.c
index 840be51710..c45001adbe 100644
--- a/config.c
+++ b/config.c
@@ -15,6 +15,7 @@
#include "strbuf.h"
#include "quote.h"
#include "hashmap.h"
+#include "mailmap.h"
#include "string-list.h"
#include "object-store.h"
#include "utf8.h"
@@ -1603,17 +1604,6 @@ static int git_default_push_config(const char *var, const char *value)
return 0;
}
-static int git_default_mailmap_config(const char *var, const char *value)
-{
- if (!strcmp(var, "mailmap.file"))
- return git_config_pathname(&git_mailmap_file, var, value);
- if (!strcmp(var, "mailmap.blob"))
- return git_config_string(&git_mailmap_blob, var, value);
-
- /* Add other config variables here and to Documentation/config.txt. */
- return 0;
-}
-
int git_default_config(const char *var, const char *value, void *cb)
{
if (starts_with(var, "core."))
diff --git a/mailmap.c b/mailmap.c
index d1f7c0d272..e1d9a2bbdb 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "config.h"
#include "string-list.h"
#include "mailmap.h"
#include "object-store.h"
@@ -12,8 +13,19 @@ static inline void debug_mm(const char *format, ...) {}
static inline const char *debug_str(const char *s) { return s; }
#endif
-const char *git_mailmap_file;
-const char *git_mailmap_blob;
+static const char *git_mailmap_file;
+static const char *git_mailmap_blob;
+
+int git_default_mailmap_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "mailmap.file"))
+ return git_config_pathname(&git_mailmap_file, var, value);
+ if (!strcmp(var, "mailmap.blob"))
+ return git_config_string(&git_mailmap_blob, var, value);
+
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
struct mailmap_info {
char *name;
diff --git a/mailmap.h b/mailmap.h
index 7e99fccb46..48bfe9fac7 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -3,6 +3,8 @@
struct string_list;
+int git_default_mailmap_config(const char *var, const char *value);
+
int read_mailmap(struct string_list *map);
void clear_mailmap(struct string_list *map);
--
2.31.1
next prev parent reply other threads:[~2021-07-31 2:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 2:42 [PATCH v1 0/6] globals: clean up some global usages Ben Boeckel
2021-07-31 2:42 ` [PATCH v1 1/6] branch: move `git_default_branch_config` to `branch.c` Ben Boeckel
2021-07-31 2:42 ` Ben Boeckel [this message]
2021-07-31 2:42 ` [PATCH v1 3/6] apply: move `apply_default_*whitespace` to `apply.c` Ben Boeckel
2021-07-31 2:42 ` [PATCH v1 4/6] config: remove `core_compression_level` Ben Boeckel
2021-07-31 2:42 ` [PATCH v1 5/6] refs/debug: declare file-local variable to be static Ben Boeckel
2021-07-31 2:42 ` [PATCH v1 6/6] globals: remove explicit `0` initialization from globals Ben Boeckel
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=20210731024221.2113906-3-mathstuf@gmail.com \
--to=mathstuf@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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).