From e3e92f9ac0437171581c87b04344f6dcb55cb6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 20 Feb 2016 17:37:58 +0100 Subject: [PATCH] Update libgit2 to c8fe6c097 --- libgit2-sys/lib.rs | 78 ++++++++++++++++++++++++++++----------------- libgit2-sys/libgit2 | 2 +- src/blame.rs | 6 ++-- src/call.rs | 1 + src/lib.rs | 5 +++ src/merge.rs | 15 +++++++-- src/repo.rs | 11 ++----- 7 files changed, 73 insertions(+), 45 deletions(-) diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 791856e823..9e61be6006 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -164,6 +164,7 @@ git_enum! { GIT_EINVALID = -21, GIT_EUNCOMMITTED = -22, GIT_EDIRECTORY = -23, + GIT_EMERGECONFLICT = -24, GIT_PASSTHROUGH = -30, GIT_ITEROVER = -31, } @@ -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, @@ -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, } @@ -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, } } @@ -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, @@ -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, @@ -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; @@ -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, } } @@ -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, @@ -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; @@ -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; @@ -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; diff --git a/libgit2-sys/libgit2 b/libgit2-sys/libgit2 index 4280fabb9f..c8fe6c0975 160000 --- a/libgit2-sys/libgit2 +++ b/libgit2-sys/libgit2 @@ -1 +1 @@ -Subproject commit 4280fabb9f79df6c4d95b1f08b97a03874b167eb +Subproject commit c8fe6c0975431e92d3dc4569734f30923b64dd18 diff --git a/src/blame.rs b/src/blame.rs index 6de64a5543..c3e1209c5c 100644 --- a/src/blame.rs +++ b/src/blame.rs @@ -51,7 +51,7 @@ impl<'repo> Blame<'repo> { /// commit. pub fn get_line(&self, lineno: usize) -> Option { 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 { @@ -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. @@ -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. diff --git a/src/call.rs b/src/call.rs index f9157216fc..44c02ef15f 100644 --- a/src/call.rs +++ b/src/call.rs @@ -136,6 +136,7 @@ mod impls { impl Convert 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, diff --git a/src/lib.rs b/src/lib.rs index 0e8ec85525..69ede11361 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -242,7 +242,9 @@ pub enum RepositoryState { Clean, Merge, Revert, + RevertSequence, CherryPick, + CherryPickSequence, Bisect, Rebase, RebaseInteractive, @@ -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 @@ -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, diff --git a/src/merge.rs b/src/merge.rs index cbf43250c4..045e9faf86 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -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 } @@ -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 { diff --git a/src/repo.rs b/src/repo.rs index f95cb3bb9a..2d1da2bee5 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -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, @@ -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(). @@ -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 { let mut raw = 0 as *mut raw::git_index;