Skip to content

Commit b6625a3

Browse files
authored
Merge pull request libgit2#5128 from tiennou/fix/docs
More documentation
2 parents 3d22394 + 33448b4 commit b6625a3

File tree

7 files changed

+124
-70
lines changed

7 files changed

+124
-70
lines changed

include/git2/apply.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ typedef int GIT_CALLBACK(git_apply_hunk_cb)(
6262
* @see git_apply_to_tree, git_apply
6363
*/
6464
typedef struct {
65-
unsigned int version;
65+
unsigned int version; /**< The version */
6666

67+
/** When applying a patch, callback that will be made per delta (file). */
6768
git_apply_delta_cb delta_cb;
69+
70+
/** When applying a patch, callback that will be made per hunk. */
6871
git_apply_hunk_cb hunk_cb;
72+
73+
/** Payload passed to both delta_cb & hunk_cb. */
6974
void *payload;
7075
} git_apply_options;
7176

include/git2/buffer.h

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,32 @@ GIT_BEGIN_DECL
3232
* a block of memory they hold. In this case, libgit2 will not resize or
3333
* free the memory, but will read from it as needed.
3434
*
35-
* A `git_buf` is a public structure with three fields:
36-
*
37-
* - `ptr` points to the start of the allocated memory. If it is NULL,
38-
* then the `git_buf` is considered empty and libgit2 will feel free
39-
* to overwrite it with new data.
40-
*
41-
* - `size` holds the size (in bytes) of the data that is actually used.
42-
*
43-
* - `asize` holds the known total amount of allocated memory if the `ptr`
44-
* was allocated by libgit2. It may be larger than `size`. If `ptr`
45-
* was not allocated by libgit2 and should not be resized and/or freed,
46-
* then `asize` will be set to zero.
47-
*
4835
* Some APIs may occasionally do something slightly unusual with a buffer,
4936
* such as setting `ptr` to a value that was passed in by the user. In
5037
* those cases, the behavior will be clearly documented by the API.
5138
*/
5239
typedef struct {
40+
/**
41+
* The buffer contents.
42+
*
43+
* `ptr` points to the start of the allocated memory. If it is NULL,
44+
* then the `git_buf` is considered empty and libgit2 will feel free
45+
* to overwrite it with new data.
46+
*/
5347
char *ptr;
54-
size_t asize, size;
48+
49+
/**
50+
* `asize` holds the known total amount of allocated memory if the `ptr`
51+
* was allocated by libgit2. It may be larger than `size`. If `ptr`
52+
* was not allocated by libgit2 and should not be resized and/or freed,
53+
* then `asize` will be set to zero.
54+
*/
55+
size_t asize;
56+
57+
/**
58+
* `size` holds the size (in bytes) of the data that is actually used.
59+
*/
60+
size_t size;
5561
} git_buf;
5662

5763
/**

include/git2/checkout.h

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ typedef void GIT_CALLBACK(git_checkout_perfdata_cb)(
261261
*
262262
*/
263263
typedef struct git_checkout_options {
264-
unsigned int version;
264+
unsigned int version; /**< The version */
265265

266266
unsigned int checkout_strategy; /**< default will be a safe checkout */
267267

@@ -271,29 +271,46 @@ typedef struct git_checkout_options {
271271
int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */
272272

273273
unsigned int notify_flags; /**< see `git_checkout_notify_t` above */
274+
275+
/**
276+
* Optional callback to get notifications on specific file states.
277+
* @see git_checkout_notify_t
278+
*/
274279
git_checkout_notify_cb notify_cb;
280+
281+
/** Payload passed to notify_cb */
275282
void *notify_payload;
276283

277284
/** Optional callback to notify the consumer of checkout progress. */
278285
git_checkout_progress_cb progress_cb;
286+
287+
/** Payload passed to progress_cb */
279288
void *progress_payload;
280289

281-
/** When not zeroed out, array of fnmatch patterns specifying which
282-
* paths should be taken into account, otherwise all files. Use
283-
* GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list.
290+
/**
291+
* A list of wildmatch patterns or paths.
292+
*
293+
* By default, all paths are processed. If you pass an array of wildmatch
294+
* patterns, those will be used to filter which paths should be taken into
295+
* account.
296+
*
297+
* Use GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as a simple list.
284298
*/
285299
git_strarray paths;
286300

287-
/** The expected content of the working directory; defaults to HEAD.
288-
* If the working directory does not match this baseline information,
289-
* that will produce a checkout conflict.
301+
/**
302+
* The expected content of the working directory; defaults to HEAD.
303+
*
304+
* If the working directory does not match this baseline information,
305+
* that will produce a checkout conflict.
290306
*/
291307
git_tree *baseline;
292308

293-
/** Like `baseline` above, though expressed as an index. This
294-
* option overrides `baseline`.
309+
/**
310+
* Like `baseline` above, though expressed as an index. This
311+
* option overrides `baseline`.
295312
*/
296-
git_index *baseline_index; /**< expected content of workdir, expressed as an index. */
313+
git_index *baseline_index;
297314

298315
const char *target_directory; /**< alternative checkout path to workdir */
299316

@@ -303,6 +320,8 @@ typedef struct git_checkout_options {
303320

304321
/** Optional callback to notify the consumer of performance data. */
305322
git_checkout_perfdata_cb perfdata_cb;
323+
324+
/** Payload passed to perfdata_cb */
306325
void *perfdata_payload;
307326
} git_checkout_options;
308327

include/git2/remote.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *
495495
* about the progress of the network operations.
496496
*/
497497
struct git_remote_callbacks {
498-
unsigned int version;
498+
unsigned int version; /**< The version */
499+
499500
/**
500501
* Textual progress from the remote. Text send over the
501502
* progress side-band will be passed to this function (this is

include/git2/status.h

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,27 +163,36 @@ typedef enum {
163163
/**
164164
* Options to control how `git_status_foreach_ext()` will issue callbacks.
165165
*
166-
* This structure is set so that zeroing it out will give you relatively
167-
* sane defaults.
166+
* Initialize with `GIT_STATUS_OPTIONS_INIT`. Alternatively, you can
167+
* use `git_status_options_init`.
168168
*
169-
* The `show` value is one of the `git_status_show_t` constants that
170-
* control which files to scan and in what order.
171-
*
172-
* The `flags` value is an OR'ed combination of the `git_status_opt_t`
173-
* values above.
174-
*
175-
* The `pathspec` is an array of path patterns to match (using
176-
* fnmatch-style matching), or just an array of paths to match exactly if
177-
* `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
178-
*
179-
* The `baseline` is the tree to be used for comparison to the working directory
180-
* and index; defaults to HEAD.
181169
*/
182170
typedef struct {
183-
unsigned int version;
171+
unsigned int version; /**< The version */
172+
173+
/**
174+
* The `show` value is one of the `git_status_show_t` constants that
175+
* control which files to scan and in what order.
176+
*/
184177
git_status_show_t show;
178+
179+
/**
180+
* The `flags` value is an OR'ed combination of the `git_status_opt_t`
181+
* values above.
182+
*/
185183
unsigned int flags;
184+
185+
/**
186+
* The `pathspec` is an array of path patterns to match (using
187+
* fnmatch-style matching), or just an array of paths to match exactly if
188+
* `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
189+
*/
186190
git_strarray pathspec;
191+
192+
/**
193+
* The `baseline` is the tree to be used for comparison to the working directory
194+
* and index; defaults to HEAD.
195+
*/
187196
git_tree *baseline;
188197
} git_status_options;
189198

include/git2/sys/alloc.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,51 +21,51 @@ GIT_BEGIN_DECL
2121
* that all fields need to be set to a proper function.
2222
*/
2323
typedef struct {
24-
/* Allocate `n` bytes of memory */
24+
/** Allocate `n` bytes of memory */
2525
void * GIT_CALLBACK(gmalloc)(size_t n, const char *file, int line);
2626

27-
/*
27+
/**
2828
* Allocate memory for an array of `nelem` elements, where each element
2929
* has a size of `elsize`. Returned memory shall be initialized to
3030
* all-zeroes
3131
*/
3232
void * GIT_CALLBACK(gcalloc)(size_t nelem, size_t elsize, const char *file, int line);
3333

34-
/* Allocate memory for the string `str` and duplicate its contents. */
34+
/** Allocate memory for the string `str` and duplicate its contents. */
3535
char * GIT_CALLBACK(gstrdup)(const char *str, const char *file, int line);
3636

37-
/*
37+
/**
3838
* Equivalent to the `gstrdup` function, but only duplicating at most
3939
* `n + 1` bytes
4040
*/
4141
char * GIT_CALLBACK(gstrndup)(const char *str, size_t n, const char *file, int line);
4242

43-
/*
43+
/**
4444
* Equivalent to `gstrndup`, but will always duplicate exactly `n` bytes
4545
* of `str`. Thus, out of bounds reads at `str` may happen.
4646
*/
4747
char * GIT_CALLBACK(gsubstrdup)(const char *str, size_t n, const char *file, int line);
4848

49-
/*
49+
/**
5050
* This function shall deallocate the old object `ptr` and return a
5151
* pointer to a new object that has the size specified by `size`. In
5252
* case `ptr` is `NULL`, a new array shall be allocated.
5353
*/
5454
void * GIT_CALLBACK(grealloc)(void *ptr, size_t size, const char *file, int line);
5555

56-
/*
56+
/**
5757
* This function shall be equivalent to `grealloc`, but allocating
5858
* `neleme * elsize` bytes.
5959
*/
6060
void * GIT_CALLBACK(greallocarray)(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
6161

62-
/*
62+
/**
6363
* This function shall allocate a new array of `nelem` elements, where
6464
* each element has a size of `elsize` bytes.
6565
*/
6666
void * GIT_CALLBACK(gmallocarray)(size_t nelem, size_t elsize, const char *file, int line);
6767

68-
/*
68+
/**
6969
* This function shall free the memory pointed to by `ptr`. In case
7070
* `ptr` is `NULL`, this shall be a no-op.
7171
*/

include/git2/transport.h

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef enum {
3737
* Hostkey information taken from libssh2
3838
*/
3939
typedef struct {
40-
git_cert parent;
40+
git_cert parent; /**< The parent cert */
4141

4242
/**
4343
* A hostkey type from libssh2, either
@@ -62,11 +62,13 @@ typedef struct {
6262
* X.509 certificate information
6363
*/
6464
typedef struct {
65-
git_cert parent;
65+
git_cert parent; /**< The parent cert */
66+
6667
/**
6768
* Pointer to the X.509 certificate data
6869
*/
6970
void *data;
71+
7072
/**
7173
* Length of the memory block pointed to by `data`.
7274
*/
@@ -144,14 +146,16 @@ typedef struct git_cred git_cred;
144146
*/
145147
struct git_cred {
146148
git_credtype_t credtype; /**< A type of credential */
149+
150+
/** The deallocator for this type of credentials */
147151
void GIT_CALLBACK(free)(git_cred *cred);
148152
};
149153

150154
/** A plaintext username and password */
151155
typedef struct {
152-
git_cred parent;
153-
char *username;
154-
char *password;
156+
git_cred parent; /**< The parent cred */
157+
char *username; /**< The username to authenticate as */
158+
char *password; /**< The password to use */
155159
} git_cred_userpass_plaintext;
156160

157161

@@ -172,42 +176,52 @@ typedef void GIT_CALLBACK(git_cred_ssh_interactive_cb)(const char* name, int nam
172176
* A ssh key from disk
173177
*/
174178
typedef struct git_cred_ssh_key {
175-
git_cred parent;
176-
char *username;
177-
char *publickey;
178-
char *privatekey;
179-
char *passphrase;
179+
git_cred parent; /**< The parent cred */
180+
char *username; /**< The username to authenticate as */
181+
char *publickey; /**< The path to a public key */
182+
char *privatekey; /**< The path to a private key */
183+
char *passphrase; /**< Passphrase used to decrypt the private key */
180184
} git_cred_ssh_key;
181185

182186
/**
183187
* Keyboard-interactive based ssh authentication
184188
*/
185189
typedef struct git_cred_ssh_interactive {
186-
git_cred parent;
187-
char *username;
190+
git_cred parent; /**< The parent cred */
191+
char *username; /**< The username to authenticate as */
192+
193+
/**
194+
* Callback used for authentication.
195+
*/
188196
git_cred_ssh_interactive_cb prompt_callback;
189-
void *payload;
197+
198+
void *payload; /**< Payload passed to prompt_callback */
190199
} git_cred_ssh_interactive;
191200

192201
/**
193202
* A key with a custom signature function
194203
*/
195204
typedef struct git_cred_ssh_custom {
196-
git_cred parent;
197-
char *username;
198-
char *publickey;
199-
size_t publickey_len;
205+
git_cred parent; /**< The parent cred */
206+
char *username; /**< The username to authenticate as */
207+
char *publickey; /**< The public key data */
208+
size_t publickey_len; /**< Length of the public key */
209+
210+
/**
211+
* Callback used to sign the data.
212+
*/
200213
git_cred_sign_cb sign_callback;
201-
void *payload;
214+
215+
void *payload; /**< Payload passed to prompt_callback */
202216
} git_cred_ssh_custom;
203217

204218
/** A key for NTLM/Kerberos "default" credentials */
205219
typedef struct git_cred git_cred_default;
206220

207221
/** Username-only credential information */
208222
typedef struct git_cred_username {
209-
git_cred parent;
210-
char username[1];
223+
git_cred parent; /**< The parent cred */
224+
char username[1]; /**< The username to authenticate as */
211225
} git_cred_username;
212226

213227
/**

0 commit comments

Comments
 (0)