]>
Commit | Line | Data |
---|---|---|
638c2ca4 | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
638c2ca4 | 3 | * |
bb742ede VM |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
638c2ca4 VM |
6 | */ |
7 | #ifndef INCLUDE_git_signature_h__ | |
8 | #define INCLUDE_git_signature_h__ | |
9 | ||
10 | #include "common.h" | |
11 | #include "types.h" | |
12 | ||
13 | /** | |
14 | * @file git2/signature.h | |
15 | * @brief Git signature creation | |
16 | * @defgroup git_signature Git signature creation | |
17 | * @ingroup Git | |
18 | * @{ | |
19 | */ | |
20 | GIT_BEGIN_DECL | |
21 | ||
22 | /** | |
ca94e031 RB |
23 | * Create a new action signature. |
24 | * | |
25 | * Call `git_signature_free()` to free the data. | |
638c2ca4 | 26 | * |
8aedf1d5 | 27 | * Note: angle brackets ('<' and '>') characters are not allowed |
28 | * to be used in either the `name` or the `email` parameter. | |
29 | * | |
ff6b5ac9 | 30 | * @param out new signature, in case of error NULL |
b5c00c6d | 31 | * @param name name of the person |
d144c569 | 32 | * @param email email of the person |
ac3d33df JK |
33 | * @param time time (in seconds from epoch) when the action happened |
34 | * @param offset timezone offset (in minutes) for the time | |
e172cf08 | 35 | * @return 0 or an error code |
638c2ca4 | 36 | */ |
ff6b5ac9 | 37 | GIT_EXTERN(int) git_signature_new(git_signature **out, const char *name, const char *email, git_time_t time, int offset); |
638c2ca4 | 38 | |
9e9e6ae1 | 39 | /** |
ca94e031 RB |
40 | * Create a new action signature with a timestamp of 'now'. |
41 | * | |
42 | * Call `git_signature_free()` to free the data. | |
9e9e6ae1 | 43 | * |
ff6b5ac9 | 44 | * @param out new signature, in case of error NULL |
9e9e6ae1 CMN |
45 | * @param name name of the person |
46 | * @param email email of the person | |
e172cf08 | 47 | * @return 0 or an error code |
9e9e6ae1 | 48 | */ |
ff6b5ac9 | 49 | GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const char *email); |
9e9e6ae1 | 50 | |
ce23330f RB |
51 | /** |
52 | * Create a new action signature with default user and now timestamp. | |
53 | * | |
54 | * This looks up the user.name and user.email from the configuration and | |
55 | * uses the current time as the timestamp, and creates a new signature | |
56 | * based on that information. It will return GIT_ENOTFOUND if either the | |
57 | * user.name or user.email are not set. | |
58 | * | |
59 | * @param out new signature | |
60 | * @param repo repository pointer | |
61 | * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code | |
62 | */ | |
63 | GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo); | |
9e9e6ae1 | 64 | |
d383c39b ET |
65 | /** |
66 | * Create a new signature by parsing the given buffer, which is | |
67 | * expected to be in the format "Real Name <email> timestamp tzoffset", | |
68 | * where `timestamp` is the number of seconds since the Unix epoch and | |
69 | * `tzoffset` is the timezone offset in `hhmm` format (note the lack | |
70 | * of a colon separator). | |
71 | * | |
72 | * @param out new signature | |
73 | * @param buf signature string | |
e579e0f7 | 74 | * @return 0 on success, GIT_EINVALID if the signature is not parseable, or an error code |
d383c39b ET |
75 | */ |
76 | GIT_EXTERN(int) git_signature_from_buffer(git_signature **out, const char *buf); | |
77 | ||
638c2ca4 | 78 | /** |
ca94e031 RB |
79 | * Create a copy of an existing signature. All internal strings are also |
80 | * duplicated. | |
81 | * | |
82 | * Call `git_signature_free()` to free the data. | |
638c2ca4 | 83 | * |
29be3a6d | 84 | * @param dest pointer where to store the copy |
31b0cb51 | 85 | * @param sig signature to duplicate |
29be3a6d | 86 | * @return 0 or an error code |
638c2ca4 | 87 | */ |
29be3a6d | 88 | GIT_EXTERN(int) git_signature_dup(git_signature **dest, const git_signature *sig); |
638c2ca4 VM |
89 | |
90 | /** | |
ca94e031 RB |
91 | * Free an existing signature. |
92 | * | |
93 | * Because the signature is not an opaque structure, it is legal to free it | |
94 | * manually, but be sure to free the "name" and "email" strings in addition | |
95 | * to the structure itself. | |
638c2ca4 | 96 | * |
b5c00c6d | 97 | * @param sig signature to free |
638c2ca4 VM |
98 | */ |
99 | GIT_EXTERN(void) git_signature_free(git_signature *sig); | |
100 | ||
101 | /** @} */ | |
102 | GIT_END_DECL | |
103 | #endif |