Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libgit2 to c8fe6c097 #110

Merged
merged 1 commit into from
Feb 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 49 additions & 29 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ git_enum! {
GIT_EINVALID = -21,
GIT_EUNCOMMITTED = -22,
GIT_EDIRECTORY = -23,
GIT_EMERGECONFLICT = -24,
GIT_PASSTHROUGH = -30,
GIT_ITEROVER = -31,
}
Expand Down Expand Up @@ -210,7 +211,9 @@ git_enum! {
GIT_REPOSITORY_STATE_NONE,
GIT_REPOSITORY_STATE_MERGE,
GIT_REPOSITORY_STATE_REVERT,
GIT_REPOSITORY_STATE_REVERT_SEQUENCE,
GIT_REPOSITORY_STATE_CHERRYPICK,
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE,
GIT_REPOSITORY_STATE_BISECT,
GIT_REPOSITORY_STATE_REBASE,
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
Expand Down Expand Up @@ -664,20 +667,20 @@ pub struct git_blame_options {
pub min_match_characters: u16,
pub newest_commit: git_oid,
pub oldest_commit: git_oid,
pub min_line: u32,
pub max_line: u32,
pub min_line: usize,
pub max_line: usize,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct git_blame_hunk {
pub lines_in_hunk: u16,
pub lines_in_hunk: usize,
pub final_commit_id: git_oid,
pub final_start_line_number: u16,
pub final_start_line_number: usize,
pub final_signature: *mut git_signature,
pub orig_commit_id: git_oid,
pub orig_path: *const c_char,
pub orig_start_line_number: u16,
pub orig_start_line_number: usize,
pub orig_signature: *mut git_signature,
pub boundary: c_char,
}
Expand Down Expand Up @@ -720,11 +723,12 @@ pub struct git_config_entry {

git_enum! {
pub enum git_config_level_t: c_int {
GIT_CONFIG_LEVEL_SYSTEM = 1,
GIT_CONFIG_LEVEL_XDG = 2,
GIT_CONFIG_LEVEL_GLOBAL = 3,
GIT_CONFIG_LEVEL_LOCAL = 4,
GIT_CONFIG_LEVEL_APP = 5,
GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
GIT_CONFIG_LEVEL_SYSTEM = 2,
GIT_CONFIG_LEVEL_XDG = 3,
GIT_CONFIG_LEVEL_GLOBAL = 4,
GIT_CONFIG_LEVEL_LOCAL = 5,
GIT_CONFIG_LEVEL_APP = 6,
GIT_CONFIG_HIGHEST_LEVEL = -1,
}
}
Expand All @@ -750,6 +754,10 @@ git_enum! {
}
}

pub type git_submodule_cb = extern fn(*mut git_submodule,
*const c_char,
*mut c_void) -> c_int;

#[repr(C)]
pub struct git_cred {
pub credtype: git_credtype_t,
Expand Down Expand Up @@ -950,7 +958,8 @@ pub struct git_diff_options {
pub ignore_submodules: git_submodule_ignore_t,
pub pathspec: git_strarray,
pub notify_cb: git_diff_notify_cb,
pub notify_payload: *mut c_void,
pub progress_cb: git_diff_progress_cb,
pub payload: *mut c_void,
pub context_lines: u32,
pub interhunk_lines: u32,
pub id_abbrev: u16,
Expand Down Expand Up @@ -984,6 +993,11 @@ pub type git_diff_notify_cb = extern fn(*const git_diff,
*const c_char,
*mut c_void) -> c_int;

pub type git_diff_progress_cb = extern fn (*const git_diff,
*const c_char,
*const c_char,
*mut c_void) -> c_int;

pub const GIT_DIFF_NORMAL: u32 = 0;
pub const GIT_DIFF_REVERSE: u32 = 1 << 0;
pub const GIT_DIFF_INCLUDE_IGNORED: u32 = 1 << 1;
Expand Down Expand Up @@ -1087,17 +1101,21 @@ git_enum! {
#[repr(C)]
pub struct git_merge_options {
pub version: c_uint,
pub tree_flags: git_merge_tree_flag_t,
pub flags: git_merge_flag_t,
pub rename_threshold: c_uint,
pub target_limit: c_uint,
pub metric: *mut git_diff_similarity_metric,
pub recursion_limit: c_uint,
pub file_favor: git_merge_file_favor_t,
pub file_flags: c_uint,
pub file_flags: git_merge_file_flag_t,
}

git_enum! {
pub enum git_merge_tree_flag_t {
GIT_MERGE_TREE_FIND_RENAMES = 1 << 0,
pub enum git_merge_flag_t {
GIT_MERGE_FIND_RENAMES = 1 << 0,
GIT_MERGE_FAIL_ON_CONFLICT = 1 << 1,
GIT_MERGE_SKIP_REUC = 1 << 2,
GIT_MERGE_NO_RECURSIVE = 1 << 3,
}
}

Expand All @@ -1110,16 +1128,19 @@ git_enum! {
}
}

// used in git_merge_options.file_flags
pub const GIT_MERGE_FILE_DEFAULT: u32 = 0;
pub const GIT_MERGE_FILE_STYLE_MERGE: u32 = (1 << 0);
pub const GIT_MERGE_FILE_STYLE_DIFF3: u32 = (1 << 1);
pub const GIT_MERGE_FILE_SIMPLIFY_ALNUM: u32 = (1 << 2);
pub const GIT_MERGE_FILE_IGNORE_WHITESPACE: u32 = (1 << 3);
pub const GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE: u32 = (1 << 4);
pub const GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL: u32 = (1 << 5);
pub const GIT_MERGE_FILE_DIFF_PATIENCE: u32 = (1 << 6);
pub const GIT_MERGE_FILE_DIFF_MINIMAL: u32 = (1 << 7);
git_enum! {
pub enum git_merge_file_flag_t {
GIT_MERGE_FILE_DEFAULT = 0,
GIT_MERGE_FILE_STYLE_MERGE = (1 << 0),
GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1),
GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2),
GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3),
GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4),
GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5),
GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6),
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
}
}

