ident.h: move ident-related declarations out of cache.h

These functions were all defined in a separate ident.c already, so create ident.h and move the declarations into that file. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 24, 2023 at 00:09 UTC b5fa608180d4270b3495258ab098426551a18372
11 files changed +79 -59
builtin/cat-file.c
+1
@@ -10,6 +10,7 @@
10 #include "builtin.h"
11 #include "diff.h"
12 #include "hex.h"
13 +#include "ident.h"
14 #include "parse-options.h"
15 #include "userdiff.h"
16 #include "streaming.h"
builtin/check-mailmap.c
+1
@@ -1,5 +1,6 @@
1 #include "builtin.h"
2 #include "config.h"
3 +#include "ident.h"
4 #include "mailmap.h"
5 #include "parse-options.h"
6 #include "string-list.h"
builtin/config.c
+1
@@ -2,6 +2,7 @@
2 #include "alloc.h"
3 #include "config.h"
4 #include "color.h"
5 +#include "ident.h"
6 #include "parse-options.h"
7 #include "urlmatch.h"
8 #include "quote.h"
builtin/var.c
+1
@@ -5,6 +5,7 @@
5 */
6 #include "builtin.h"
7 #include "config.h"
8 +#include "ident.h"
9 #include "refs.h"
10
11 static const char var_usage[] = "git var (-l | <variable>)";
cache.h
-58
@@ -1445,65 +1445,10 @@ struct object *repo_peel_to_type(struct repository *r,
1445 #define peel_to_type(name, namelen, obj, type) \
1446 repo_peel_to_type(the_repository, name, namelen, obj, type)
1447
1448 -#define IDENT_STRICT 1
1449 -#define IDENT_NO_DATE 2
1450 -#define IDENT_NO_NAME 4
1451 -
1452 -enum want_ident {
1453 - WANT_BLANK_IDENT,
1454 - WANT_AUTHOR_IDENT,
1455 - WANT_COMMITTER_IDENT
1456 -};
1457 -
1458 -const char *git_author_info(int);
1459 -const char *git_committer_info(int);
1460 -const char *fmt_ident(const char *name, const char *email,
1461 - enum want_ident whose_ident,
1462 - const char *date_str, int);
1463 -const char *fmt_name(enum want_ident);
1464 -const char *ident_default_name(void);
1465 -const char *ident_default_email(void);
1448 const char *git_editor(void);
1449 const char *git_sequence_editor(void);
1450 const char *git_pager(int stdout_is_tty);
1451 int is_terminal_dumb(void);
1470 -int git_ident_config(const char *, const char *, void *);
1471 -/*
1472 - * Prepare an ident to fall back on if the user didn't configure it.
1473 - */
1474 -void prepare_fallback_ident(const char *name, const char *email);
1475 -void reset_ident_date(void);
1476 -
1477 -struct ident_split {
1478 - const char *name_begin;
1479 - const char *name_end;
1480 - const char *mail_begin;
1481 - const char *mail_end;
1482 - const char *date_begin;
1483 - const char *date_end;
1484 - const char *tz_begin;
1485 - const char *tz_end;
1486 -};
1487 -/*
1488 - * Signals an success with 0, but time part of the result may be NULL
1489 - * if the input lacks timestamp and zone
1490 - */
1491 -int split_ident_line(struct ident_split *, const char *, int);
1492 -
1493 -/*
1494 - * Given a commit or tag object buffer and the commit or tag headers, replaces
1495 - * the idents in the headers with their canonical versions using the mailmap mechanism.
1496 - */
1497 -void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);
1498 -
1499 -/*
1500 - * Compare split idents for equality or strict ordering. Note that we
1501 - * compare only the ident part of the line, ignoring any timestamp.
1502 - *
1503 - * Because there are two fields, we must choose one as the primary key; we
1504 - * currently arbitrarily pick the email.
1505 - */
1506 -int ident_cmp(const struct ident_split *, const struct ident_split *);
1452
1453 struct cache_def {
1454 struct strbuf path;
@@ -1570,9 +1515,6 @@ int update_server_info(int);
1515 const char *get_log_output_encoding(void);
1516 const char *get_commit_output_encoding(void);
1517
1573 -int committer_ident_sufficiently_given(void);
1574 -int author_ident_sufficiently_given(void);
1575 -
1518 extern const char *git_commit_encoding;
1519 extern const char *git_log_output_encoding;
1520 extern const char *git_mailmap_file;
config.c
+1
@@ -11,6 +11,7 @@
11 #include "branch.h"
12 #include "config.h"
13 #include "environment.h"
14 +#include "ident.h"
15 #include "repository.h"
16 #include "lockfile.h"
17 #include "exec-cmd.h"
gpg-interface.c
+1
@@ -4,6 +4,7 @@
4 #include "run-command.h"
5 #include "strbuf.h"
6 #include "dir.h"
7 +#include "ident.h"
8 #include "gpg-interface.h"
9 #include "sigchain.h"
10 #include "tempfile.h"
ident.c
+4 -1
@@ -5,10 +5,13 @@
5 *
6 * Copyright (C) 2005 Linus Torvalds
7 */
8 -#include "cache.h"
8 +#include "git-compat-util.h"
9 +#include "ident.h"
10 #include "config.h"
11 #include "date.h"
12 +#include "gettext.h"
13 #include "mailmap.h"
14 +#include "strbuf.h"
15
16 static struct strbuf git_default_name = STRBUF_INIT;
17 static struct strbuf git_default_email = STRBUF_INIT;
ident.h new
+67
@@ -0,0 +1,67 @@
1 +#ifndef IDENT_H
2 +#define IDENT_H
3 +
4 +#include "string-list.h"
5 +
6 +struct ident_split {
7 + const char *name_begin;
8 + const char *name_end;
9 + const char *mail_begin;
10 + const char *mail_end;
11 + const char *date_begin;
12 + const char *date_end;
13 + const char *tz_begin;
14 + const char *tz_end;
15 +};
16 +
17 +#define IDENT_STRICT 1
18 +#define IDENT_NO_DATE 2
19 +#define IDENT_NO_NAME 4
20 +
21 +enum want_ident {
22 + WANT_BLANK_IDENT,
23 + WANT_AUTHOR_IDENT,
24 + WANT_COMMITTER_IDENT
25 +};
26 +
27 +const char *ident_default_name(void);
28 +const char *ident_default_email(void);
29 +/*
30 + * Prepare an ident to fall back on if the user didn't configure it.
31 + */
32 +void prepare_fallback_ident(const char *name, const char *email);
33 +void reset_ident_date(void);
34 +/*
35 + * Signals an success with 0, but time part of the result may be NULL
36 + * if the input lacks timestamp and zone
37 + */
38 +int split_ident_line(struct ident_split *, const char *, int);
39 +
40 +/*
41 + * Given a commit or tag object buffer and the commit or tag headers, replaces
42 + * the idents in the headers with their canonical versions using the mailmap mechanism.
43 + */
44 +void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);
45 +
46 +/*
47 + * Compare split idents for equality or strict ordering. Note that we
48 + * compare only the ident part of the line, ignoring any timestamp.
49 + *
50 + * Because there are two fields, we must choose one as the primary key; we
51 + * currently arbitrarily pick the email.
52 + */
53 +int ident_cmp(const struct ident_split *, const struct ident_split *);
54 +
55 +const char *git_author_info(int);
56 +const char *git_committer_info(int);
57 +const char *fmt_ident(const char *name, const char *email,
58 + enum want_ident whose_ident,
59 + const char *date_str, int);
60 +const char *fmt_name(enum want_ident);
61 +
62 +int committer_ident_sufficiently_given(void);
63 +int author_ident_sufficiently_given(void);
64 +
65 +int git_ident_config(const char *, const char *, void *);
66 +
67 +#endif
refs/files-backend.c
+1
@@ -5,6 +5,7 @@
5 #include "refs-internal.h"
6 #include "ref-cache.h"
7 #include "packed-backend.h"
8 +#include "../ident.h"
9 #include "../iterator.h"
10 #include "../dir-iterator.h"
11 #include "../lockfile.h"
revision.h
+1
@@ -8,6 +8,7 @@
8 #include "pretty.h"
9 #include "diff.h"
10 #include "commit-slab-decl.h"
11 +#include "ident.h"
12 #include "list-objects-filter-options.h"
13
14 /**