diff options
author | tummychow <tummychow@users.noreply.github.com> | 2018-02-16 13:52:33 -0800 |
---|---|---|
committer | tummychow <tummychow@users.noreply.github.com> | 2018-02-16 13:52:33 -0800 |
commit | 4acf6b5b2d6f49bc042157e91a956db994d65e01 (patch) | |
tree | 04a5d1eac9a61e81f8ec2b1f0fa809f68925cba4 | |
parent | 8b312c943a20f9b687aa06072a638a93adfa6c2f (diff) |
refactor diff_options again
-rw-r--r-- | src/lib.rs | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -25,6 +25,15 @@ pub fn run(config: &Config) -> Result<(), failure::Error> { None => None, }; + let mut diff_options = Some({ + let mut ret = git2::DiffOptions::new(); + ret.context_lines(0) + .id_abbrev(40) + .ignore_filemode(true) + .ignore_submodules(true); + ret + }); + let stack: Vec<_> = { let stack = working_stack(&repo, base, config.logger)?; let mut diffs = Vec::with_capacity(stack.len()); @@ -36,7 +45,7 @@ pub fn run(config: &Config) -> Result<(), failure::Error> { Some(commit.parent(0)?.tree()?) }.as_ref(), Some(&commit.tree()?), - Some(&mut diff_options()), + diff_options.as_mut(), )?)?; debug!(config.logger, "parsed commit diff"; "commit" => commit.id().to_string(), @@ -51,7 +60,7 @@ pub fn run(config: &Config) -> Result<(), failure::Error> { let index = owned::parse_diff(&repo.diff_tree_to_index( Some(&repo.head()?.peel_to_tree()?), None, - Some(&mut diff_options()), + diff_options.as_mut(), )?)?; debug!(config.logger, "parsed index"; "index" => format!("{:?}", index), @@ -60,15 +69,6 @@ pub fn run(config: &Config) -> Result<(), failure::Error> { Ok(()) } -fn diff_options() -> git2::DiffOptions { - let mut ret = git2::DiffOptions::new(); - ret.context_lines(0) - .id_abbrev(40) - .ignore_filemode(true) - .ignore_submodules(true); - ret -} - fn max_stack(repo: &git2::Repository) -> usize { match repo.config() .and_then(|config| config.get_i64(MAX_STACK_CONFIG_NAME)) |