mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
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](https://github.com/rust-lang/git2-rs/compare/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] <support@github.com> * Avoid passing reference into struct git2-rs changed the lifetime of the result of Patch::hunk() to reference the patch struct: https://github.com/rust-lang/git2-rs/pull/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] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Naseschwarz <naseschwarz@0x53a.de>
This commit is contained in:
parent
597e944af9
commit
a91132d187
4 changed files with 19 additions and 22 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -1119,9 +1119,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "git2"
|
name = "git2"
|
||||||
version = "0.20.0"
|
version = "0.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
|
checksum = "5220b8ba44c68a9a7f7a7659e864dd73692e417ef0211bea133c7b74e031eeb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
@ -2184,9 +2184,9 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libgit2-sys"
|
name = "libgit2-sys"
|
||||||
version = "0.18.0+1.9.0"
|
version = "0.18.1+1.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec"
|
checksum = "e1dcb20f84ffcdd825c7a311ae347cce604a6f084a767dec4a4929829645290e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ pub(crate) struct HunkLines<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::redundant_pub_crate)]
|
#[allow(clippy::redundant_pub_crate)]
|
||||||
pub(crate) fn get_file_diff_patch_and_hunklines<'a>(
|
pub(crate) fn get_file_diff_patch<'a>(
|
||||||
repo: &'a Repository,
|
repo: &'a Repository,
|
||||||
file: &str,
|
file: &str,
|
||||||
is_staged: bool,
|
is_staged: bool,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
) -> Result<(Patch<'a>, Vec<HunkLines<'a>>)> {
|
) -> Result<Patch<'a>> {
|
||||||
let diff = get_diff_raw(
|
let diff = get_diff_raw(
|
||||||
repo,
|
repo,
|
||||||
file,
|
file,
|
||||||
|
|
@ -34,14 +34,12 @@ pub(crate) fn get_file_diff_patch_and_hunklines<'a>(
|
||||||
Error::Generic(String::from("no patch found"))
|
Error::Generic(String::from("no patch found"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let lines = patch_get_hunklines(&patch)?;
|
Ok(patch)
|
||||||
|
|
||||||
Ok((patch, lines))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
fn patch_get_hunklines<'a>(
|
pub fn patch_get_hunklines<'a>(
|
||||||
patch: &Patch<'a>,
|
patch: &'a Patch<'a>,
|
||||||
) -> Result<Vec<HunkLines<'a>>> {
|
) -> Result<Vec<HunkLines<'a>>> {
|
||||||
let count_hunks = patch.num_hunks();
|
let count_hunks = patch.num_hunks();
|
||||||
let mut res = Vec::with_capacity(count_hunks);
|
let mut res = Vec::with_capacity(count_hunks);
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ use super::{apply_selection, load_file};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Result,
|
error::Result,
|
||||||
sync::{
|
sync::{
|
||||||
diff::DiffLinePosition,
|
diff::DiffLinePosition, patches::get_file_diff_patch,
|
||||||
patches::get_file_diff_patch_and_hunklines, repository::repo,
|
patches::patch_get_hunklines, repository::repo,
|
||||||
utils::repo_write_file, RepoPath,
|
utils::repo_write_file, RepoPath,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -27,9 +27,9 @@ pub fn discard_lines(
|
||||||
//TODO: check that file is not new (status modified)
|
//TODO: check that file is not new (status modified)
|
||||||
|
|
||||||
let new_content = {
|
let new_content = {
|
||||||
let (_patch, hunks) = get_file_diff_patch_and_hunklines(
|
let patch =
|
||||||
&repo, file_path, false, false,
|
get_file_diff_patch(&repo, file_path, false, false)?;
|
||||||
)?;
|
let hunks = patch_get_hunklines(&patch)?;
|
||||||
|
|
||||||
let working_content = load_file(&repo, file_path)?;
|
let working_content = load_file(&repo, file_path)?;
|
||||||
let old_lines = working_content.lines().collect::<Vec<_>>();
|
let old_lines = working_content.lines().collect::<Vec<_>>();
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@ use super::apply_selection;
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
sync::{
|
sync::{
|
||||||
diff::DiffLinePosition,
|
diff::DiffLinePosition, patches::get_file_diff_patch,
|
||||||
patches::get_file_diff_patch_and_hunklines, repository::repo,
|
patches::patch_get_hunklines, repository::repo, RepoPath,
|
||||||
RepoPath,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use easy_cast::Conv;
|
use easy_cast::Conv;
|
||||||
|
|
@ -39,9 +38,9 @@ pub fn stage_lines(
|
||||||
let indexed_content = String::from_utf8(blob.content().into())?;
|
let indexed_content = String::from_utf8(blob.content().into())?;
|
||||||
|
|
||||||
let new_content = {
|
let new_content = {
|
||||||
let (_patch, hunks) = get_file_diff_patch_and_hunklines(
|
let patch =
|
||||||
&repo, file_path, is_stage, false,
|
get_file_diff_patch(&repo, file_path, is_stage, false)?;
|
||||||
)?;
|
let hunks = patch_get_hunklines(&patch)?;
|
||||||
|
|
||||||
let old_lines = indexed_content.lines().collect::<Vec<_>>();
|
let old_lines = indexed_content.lines().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue