Skip to content

Commit b5fa608

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6c09c0 commit b5fa608

File tree

11 files changed

+79
-59
lines changed

11 files changed

+79
-59
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "builtin.h"
1111
#include "diff.h"
1212
#include "hex.h"
13+
#include "ident.h"
1314
#include "parse-options.h"
1415
#include "userdiff.h"
1516
#include "streaming.h"

builtin/check-mailmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "config.h"
3+
#include "ident.h"
34
#include "mailmap.h"
45
#include "parse-options.h"
56
#include "string-list.h"

builtin/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "alloc.h"
33
#include "config.h"
44
#include "color.h"
5+
#include "ident.h"
56
#include "parse-options.h"
67
#include "urlmatch.h"
78
#include "quote.h"

builtin/var.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include "builtin.h"
77
#include "config.h"
8+
#include "ident.h"
89
#include "refs.h"
910

1011
static const char var_usage[] = "git var (-l | <variable>)";

cache.h

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,65 +1445,10 @@ struct object *repo_peel_to_type(struct repository *r,
14451445
#define peel_to_type(name, namelen, obj, type) \
14461446
repo_peel_to_type(the_repository, name, namelen, obj, type)
14471447

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);
14661448
const char *git_editor(void);
14671449
const char *git_sequence_editor(void);
14681450
const char *git_pager(int stdout_is_tty);
14691451
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 *);
15071452

15081453
struct cache_def {
15091454
struct strbuf path;
@@ -1570,9 +1515,6 @@ int update_server_info(int);
15701515
const char *get_log_output_encoding(void);
15711516
const char *get_commit_output_encoding(void);
15721517

1573-
int committer_ident_sufficiently_given(void);
1574-
int author_ident_sufficiently_given(void);
1575-
15761518
extern const char *git_commit_encoding;
15771519
extern const char *git_log_output_encoding;
15781520
extern const char *git_mailmap_file;

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "branch.h"
1212
#include "config.h"
1313
#include "environment.h"
14+
#include "ident.h"
1415
#include "repository.h"
1516
#include "lockfile.h"
1617
#include "exec-cmd.h"

gpg-interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "run-command.h"
55
#include "strbuf.h"
66
#include "dir.h"
7+
#include "ident.h"
78
#include "gpg-interface.h"
89
#include "sigchain.h"
910
#include "tempfile.h"

ident.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*
66
* Copyright (C) 2005 Linus Torvalds
77
*/
8-
#include "cache.h"
8+
#include "git-compat-util.h"
9+
#include "ident.h"
910
#include "config.h"
1011
#include "date.h"
12+
#include "gettext.h"
1113
#include "mailmap.h"
14+
#include "strbuf.h"
1215

1316
static struct strbuf git_default_name = STRBUF_INIT;
1417
static struct strbuf git_default_email = STRBUF_INIT;

ident.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "refs-internal.h"
66
#include "ref-cache.h"
77
#include "packed-backend.h"
8+
#include "../ident.h"
89
#include "../iterator.h"
910
#include "../dir-iterator.h"
1011
#include "../lockfile.h"

0 commit comments

Comments
 (0)