cli: don't require --allow-backwards when creating a branch

If a branch doesn't exist yet, it's clearly safe to move it "forward"
to any commit (it was simply a bug that we required
`--allow-backards`).
This commit is contained in:
Martin von Zweigbergk 2021-08-11 11:10:49 -07:00
parent 7f335a4632
commit 45f926c234

View file

@ -2056,16 +2056,14 @@ fn cmd_backout(
fn is_fast_forward(repo: RepoRef, branch_name: &str, new_target_id: &CommitId) -> bool { fn is_fast_forward(repo: RepoRef, branch_name: &str, new_target_id: &CommitId) -> bool {
if let Some(current_target) = repo.view().get_local_branch(branch_name) { if let Some(current_target) = repo.view().get_local_branch(branch_name) {
if current_target current_target
.adds() .adds()
.iter() .iter()
.any(|add| repo.index().is_ancestor(add, new_target_id)) .any(|add| repo.index().is_ancestor(add, new_target_id))
{ } else {
return true; true
} }
} }
false
}
fn cmd_branch( fn cmd_branch(
ui: &mut Ui, ui: &mut Ui,