Skip to content

fix status fetch hanging on bare repos w/o worktree #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 7 additions & 8 deletions asyncgit/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions asyncgit/src/sync/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/string_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down