pub type git_transport_cb = extern fn(out: *mut *mut git_transport,
owner: *mut git_remote,
Expand Down Expand Up @@ -1659,9 +1680,7 @@ extern {
write_index: c_int) -> c_int;
pub fn git_submodule_branch(submodule: *mut git_submodule) -> *const c_char;
pub fn git_submodule_foreach(repo: *mut git_repository,
callback: extern fn(*mut git_submodule,
*const c_char,
*mut c_void) -> c_int,
callback: git_submodule_cb,
payload: *mut c_void) -> c_int;
pub fn git_submodule_free(submodule: *mut git_submodule);
pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid;
Expand Down Expand Up @@ -1941,6 +1960,7 @@ extern {
pub fn git_config_delete_multivar(cfg: *mut git_config,
name: *const c_char,
regexp: *const c_char) -> c_int;
pub fn git_config_find_programdata(out: *mut git_buf) -> c_int;
pub fn git_config_find_global(out: *mut git_buf) -> c_int;
pub fn git_config_find_system(out: *mut git_buf) -> c_int;
pub fn git_config_find_xdg(out: *mut git_buf) -> c_int;
Expand Down Expand Up @@ -2172,7 +2192,7 @@ extern {
pub fn git_blame_get_hunk_count(blame: *mut git_blame) -> u32;

pub fn git_blame_get_hunk_byline(blame: *mut git_blame,
lineno: u32) -> *const git_blame_hunk;
lineno: usize) -> *const git_blame_hunk;
pub fn git_blame_get_hunk_byindex(blame: *mut git_blame,
index: u32) -> *const git_blame_hunk;

Expand Down
2 changes: 1 addition & 1 deletion libgit2-sys/libgit2
Submodule libgit2 updated 385 files
6 changes: 3 additions & 3 deletions src/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'repo> Blame<'repo> {
/// commit.
pub fn get_line(&self, lineno: usize) -> Option<BlameHunk> {
unsafe {
let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno as u32);
let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno);
if ptr.is_null() {
None
} else {
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'blame> BlameHunk<'blame> {
///
/// Note that the start line is counting from 1.
pub fn final_start_line(&self) -> usize {
unsafe { (*self.raw).final_start_line_number as usize }
unsafe { (*self.raw).final_start_line_number }
}

/// Returns the OID of the commit where this hunk was found.
Expand All @@ -112,7 +112,7 @@ impl<'blame> BlameHunk<'blame> {
///
/// Note that the start line is counting from 1.
pub fn orig_start_line(&self) -> usize {
unsafe { (*self.raw).orig_start_line_number as usize }
unsafe { (*self.raw).orig_start_line_number}
}

/// Returns path to the file where this hunk originated.
Expand Down
1 change: 1 addition & 0 deletions src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ mod impls {
impl Convert<raw::git_config_level_t> for ConfigLevel {
fn convert(&self) -> raw::git_config_level_t {
match *self {
ConfigLevel::ProgramData => raw::GIT_CONFIG_LEVEL_PROGRAMDATA,
ConfigLevel::System => raw::GIT_CONFIG_LEVEL_SYSTEM,
ConfigLevel::XDG => raw::GIT_CONFIG_LEVEL_XDG,
ConfigLevel::Global => raw::GIT_CONFIG_LEVEL_GLOBAL,
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ pub enum RepositoryState {
Clean,
Merge,
Revert,
RevertSequence,
CherryPick,
CherryPickSequence,
Bisect,
Rebase,
RebaseInteractive,
Expand Down Expand Up @@ -302,6 +304,8 @@ pub enum BranchType {
/// searching for config entries.
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum ConfigLevel {
/// System-wide on Windows, for compatibility with portable git
ProgramData,
/// System-wide configuration file, e.g. /etc/gitconfig
System,
/// XDG-compatible configuration file, e.g. ~/.config/git/config
Expand Down Expand Up @@ -542,6 +546,7 @@ impl ConfigLevel {
/// Converts a raw configuration level to a ConfigLevel
pub fn from_raw(raw: raw::git_config_level_t) -> ConfigLevel {
match raw {
raw::GIT_CONFIG_LEVEL_PROGRAMDATA => ConfigLevel::ProgramData,
raw::GIT_CONFIG_LEVEL_SYSTEM => ConfigLevel::System,
raw::GIT_CONFIG_LEVEL_XDG => ConfigLevel::XDG,
raw::GIT_CONFIG_LEVEL_GLOBAL => ConfigLevel::Global,
Expand Down
15 changes: 12 additions & 3 deletions src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ impl MergeOptions {
/// Detect file renames
pub fn find_renames(&mut self, find: bool) -> &mut MergeOptions {
if find {
self.raw.tree_flags |= raw::GIT_MERGE_TREE_FIND_RENAMES;
self.raw.flags |= raw::GIT_MERGE_FIND_RENAMES;
} else {
self.raw.tree_flags &= !raw::GIT_MERGE_TREE_FIND_RENAMES;
self.raw.flags &= !raw::GIT_MERGE_FIND_RENAMES;
}
self
}
Expand All @@ -65,13 +65,22 @@ impl MergeOptions {
self
}

/// Maximum number of times to merge common ancestors to build a
/// virtual merge base when faced with criss-cross merges. When
/// this limit is reached, the next ancestor will simply be used
/// instead of attempting to merge it. The default is unlimited.
pub fn recursion_limit(&mut self, limit: u32) -> &mut MergeOptions {
self.raw.recursion_limit = limit as c_uint;
self
}

/// Specify a side to favor for resolving conflicts
pub fn file_favor(&mut self, favor: FileFavor) -> &mut MergeOptions {
self.raw.file_favor = favor.convert();
self
}

fn flag(&mut self, opt: u32, val: bool) -> &mut MergeOptions {
fn flag(&mut self, opt: raw::git_merge_file_flag_t, val: bool) -> &mut MergeOptions {
if val {
self.raw.file_flags |= opt;
} else {
Expand Down
11 changes: 2 additions & 9 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ impl Repository {
GIT_REPOSITORY_STATE_NONE => Clean,
GIT_REPOSITORY_STATE_MERGE => Merge,
GIT_REPOSITORY_STATE_REVERT => Revert,
GIT_REPOSITORY_STATE_REVERT_SEQUENCE => RevertSequence,
GIT_REPOSITORY_STATE_CHERRYPICK => CherryPick,
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE => CherryPickSequence,
GIT_REPOSITORY_STATE_BISECT => Bisect,
GIT_REPOSITORY_STATE_REBASE => Rebase,
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE => RebaseInteractive,
Expand Down Expand Up @@ -1093,9 +1095,6 @@ impl Repository {
/// are written to the index. Callers should inspect the repository's index
/// after this completes, resolve any conflicts and prepare a commit.
///
/// The merge performed uses the first common ancestor, unlike the
/// git-merge-recursive strategy, which may produce an artificial common
/// ancestor tree when there are multiple ancestors.
/// For compatibility with git, the repository is put into a merging state.
/// Once the commit is done (or if the uses wishes to abort), you should
/// clear this state by calling git_repository_state_cleanup().
Expand Down Expand Up @@ -1131,12 +1130,6 @@ impl Repository {
/// the merge. The index may be written as-is to the working directory or
/// checked out. If the index is to be converted to a tree, the caller
/// should resolve any conflicts that arose as part of the merge.
///
/// The merge performed uses the first common ancestor, unlike the
/// git-merge-recursive strategy, which may produce an artificial common
/// ancestor tree when there are multiple ancestors.
///
/// The returned index must be freed explicitly with git_index_free.
pub fn merge_commits(&self, our_commit: &Commit, their_commit: &Commit,
opts: Option<&MergeOptions>) -> Result<Index, Error> {
let mut raw = 0 as *mut raw::git_index;
Expand Down