Skip to content

Commit a947ce3

Browse files
author
Stephan Dilly
authored
fix status fetch hanging on bare repos w/o worktree (#1032)
closes #1029
1 parent 0a6ca35 commit a947ce3

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.PHONY: debug build-release release-linux-musl test clippy clippy-pedantic install install-debug
33

44
ARGS=-l
5+
# ARGS=-l -d ~/code/git-bare-test.git
56
# ARGS=-l -d ~/code/git-bare-test.git -w ~/code/git-bare-test
67

78
profile:

asyncgit/src/status.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,22 @@ impl AsyncStatus {
127127
self.pending.fetch_add(1, Ordering::Relaxed);
128128

129129
rayon_core::spawn(move || {
130-
let ok = Self::fetch_helper(
130+
if let Err(e) = Self::fetch_helper(
131131
&repo,
132132
status_type,
133133
config,
134134
hash_request,
135135
&arc_current,
136136
&arc_last,
137-
)
138-
.is_ok();
137+
) {
138+
log::error!("fetch_helper: {}", e);
139+
}
139140

140141
arc_pending.fetch_sub(1, Ordering::Relaxed);
141142

142-
if ok {
143-
sender
144-
.send(AsyncGitNotification::Status)
145-
.expect("error sending status");
146-
}
143+
sender
144+
.send(AsyncGitNotification::Status)
145+
.expect("error sending status");
147146
});
148147

149148
Ok(None)

asyncgit/src/sync/status.rs

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ pub fn get_status(
104104

105105
let repo = repo(repo_path)?;
106106

107+
if repo.is_bare() && !repo.is_worktree() {
108+
return Ok(Vec::new());
109+
}
110+
107111
let show_untracked = if let Some(config) = show_untracked {
108112
config
109113
} else {

src/string_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn trim_length_left(s: &str, width: usize) -> &str {
1515
//TODO: allow customize tabsize
1616
pub fn tabs_to_spaces(input: String) -> String {
1717
if input.contains('\t') {
18-
input.replace("\t", " ")
18+
input.replace('\t', " ")
1919
} else {
2020
input
2121
}

0 commit comments

Comments
 (0)