Skip to content

Commit 0deb0d3

Browse files
committed
Bind pathspec functions
1 parent 1fb7a80 commit 0deb0d3

File tree

5 files changed

+368
-5
lines changed

5 files changed

+368
-5
lines changed

libgit2-sys/lib.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ pub enum git_push {}
6363
pub enum git_note {}
6464
pub enum git_note_iterator {}
6565
pub enum git_status_list {}
66+
pub enum git_pathspec {}
67+
pub enum git_pathspec_match_list {}
68+
pub enum git_diff {}
6669

6770
#[repr(C)]
6871
pub struct git_revspec {
@@ -692,6 +695,15 @@ pub struct git_remote_head {
692695
pub symref_target: *mut c_char,
693696
}
694697

698+
pub type git_pathspec_flag_t = u32;
699+
pub const GIT_PATHSPEC_DEFAULT: u32 = 0;
700+
pub const GIT_PATHSPEC_IGNORE_CASE: u32 = 1 << 0;
701+
pub const GIT_PATHSPEC_USE_CASE: u32 = 1 << 1;
702+
pub const GIT_PATHSPEC_NO_GLOB: u32 = 1 << 2;
703+
pub const GIT_PATHSPEC_NO_MATCH_ERROR: u32 = 1 << 3;
704+
pub const GIT_PATHSPEC_FIND_FAILURES: u32 = 1 << 4;
705+
pub const GIT_PATHSPEC_FAILURES_ONLY: u32 = 1 << 5;
706+
695707
/// Initialize openssl for the libgit2 library
696708
#[cfg(unix)]
697709
pub fn openssl_init() {
@@ -1583,6 +1595,41 @@ extern {
15831595
repo: *mut git_repository,
15841596
one: *const git_oid,
15851597
two: *const git_oid) -> c_int;
1598+
1599+
// pathspec
1600+
pub fn git_pathspec_free(ps: *mut git_pathspec);
1601+
pub fn git_pathspec_match_diff(out: *mut *mut git_pathspec_match_list,
1602+
diff: *mut git_diff,
1603+
flags: u32,
1604+
ps: *mut git_pathspec) -> c_int;
1605+
pub fn git_pathspec_match_index(out: *mut *mut git_pathspec_match_list,
1606+
index: *mut git_index,
1607+
flags: u32,
1608+
ps: *mut git_pathspec) -> c_int;
1609+
pub fn git_pathspec_match_list_diff_entry(m: *const git_pathspec_match_list,
1610+
pos: size_t) -> *const git_diff_delta;
1611+
pub fn git_pathspec_match_list_entry(m: *const git_pathspec_match_list,
1612+
pos: size_t) -> *const c_char;
1613+
pub fn git_pathspec_match_list_entrycount(m: *const git_pathspec_match_list)
1614+
-> size_t;
1615+
pub fn git_pathspec_match_list_failed_entry(m: *const git_pathspec_match_list,
1616+
pos: size_t) -> *const c_char;
1617+
pub fn git_pathspec_match_list_failed_entrycount(
1618+
m: *const git_pathspec_match_list) -> size_t;
1619+
pub fn git_pathspec_match_list_free(m: *const git_pathspec_match_list);
1620+
pub fn git_pathspec_match_tree(out: *mut *mut git_pathspec_match_list,
1621+
tree: *mut git_tree,
1622+
flags: u32,
1623+
ps: *mut git_pathspec) -> c_int;
1624+
pub fn git_pathspec_match_workdir(out: *mut *mut git_pathspec_match_list,
1625+
repo: *mut git_repository,
1626+
flags: u32,
1627+
ps: *mut git_pathspec) -> c_int;
1628+
pub fn git_pathspec_matches_path(ps: *const git_pathspec,
1629+
flags: u32,
1630+
path: *const c_char) -> c_int;
1631+
pub fn git_pathspec_new(out: *mut *mut git_pathspec,
1632+
pathspec: *const git_strarray) -> c_int;
15861633
}
15871634

15881635
#[test]

src/diff.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::kinds::marker;
22

3-
use {raw, StatusEntry, Delta, Oid};
3+
use {raw, Delta, Oid};
44

55
/// Description of changes to one entry.
66
pub struct DiffDelta<'a> {
@@ -27,8 +27,7 @@ impl<'a> DiffDelta<'a> {
2727
///
2828
/// This method is unsafe as there is no guarantee that `raw` is a valid
2929
/// pointer.
30-
pub unsafe fn from_raw(_entry: &StatusEntry<'a>,
31-
raw: *mut raw::git_diff_delta) -> DiffDelta<'a> {
30+
pub unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> {
3231
DiffDelta {
3332
raw: raw,
3433
marker1: marker::ContravariantLifetime,

src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ pub use index::{Index, IndexEntry, IndexEntries, IndexMatchedPath};
9090
pub use note::{Note, Notes};
9191
pub use object::Object;
9292
pub use oid::Oid;
93+
pub use pathspec::{Pathspec, PathspecMatchList, PathspecFailedEntries};
94+
pub use pathspec::{PathspecDiffEntries, PathspecEntries};
9395
pub use push::{Push, PushStatus};
9496
pub use reference::{Reference, References, ReferenceNames};
9597
pub use refspec::Refspec;
@@ -288,6 +290,7 @@ mod index;
288290
mod note;
289291
mod object;
290292
mod oid;
293+
mod pathspec;
291294
mod push;
292295
mod reference;
293296
mod refspec;
@@ -533,6 +536,20 @@ Lastly, the following will only be returned for ignore "NONE".
533536

534537
}
535538

539+
bitflags! {
540+
#[doc = r#"
541+
"#]
542+
flags PathspecFlags: u32 {
543+
const PATHSPEC_DEFAULT = raw::GIT_PATHSPEC_DEFAULT as u32,
544+
const PATHSPEC_IGNORE_CASE = raw::GIT_PATHSPEC_IGNORE_CASE as u32,
545+
const PATHSPEC_USE_CASE = raw::GIT_PATHSPEC_USE_CASE as u32,
546+
const PATHSPEC_NO_GLOB = raw::GIT_PATHSPEC_NO_GLOB as u32,
547+
const PATHSPEC_NO_MATCH_ERROR = raw::GIT_PATHSPEC_NO_MATCH_ERROR as u32,
548+
const PATHSPEC_FIND_FAILURES = raw::GIT_PATHSPEC_FIND_FAILURES as u32,
549+
const PATHSPEC_FAILURES_ONLY = raw::GIT_PATHSPEC_FAILURES_ONLY as u32,
550+
}
551+
}
552+
536553
#[cfg(test)]
537554
mod tests {
538555
use super::ObjectType;

0 commit comments

Comments
 (0)