mirror of
https://github.com/jj-vcs/jj.git
synced 2025-12-23 06:01:01 +00:00
rebase: abandon commits while rebasing
This fixes a bug where the rebase wouldn't work properly if a root of the target commit set was abandoned before being rebased.
This commit is contained in:
parent
e75afec82c
commit
4eabf9a511
2 changed files with 11 additions and 13 deletions
|
|
@ -24,8 +24,8 @@ use jj_lib::object_id::ObjectId as _;
|
|||
use jj_lib::repo::ReadonlyRepo;
|
||||
use jj_lib::repo::Repo as _;
|
||||
use jj_lib::revset::RevsetExpression;
|
||||
use jj_lib::rewrite::compute_move_commits;
|
||||
use jj_lib::rewrite::find_duplicate_divergent_commits;
|
||||
use jj_lib::rewrite::move_commits;
|
||||
use jj_lib::rewrite::EmptyBehaviour;
|
||||
use jj_lib::rewrite::MoveCommitsLocation;
|
||||
use jj_lib::rewrite::MoveCommitsStats;
|
||||
|
|
@ -403,12 +403,11 @@ pub(crate) fn cmd_rebase(
|
|||
};
|
||||
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
let mut computed_move = compute_move_commits(tx.repo(), &loc)?;
|
||||
if !args.keep_divergent {
|
||||
let abandoned_divergent =
|
||||
find_duplicate_divergent_commits(tx.repo(), &loc.new_parent_ids, &loc.target)?;
|
||||
for commit in &abandoned_divergent {
|
||||
tx.repo_mut().record_abandoned_commit(commit);
|
||||
}
|
||||
computed_move.record_to_abandon(abandoned_divergent.iter().map(Commit::id).cloned());
|
||||
if !abandoned_divergent.is_empty() {
|
||||
writeln!(
|
||||
ui.status(),
|
||||
|
|
@ -417,7 +416,7 @@ pub(crate) fn cmd_rebase(
|
|||
)?;
|
||||
}
|
||||
};
|
||||
let stats = move_commits(tx.repo_mut(), &loc, &rebase_options)?;
|
||||
let stats = computed_move.apply(tx.repo_mut(), &rebase_options)?;
|
||||
print_move_commits_stats(ui, &stats)?;
|
||||
tx.finish(ui, tx_description(&loc.target))?;
|
||||
|
||||
|
|
|
|||
|
|
@ -3019,18 +3019,17 @@ fn test_rebase_skip_duplicate_divergent() {
|
|||
------- stderr -------
|
||||
Skipped 1 divergent commits that were already present in the destination
|
||||
Rebased 1 commits to destination
|
||||
Working copy (@) now at: znkkpsqq ead5b1d4 d | d
|
||||
Parent commit (@-) : rlvkpnrz 08789390 a b1 | a
|
||||
Added 0 files, modified 1 files, removed 0 files
|
||||
Working copy (@) now at: znkkpsqq 81e83d0f d | d
|
||||
Parent commit (@-) : zsuskuln 3f194323 b1 b2 | b2
|
||||
Added 1 files, modified 0 files, removed 0 files
|
||||
[EOF]
|
||||
");
|
||||
// BUG: "d" should be on top of "b2", but it wasn't rebased
|
||||
insta::assert_snapshot!(get_long_log_output(&work_dir), @r"
|
||||
@ d znkkpsqq ead5b1d4: a b1
|
||||
│ ○ b2 zsuskuln 3f194323: c
|
||||
│ ○ c royxmykx 0fdb9e5a: a b1
|
||||
├─╯
|
||||
○ a b1 rlvkpnrz 08789390
|
||||
@ d znkkpsqq 81e83d0f: b1 b2
|
||||
○ b1 b2 zsuskuln 3f194323: c
|
||||
○ c royxmykx 0fdb9e5a: a
|
||||
○ a rlvkpnrz 08789390
|
||||
◆ zzzzzzzz 00000000
|
||||
[EOF]
|
||||
");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue