mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
view: also merge git_heads
when merging views
I don't know if I had just forgotten to merge `git_heads` when I added it to the view object, but it seems like it should be merged just like refs.
This commit is contained in:
parent
4e8fbaa210
commit
fafa9b70fc
2 changed files with 13 additions and 2 deletions
|
@ -39,6 +39,7 @@ use crate::op_store::{
|
|||
BranchTarget, OpStore, OperationId, OperationMetadata, RefTarget, WorkspaceId,
|
||||
};
|
||||
use crate::operation::Operation;
|
||||
use crate::refs::merge_ref_targets;
|
||||
use crate::rewrite::DescendantRebaser;
|
||||
use crate::settings::{RepoSettings, UserSettings};
|
||||
use crate::simple_op_heads_store::SimpleOpHeadsStore;
|
||||
|
@ -1108,6 +1109,17 @@ impl MutableRepo {
|
|||
other_target.as_ref(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(new_git_head) = merge_ref_targets(
|
||||
self.index.as_index_ref(),
|
||||
self.view().git_head(),
|
||||
base.git_head(),
|
||||
other.git_head(),
|
||||
) {
|
||||
self.set_git_head(new_git_head);
|
||||
} else {
|
||||
self.clear_git_head();
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds and records commits that were rewritten or abandoned between
|
||||
|
|
|
@ -462,8 +462,7 @@ fn test_merge_views_git_heads() {
|
|||
removes: vec![tx0_head.id().clone()],
|
||||
adds: vec![tx1_head.id().clone(), tx2_head.id().clone()],
|
||||
};
|
||||
// TODO: Should be equal
|
||||
assert_ne!(repo.view().git_head(), Some(&expected_git_head));
|
||||
assert_eq!(repo.view().git_head(), Some(&expected_git_head));
|
||||
}
|
||||
|
||||
fn commit_transactions(settings: &UserSettings, txs: Vec<Transaction>) -> Arc<ReadonlyRepo> {
|
||||
|
|
Loading…
Reference in a new issue