Skip to content

Commit dd6d364

Browse files
authored
Sync config docs (#643)
* Sync Config docs with libgit's docs. * Fix links. Rustdoc now warns about these not being properly linked.
1 parent 3a85308 commit dd6d364

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

src/apply.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! git_apply support
2-
//! see original: https://github.com/libgit2/libgit2/blob/master/include/git2/apply.h
2+
//! see original: <https://github.com/libgit2/libgit2/blob/master/include/git2/apply.h>
33
44
use crate::{panic, raw, util::Binding, DiffDelta, DiffHunk};
55
use libc::c_int;
66
use std::{ffi::c_void, mem};
77

88
/// Possible application locations for git_apply
9-
/// see https://libgit2.org/libgit2/#HEAD/type/git_apply_options
9+
/// see <https://libgit2.org/libgit2/#HEAD/type/git_apply_options>
1010
#[derive(Copy, Clone, Debug)]
1111
pub enum ApplyLocation {
1212
/// Apply the patch to the workdir

src/config.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ impl Config {
149149

150150
/// Remove multivar config variables in the config file with the highest level (usually the
151151
/// local one).
152+
///
153+
/// The regular expression is applied case-sensitively on the value.
152154
pub fn remove_multivar(&mut self, name: &str, regexp: &str) -> Result<(), Error> {
153155
let name = CString::new(name)?;
154156
let regexp = CString::new(regexp)?;
@@ -204,6 +206,8 @@ impl Config {
204206
///
205207
/// This is the same as `get_bytes` except that it may return `Err` if
206208
/// the bytes are not valid utf-8.
209+
///
210+
/// This method will return an error if this `Config` is not a snapshot.
207211
pub fn get_str(&self, name: &str) -> Result<&str, Error> {
208212
str::from_utf8(self.get_bytes(name)?)
209213
.map_err(|_| Error::from_str("configuration value is not valid utf8"))
@@ -223,6 +227,10 @@ impl Config {
223227

224228
/// Get the value of a string config variable as an owned string.
225229
///
230+
/// All config files will be looked into, in the order of their
231+
/// defined level. A higher level means a higher priority. The
232+
/// first occurrence of the variable will be returned here.
233+
///
226234
/// An error will be returned if the config value is not valid utf-8.
227235
pub fn get_string(&self, name: &str) -> Result<String, Error> {
228236
let ret = Buf::new();
@@ -235,7 +243,15 @@ impl Config {
235243
.map_err(|_| Error::from_str("configuration value is not valid utf8"))
236244
}
237245

238-
/// Get the value of a path config variable as an owned .
246+
/// Get the value of a path config variable as an owned `PathBuf`.
247+
///
248+
/// A leading '~' will be expanded to the global search path (which
249+
/// defaults to the user's home directory but can be overridden via
250+
/// [`raw::git_libgit2_opts`].
251+
///
252+
/// All config files will be looked into, in the order of their
253+
/// defined level. A higher level means a higher priority. The
254+
/// first occurrence of the variable will be returned here.
239255
pub fn get_path(&self, name: &str) -> Result<PathBuf, Error> {
240256
let ret = Buf::new();
241257
let name = CString::new(name)?;
@@ -260,6 +276,10 @@ impl Config {
260276
/// If `glob` is `Some`, then the iterator will only iterate over all
261277
/// variables whose name matches the pattern.
262278
///
279+
/// The regular expression is applied case-sensitively on the normalized form of
280+
/// the variable name: the section and variable parts are lower-cased. The
281+
/// subsection is left unchanged.
282+
///
263283
/// # Example
264284
///
265285
/// ```
@@ -293,6 +313,10 @@ impl Config {
293313
///
294314
/// If `regexp` is `Some`, then the iterator will only iterate over all
295315
/// values which match the pattern.
316+
///
317+
/// The regular expression is applied case-sensitively on the normalized form of
318+
/// the variable name: the section and variable parts are lower-cased. The
319+
/// subsection is left unchanged.
296320
pub fn multivar(&self, name: &str, regexp: Option<&str>) -> Result<ConfigEntries<'_>, Error> {
297321
let mut ret = ptr::null_mut();
298322
let name = CString::new(name)?;
@@ -363,6 +387,8 @@ impl Config {
363387

364388
/// Set the value of an multivar config variable in the config file with the
365389
/// highest level (usually the local one).
390+
///
391+
/// The regular expression is applied case-sensitively on the value.
366392
pub fn set_multivar(&mut self, name: &str, regexp: &str, value: &str) -> Result<(), Error> {
367393
let name = CString::new(name)?;
368394
let regexp = CString::new(regexp)?;
@@ -398,6 +424,7 @@ impl Config {
398424
}
399425

400426
/// Parse a string as a bool.
427+
///
401428
/// Interprets "true", "yes", "on", 1, or any non-zero number as true.
402429
/// Interprets "false", "no", "off", 0, or an empty string as false.
403430
pub fn parse_bool<S: IntoCString>(s: S) -> Result<bool, Error> {

src/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl Repository {
313313
/// Find a single object and intermediate reference by a revision string.
314314
///
315315
/// See `man gitrevisions`, or
316-
/// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
316+
/// <http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions> for
317317
/// information on the syntax accepted.
318318
///
319319
/// In some cases (`@{<-n>}` or `<branchname>@{upstream}`), the expression

src/tagforeach.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! git_tag_foreach support
2-
//! see original: https://libgit2.org/libgit2/#HEAD/group/tag/git_tag_foreach
2+
//! see original: <https://libgit2.org/libgit2/#HEAD/group/tag/git_tag_foreach>
33
44
use crate::{panic, raw, util::Binding, Oid};
55
use libc::{c_char, c_int};
@@ -16,7 +16,7 @@ pub(crate) struct TagForeachData<'a> {
1616
}
1717

1818
/// c callback forwarding to rust callback inside `TagForeachData`
19-
/// see original: https://libgit2.org/libgit2/#HEAD/group/callback/git_tag_foreach_cb
19+
/// see original: <https://libgit2.org/libgit2/#HEAD/group/callback/git_tag_foreach_cb>
2020
pub(crate) extern "C" fn tag_foreach_cb(
2121
name: *const c_char,
2222
oid: *mut git_oid,

0 commit comments

Comments
 (0)