forked from mirrors/jj
git: on import_refs(), don't preserve old branches referenced by remote refs
If we made @git branches real .remote_targets["git"], remotely-rewritten commits could also be pinned by the @git branches, and therefore wouldn't be abandoned. We could exclude the "git" remote, but I don't think local commits should be pinned by remote refs in general. If we squashed a fetched commit, remote ref would point to a hidden commit anyway.
This commit is contained in:
parent
5f63400f2f
commit
520f692a46
1 changed files with 5 additions and 4 deletions
|
@ -356,15 +356,16 @@ fn diff_refs_to_import(
|
||||||
Ok(changed_git_refs)
|
Ok(changed_git_refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Commits referenced by local/remote branches, tags, or HEAD@git.
|
/// Commits referenced by local branches, tags, or HEAD@git.
|
||||||
///
|
///
|
||||||
/// On `import_refs()`, this is similar to collecting commits referenced by
|
/// On `import_refs()`, this is similar to collecting commits referenced by
|
||||||
/// `view.git_refs()`. Main difference is that local branches can be moved by
|
/// `view.git_refs()`. Main difference is that local branches can be moved by
|
||||||
/// tracking remotes, and such mutation isn't applied to `view.git_refs()` yet.
|
/// tracking remotes, and such mutation isn't applied to `view.git_refs()` yet.
|
||||||
fn pinned_commit_ids(view: &View) -> impl Iterator<Item = &CommitId> {
|
fn pinned_commit_ids(view: &View) -> impl Iterator<Item = &CommitId> {
|
||||||
let branch_ref_targets = view.branches().values().flat_map(|branch_target| {
|
let branch_ref_targets = view
|
||||||
iter::once(&branch_target.local_target).chain(branch_target.remote_targets.values())
|
.branches()
|
||||||
});
|
.values()
|
||||||
|
.map(|branch_target| &branch_target.local_target);
|
||||||
itertools::chain!(
|
itertools::chain!(
|
||||||
branch_ref_targets,
|
branch_ref_targets,
|
||||||
view.tags().values(),
|
view.tags().values(),
|
||||||
|
|
Loading…
Reference in a new issue