Skip to content

Commit 2c8fb4f

Browse files
author
Stephan Dilly
committed
only even try to ff merge when there is something incoming (#554)
* Update pull.rs
1 parent e7a8990 commit 2c8fb4f

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

Diff for: src/components/pull.rs

+23-13
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,7 @@ impl PullComponent {
127127
self.git_fetch.last_result()?
128128
{
129129
if err.is_empty() {
130-
let merge_res =
131-
sync::branch_merge_upstream_fastforward(
132-
CWD,
133-
&self.branch,
134-
);
135-
if let Err(err) = merge_res {
136-
self.queue.borrow_mut().push_back(
137-
InternalEvent::ShowErrorMsg(format!(
138-
"merge failed:\n{}",
139-
err
140-
)),
141-
);
142-
}
130+
self.do_merge()?;
143131
} else {
144132
self.queue.borrow_mut().push_back(
145133
InternalEvent::ShowErrorMsg(format!(
@@ -154,6 +142,28 @@ impl PullComponent {
154142

155143
Ok(())
156144
}
145+
146+
// check if something is incoming and try a ff merge then
147+
fn do_merge(&self) -> Result<()> {
148+
let branch_compare =
149+
sync::branch_compare_upstream(CWD, &self.branch)?;
150+
if branch_compare.behind > 0 {
151+
let merge_res = sync::branch_merge_upstream_fastforward(
152+
CWD,
153+
&self.branch,
154+
);
155+
if let Err(err) = merge_res {
156+
self.queue.borrow_mut().push_back(
157+
InternalEvent::ShowErrorMsg(format!(
158+
"merge failed:\n{}",
159+
err
160+
)),
161+
);
162+
}
163+
}
164+
165+
Ok(())
166+
}
157167
}
158168

159169
impl DrawableComponent for PullComponent {

0 commit comments

Comments
 (0)