From d3098ac3940c8a6a66b8bda29f824e467cd58dae Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 8 Dec 2021 21:40:22 +0100 Subject: [PATCH 1/2] fix status fetch hanging on bare repos w/o worktree --- Makefile | 1 + asyncgit/src/status.rs | 15 +++++++-------- asyncgit/src/sync/status.rs | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f73bd94207..edc95465b8 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ .PHONY: debug build-release release-linux-musl test clippy clippy-pedantic install install-debug ARGS=-l +# ARGS=-l -d ~/code/git-bare-test.git # ARGS=-l -d ~/code/git-bare-test.git -w ~/code/git-bare-test profile: diff --git a/asyncgit/src/status.rs b/asyncgit/src/status.rs index b73e5a6ba0..3576c91ebe 100644 --- a/asyncgit/src/status.rs +++ b/asyncgit/src/status.rs @@ -127,23 +127,22 @@ impl AsyncStatus { self.pending.fetch_add(1, Ordering::Relaxed); rayon_core::spawn(move || { - let ok = Self::fetch_helper( + if let Err(e) = Self::fetch_helper( &repo, status_type, config, hash_request, &arc_current, &arc_last, - ) - .is_ok(); + ) { + log::error!("fetch_helper: {}", e); + } arc_pending.fetch_sub(1, Ordering::Relaxed); - if ok { - sender - .send(AsyncGitNotification::Status) - .expect("error sending status"); - } + sender + .send(AsyncGitNotification::Status) + .expect("error sending status"); }); Ok(None) diff --git a/asyncgit/src/sync/status.rs b/asyncgit/src/sync/status.rs index 6613b85754..4ec99e1705 100644 --- a/asyncgit/src/sync/status.rs +++ b/asyncgit/src/sync/status.rs @@ -104,6 +104,10 @@ pub fn get_status( let repo = repo(repo_path)?; + if repo.is_bare() && !repo.is_worktree() { + return Ok(Vec::new()); + } + let show_untracked = if let Some(config) = show_untracked { config } else { From 19c5b89847c09198f3570fa6a230fcec98d59385 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 8 Dec 2021 21:50:52 +0100 Subject: [PATCH 2/2] clippy fixes --- src/string_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_utils.rs b/src/string_utils.rs index 627a0e6086..065f5554c5 100644 --- a/src/string_utils.rs +++ b/src/string_utils.rs @@ -15,7 +15,7 @@ pub fn trim_length_left(s: &str, width: usize) -> &str { //TODO: allow customize tabsize pub fn tabs_to_spaces(input: String) -> String { if input.contains('\t') { - input.replace("\t", " ") + input.replace('\t', " ") } else { input }