]>
git.proxmox.com Git - libgit2.git/blob - include/git2/signature.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_signature_h__
8 #define INCLUDE_git_signature_h__
14 * @file git2/signature.h
15 * @brief Git signature creation
16 * @defgroup git_signature Git signature creation
23 * Create a new action signature.
25 * Call `git_signature_free()` to free the data.
27 * Note: angle brackets ('<' and '>') characters are not allowed
28 * to be used in either the `name` or the `email` parameter.
30 * @param out new signature, in case of error NULL
31 * @param name name of the person
32 * @param email email of the person
33 * @param time time when the action happened
34 * @param offset timezone offset in minutes for the time
35 * @return 0 or an error code
37 GIT_EXTERN(int) git_signature_new(git_signature
**out
, const char *name
, const char *email
, git_time_t time
, int offset
);
40 * Create a new action signature with a timestamp of 'now'.
42 * Call `git_signature_free()` to free the data.
44 * @param out new signature, in case of error NULL
45 * @param name name of the person
46 * @param email email of the person
47 * @return 0 or an error code
49 GIT_EXTERN(int) git_signature_now(git_signature
**out
, const char *name
, const char *email
);
52 * Create a new action signature with default user and now timestamp.
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.
59 * @param out new signature
60 * @param repo repository pointer
61 * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code
63 GIT_EXTERN(int) git_signature_default(git_signature
**out
, git_repository
*repo
);
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).
72 * @param out new signature
73 * @param buf signature string
74 * @return 0 on success, or an error code
76 GIT_EXTERN(int) git_signature_from_buffer(git_signature
**out
, const char *buf
);
79 * Create a copy of an existing signature. All internal strings are also
82 * Call `git_signature_free()` to free the data.
84 * @param dest pointer where to store the copy
85 * @param sig signature to duplicate
86 * @return 0 or an error code
88 GIT_EXTERN(int) git_signature_dup(git_signature
**dest
, const git_signature
*sig
);
91 * Free an existing signature.
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.
97 * @param sig signature to free
99 GIT_EXTERN(void) git_signature_free(git_signature
*sig
);