diff options
| author | Russell Belfer <rb@github.com> | 2013-05-09 06:45:06 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-05-09 06:45:06 -0700 |
| commit | 3d1c9f612d78c6c235a3f38af226300fb6dd7dd6 (patch) | |
| tree | 70715be871f0845757c58abe674109d9ec6d0a4d /include/git2/repository.h | |
| parent | 503dd0f3c4f798b02e0173dde7e3631d6e860c42 (diff) | |
| download | libgit2-3d1c9f612d78c6c235a3f38af226300fb6dd7dd6.tar.gz | |
Fix git_repository_message docs
This clarifies the docs for git_repository_message and also adds
to the tests to explicitly check NUL termination of data when the
output buffer is smaller than the message size. There is a minor
behavior change so that a non-NULL output buffer will always be
NUL terminated (at length zero) if an error occurs.
Diffstat (limited to 'include/git2/repository.h')
| -rw-r--r-- | include/git2/repository.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/git2/repository.h b/include/git2/repository.h index cd238e17c..e0464c63f 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -460,10 +460,19 @@ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo); * Use this function to get the contents of this file. Don't forget to * remove the file after you create the commit. * + * If the repository message exists and there are no errors reading it, this + * returns the bytes needed to store the message in memory (i.e. message + * file size plus one terminating NUL byte). That value is returned even if + * `out` is NULL or `len` is shorter than the necessary size. + * + * The `out` buffer will *always* be NUL terminated, even if truncation + * occurs. + * * @param out Buffer to write data into or NULL to just read required size - * @param len Length of buffer in bytes + * @param len Length of `out` buffer in bytes * @param repo Repository to read prepared message from - * @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error + * @return GIT_ENOUTFOUND if no message exists, other value < 0 for other + * errors, or total bytes in message (may be > `len`) on success */ GIT_EXTERN(int) git_repository_message(char *out, size_t len, git_repository *repo); |
