Skip to content

Commit ab95b98

Browse files
authored
allow pushing to empty repo (#2063)
closes #1919
1 parent be10d90 commit ab95b98

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ These defaults require some adoption from existing users but feel more natural t
2828

2929
### Fixes
3030
* stash window empty after file history popup closes ([#1986](https://github.com/extrawurst/gitui/issues/1986))
31+
* allow push to empty remote ([#1919](https://github.com/extrawurst/gitui/issues/1919))
3132

3233
## [0.24.3] - 2023-09-09
3334

Diff for: src/tabs/status.rs

+10-21
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ use crate::{
1515
};
1616
use anyhow::Result;
1717
use asyncgit::{
18-
asyncjob::AsyncSingleJob,
1918
cached,
2019
sync::{
2120
self, status::StatusType, RepoPath, RepoPathRef, RepoState,
2221
},
2322
sync::{BranchCompare, CommitId},
24-
AsyncBranchesJob, AsyncDiff, AsyncGitNotification, AsyncStatus,
25-
DiffParams, DiffType, PushType, StatusItem, StatusParams,
23+
AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams,
24+
DiffType, PushType, StatusItem, StatusParams,
2625
};
2726

2827
use crossterm::event::Event;
@@ -74,7 +73,6 @@ pub struct Status {
7473
git_status_stage: AsyncStatus,
7574
git_branch_state: Option<BranchCompare>,
7675
git_branch_name: cached::BranchName,
77-
git_branches: AsyncSingleJob<AsyncBranchesJob>,
7876
queue: Queue,
7977
git_action_executed: bool,
8078
options: SharedOptions,
@@ -187,7 +185,6 @@ impl Status {
187185
repo_clone,
188186
env.sender_git.clone(),
189187
),
190-
git_branches: AsyncSingleJob::new(env.sender_git.clone()),
191188
git_action_executed: false,
192189
git_branch_state: None,
193190
git_branch_name: cached::BranchName::new(
@@ -408,22 +405,12 @@ impl Status {
408405
self.git_diff.is_pending()
409406
|| self.git_status_stage.is_pending()
410407
|| self.git_status_workdir.is_pending()
411-
|| self.git_branches.is_pending()
412408
}
413409

414410
fn check_remotes(&mut self) {
415-
self.has_remotes = false;
416-
417-
if let Some(result) = self.git_branches.take_last() {
418-
if let Some(Ok(branches)) = result.result() {
419-
self.has_remotes = !branches.is_empty();
420-
}
421-
} else {
422-
self.git_branches.spawn(AsyncBranchesJob::new(
423-
self.repo.borrow().clone(),
424-
false,
425-
));
426-
}
411+
self.has_remotes =
412+
sync::get_default_remote(&self.repo.borrow().clone())
413+
.is_ok();
427414
}
428415

429416
///
@@ -609,10 +596,12 @@ impl Status {
609596
}
610597

611598
fn can_push(&self) -> bool {
612-
self.git_branch_state
599+
let is_ahead = self
600+
.git_branch_state
613601
.as_ref()
614-
.map_or(true, |state| state.ahead > 0)
615-
&& self.has_remotes
602+
.map_or(true, |state| state.ahead > 0);
603+
604+
is_ahead && self.has_remotes
616605
}
617606

618607
const fn can_pull(&self) -> bool {

0 commit comments

Comments
 (0)