Skip to content

Commit

Permalink
feat(rebase): do not rebase to same base
Browse files Browse the repository at this point in the history
Abort the rebase early when the specified target is the same commit
that the branch is already based on.
  • Loading branch information
jpgrayson committed Jul 28, 2024
1 parent 8d3ead8 commit 06e0608
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cmd/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ fn run(matches: &ArgMatches) -> Result<()> {
stack.base().clone()
};

if !matches.get_flag("interactive") && target_commit.id == stack.base().id {
print_info_message(
matches,
&format!(
"Already based on {}",
formatted_target_id_and_ref(&repo, std::rc::Rc::clone(&target_commit))
),
);
return Ok(());
}

if stack.is_protected(&config) {
return Err(anyhow!("this branch is protected; rebase is not permitted"));
}
Expand Down

0 comments on commit 06e0608

Please sign in to comment.