Skip to content

Commit 9f5cef6

Browse files
authored
Document IndexEntry.path a bit. (#586)
1 parent 5f1d3b1 commit 9f5cef6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/index.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ pub struct IndexEntry {
6666
pub id: Oid,
6767
pub flags: u16,
6868
pub flags_extended: u16,
69+
70+
/// The path of this index entry as a byte vector. Regardless of the
71+
/// current platform, the directory separator is an ASCII forward slash
72+
/// (`0x2F`). There are no terminating or internal NUL characters, and no
73+
/// trailing slashes. Most of the time, paths will be valid utf-8 — but
74+
/// not always. For more information on the path storage format, see
75+
/// [these git docs][git-index-docs]. Note that libgit2 will take care of
76+
/// handling the prefix compression mentioned there.
77+
///
78+
/// [git-index-docs]: https://github.com/git/git/blob/a08a83db2bf27f015bec9a435f6d73e223c21c5e/Documentation/technical/index-format.txt#L107-L124
79+
///
80+
/// You can turn this value into a `std::ffi::CString` with
81+
/// `CString::new(&entry.path[..]).unwrap()`. To turn a reference into a
82+
/// `&std::path::Path`, see the `bytes2path()` function in the private,
83+
/// internal `util` module in this crate’s source code.
6984
pub path: Vec<u8>,
7085
}
7186

0 commit comments

Comments
 (0)