summaryrefslogtreecommitdiff
path: root/ident.h
blob: 96a64896a0167381228af77cbfec4cb56c428ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef IDENT_H
#define IDENT_H

#include "string-list.h"

struct ident_split {
	const char *name_begin;
	const char *name_end;
	const char *mail_begin;
	const char *mail_end;
	const char *date_begin;
	const char *date_end;
	const char *tz_begin;
	const char *tz_end;
};

#define IDENT_STRICT	       1
#define IDENT_NO_DATE	       2
#define IDENT_NO_NAME	       4

enum want_ident {
	WANT_BLANK_IDENT,
	WANT_AUTHOR_IDENT,
	WANT_COMMITTER_IDENT
};

const char *ident_default_name(void);
const char *ident_default_email(void);
/*
 * Prepare an ident to fall back on if the user didn't configure it.
 */
void prepare_fallback_ident(const char *name, const char *email);
void reset_ident_date(void);
/*
 * Signals an success with 0, but time part of the result may be NULL
 * if the input lacks timestamp and zone
 */
int split_ident_line(struct ident_split *, const char *, int);

/*
 * Given a commit or tag object buffer and the commit or tag headers, replaces
 * the idents in the headers with their canonical versions using the mailmap mechanism.
 */
void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);

/*
 * Compare split idents for equality or strict ordering. Note that we
 * compare only the ident part of the line, ignoring any timestamp.
 *
 * Because there are two fields, we must choose one as the primary key; we
 * currently arbitrarily pick the email.
 */
int ident_cmp(const struct ident_split *, const struct ident_split *);

const char *git_author_info(int);
const char *git_committer_info(int);
const char *fmt_ident(const char *name, const char *email,
		      enum want_ident whose_ident,
		      const char *date_str, int);
const char *fmt_name(enum want_ident);

int committer_ident_sufficiently_given(void);
int author_ident_sufficiently_given(void);

int git_ident_config(const char *, const char *, void *);

#endif