Skip to content

Commit a91132d

Browse files
naseschwarzdependabot[bot]Naseschwarz
authored
Bump git2 from 0.20.0 to 0.20.1 (#2567)
* Bump git2 from 0.20.0 to 0.20.1 Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.20.0 to 0.20.1. - [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md) - [Commits](rust-lang/git2-rs@git2-0.20.0...git2-0.20.1) --- updated-dependencies: - dependency-name: git2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Avoid passing reference into struct git2-rs changed the lifetime of the result of Patch::hunk() to reference the patch struct: rust-lang/git2-rs#1141 Thus, returning a patch struct and a reference into it is flagged by the borrow checker upon move when returning. This patch avoids returning both alltogether by separating retrieving and retrieving the patch. --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Naseschwarz <[email protected]>
1 parent 597e944 commit a91132d

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

asyncgit/src/sync/patches.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ pub(crate) struct HunkLines<'a> {
99
}
1010

1111
#[allow(clippy::redundant_pub_crate)]
12-
pub(crate) fn get_file_diff_patch_and_hunklines<'a>(
12+
pub(crate) fn get_file_diff_patch<'a>(
1313
repo: &'a Repository,
1414
file: &str,
1515
is_staged: bool,
1616
reverse: bool,
17-
) -> Result<(Patch<'a>, Vec<HunkLines<'a>>)> {
17+
) -> Result<Patch<'a>> {
1818
let diff = get_diff_raw(
1919
repo,
2020
file,
@@ -34,14 +34,12 @@ pub(crate) fn get_file_diff_patch_and_hunklines<'a>(
3434
Error::Generic(String::from("no patch found"))
3535
})?;
3636

37-
let lines = patch_get_hunklines(&patch)?;
38-
39-
Ok((patch, lines))
37+
Ok(patch)
4038
}
4139

4240
//
43-
fn patch_get_hunklines<'a>(
44-
patch: &Patch<'a>,
41+
pub fn patch_get_hunklines<'a>(
42+
patch: &'a Patch<'a>,
4543
) -> Result<Vec<HunkLines<'a>>> {
4644
let count_hunks = patch.num_hunks();
4745
let mut res = Vec::with_capacity(count_hunks);

asyncgit/src/sync/staging/discard_tracked.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use super::{apply_selection, load_file};
22
use crate::{
33
error::Result,
44
sync::{
5-
diff::DiffLinePosition,
6-
patches::get_file_diff_patch_and_hunklines, repository::repo,
5+
diff::DiffLinePosition, patches::get_file_diff_patch,
6+
patches::patch_get_hunklines, repository::repo,
77
utils::repo_write_file, RepoPath,
88
},
99
};
@@ -27,9 +27,9 @@ pub fn discard_lines(
2727
//TODO: check that file is not new (status modified)
2828

2929
let new_content = {
30-
let (_patch, hunks) = get_file_diff_patch_and_hunklines(
31-
&repo, file_path, false, false,
32-
)?;
30+
let patch =
31+
get_file_diff_patch(&repo, file_path, false, false)?;
32+
let hunks = patch_get_hunklines(&patch)?;
3333

3434
let working_content = load_file(&repo, file_path)?;
3535
let old_lines = working_content.lines().collect::<Vec<_>>();

asyncgit/src/sync/staging/stage_tracked.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use super::apply_selection;
22
use crate::{
33
error::{Error, Result},
44
sync::{
5-
diff::DiffLinePosition,
6-
patches::get_file_diff_patch_and_hunklines, repository::repo,
7-
RepoPath,
5+
diff::DiffLinePosition, patches::get_file_diff_patch,
6+
patches::patch_get_hunklines, repository::repo, RepoPath,
87
},
98
};
109
use easy_cast::Conv;
@@ -39,9 +38,9 @@ pub fn stage_lines(
3938
let indexed_content = String::from_utf8(blob.content().into())?;
4039

4140
let new_content = {
42-
let (_patch, hunks) = get_file_diff_patch_and_hunklines(
43-
&repo, file_path, is_stage, false,
44-
)?;
41+
let patch =
42+
get_file_diff_patch(&repo, file_path, is_stage, false)?;
43+
let hunks = patch_get_hunklines(&patch)?;
4544

4645
let old_lines = indexed_content.lines().collect::<Vec<_>>();
4746

0 commit comments

Comments
 (0)