Skip to content

Commit fcfd2df

Browse files
authored
Merge branch 'master' into dependabot/cargo/serde-1.0.210
2 parents efcd988 + ea94d3a commit fcfd2df

File tree

7 files changed

+70
-16
lines changed

7 files changed

+70
-16
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

asyncgit/src/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ pub enum Error {
9494
Sign(#[from] crate::sync::sign::SignError),
9595

9696
///
97-
#[error("gix::open error: {0}")]
98-
GixOpen(#[from] Box<gix::open::Error>),
97+
#[error("gix::discover error: {0}")]
98+
GixDiscover(#[from] Box<gix::discover::Error>),
9999

100100
///
101101
#[error("gix::reference::find::existing error: {0}")]
@@ -139,8 +139,8 @@ impl<T> From<crossbeam_channel::SendError<T>> for Error {
139139
}
140140
}
141141

142-
impl From<gix::open::Error> for Error {
143-
fn from(error: gix::open::Error) -> Self {
144-
Self::GixOpen(Box::new(error))
142+
impl From<gix::discover::Error> for Error {
143+
fn from(error: gix::discover::Error) -> Self {
144+
Self::GixDiscover(Box::new(error))
145145
}
146146
}

asyncgit/src/revlog.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ impl AsyncLog {
276276
let mut entries = vec![CommitId::default(); LIMIT_COUNT];
277277
entries.resize(0, CommitId::default());
278278

279-
let mut repo = gix::open(repo_path.gitpath())?;
279+
let mut repo: gix::Repository =
280+
gix::ThreadSafeRepository::discover_with_environment_overrides(repo_path.gitpath())
281+
.map(Into::into)?;
280282
let mut walker =
281283
LogWalkerWithoutFilter::new(&mut repo, LIMIT_COUNT)?;
282284

@@ -321,3 +323,49 @@ impl AsyncLog {
321323
.expect("error sending");
322324
}
323325
}
326+
327+
#[cfg(test)]
328+
mod tests {
329+
use std::sync::atomic::AtomicBool;
330+
use std::sync::{Arc, Mutex};
331+
use std::time::Duration;
332+
333+
use crossbeam_channel::unbounded;
334+
335+
use crate::sync::tests::{debug_cmd_print, repo_init};
336+
use crate::sync::RepoPath;
337+
use crate::AsyncLog;
338+
339+
use super::AsyncLogResult;
340+
341+
#[test]
342+
fn test_smoke_in_subdir() {
343+
let (_td, repo) = repo_init().unwrap();
344+
let root = repo.path().parent().unwrap();
345+
let repo_path: RepoPath =
346+
root.as_os_str().to_str().unwrap().into();
347+
348+
let (tx_git, _rx_git) = unbounded();
349+
350+
debug_cmd_print(&repo_path, "mkdir subdir");
351+
352+
let subdir = repo.path().parent().unwrap().join("subdir");
353+
let subdir_path: RepoPath =
354+
subdir.as_os_str().to_str().unwrap().into();
355+
356+
let arc_current = Arc::new(Mutex::new(AsyncLogResult {
357+
commits: Vec::new(),
358+
duration: Duration::default(),
359+
}));
360+
let arc_background = Arc::new(AtomicBool::new(false));
361+
362+
let result = AsyncLog::fetch_helper_without_filter(
363+
&subdir_path,
364+
&arc_current,
365+
&arc_background,
366+
&tx_git,
367+
);
368+
369+
assert!(result.is_ok());
370+
}
371+
}

asyncgit/src/sync/commit_filter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ pub fn filter_commit_by_search(
214214

215215
Ok(msg_summary_match
216216
|| msg_body_match
217-
|| file_match || authors_match)
217+
|| file_match
218+
|| authors_match)
218219
},
219220
))
220221
}

asyncgit/src/sync/logwalker.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a> LogWalker<'a> {
113113
///
114114
/// `SharedCommitFilterFn` requires access to a `git2::repo::Repository` because, under the hood,
115115
/// it calls into functions that work with a `git2::repo::Repository`. It seems unwise to open a
116-
/// repo both through `gix::open` and `Repository::open_ext` at the same time, so there is a
116+
/// repo both through `gix::discover` and `Repository::open_ext` at the same time, so there is a
117117
/// separate struct that works with `gix::Repository` only.
118118
///
119119
/// A more long-term option is to refactor filtering to work with a `gix::Repository` and to remove
@@ -270,7 +270,10 @@ mod tests {
270270
stage_add_file(repo_path, file_path).unwrap();
271271
let oid2 = commit(repo_path, "commit2").unwrap();
272272

273-
let mut repo = gix::open(repo_path.gitpath()).unwrap();
273+
let mut repo: gix::Repository =
274+
gix::ThreadSafeRepository::discover_with_environment_overrides(repo_path.gitpath())
275+
.map(Into::into)
276+
.unwrap();
274277
let mut walk = LogWalkerWithoutFilter::new(&mut repo, 100)?;
275278
let mut items = Vec::new();
276279
assert!(matches!(walk.read(&mut items), Ok(2)));

asyncgit/src/sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub use utils::{
110110
pub use git2::ResetType;
111111

112112
#[cfg(test)]
113-
mod tests {
113+
pub mod tests {
114114
use super::{
115115
commit,
116116
repository::repo,

src/tabs/status.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@ impl Status {
686686
strings::commands::select_staging(&self.key_config),
687687
!focus_on_diff,
688688
(self.visible
689-
&& !focus_on_diff && self.focus == Focus::WorkDir)
689+
&& !focus_on_diff
690+
&& self.focus == Focus::WorkDir)
690691
|| force_all,
691692
)
692693
.order(strings::order::NAV),
@@ -696,7 +697,8 @@ impl Status {
696697
strings::commands::select_unstaged(&self.key_config),
697698
!focus_on_diff,
698699
(self.visible
699-
&& !focus_on_diff && self.focus == Focus::Stage)
700+
&& !focus_on_diff
701+
&& self.focus == Focus::Stage)
700702
|| force_all,
701703
)
702704
.order(strings::order::NAV),

0 commit comments

Comments
 (0)