From 520f692a4600980566568b34ffb5dca74e6b7a36 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 27 Sep 2023 20:56:59 +0900 Subject: [PATCH] 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. --- lib/src/git.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/git.rs b/lib/src/git.rs index 582bf4ee1c..db2f823489 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -356,15 +356,16 @@ fn diff_refs_to_import( 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 /// `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. fn pinned_commit_ids(view: &View) -> impl Iterator { - let branch_ref_targets = view.branches().values().flat_map(|branch_target| { - iter::once(&branch_target.local_target).chain(branch_target.remote_targets.values()) - }); + let branch_ref_targets = view + .branches() + .values() + .map(|branch_target| &branch_target.local_target); itertools::chain!( branch_ref_targets, view.tags().values(),