Skip to content

Commit

Permalink
git: exclude hidden commits from list of commits to be abandoned
Browse files Browse the repository at this point in the history
This wasn't a problem before, but we wouldn't want to report previously-hidden
commits as abandoned.
  • Loading branch information
yuja committed Sep 30, 2023
1 parent 482298d commit 147bca3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::backend::{BackendError, CommitId, ObjectId};
use crate::git_backend::GitBackend;
use crate::op_store::{BranchTarget, RefTarget, RefTargetOptionExt};
use crate::repo::{MutableRepo, Repo};
use crate::revset;
use crate::revset::{self, RevsetExpression};
use crate::settings::GitSettings;
use crate::view::{RefName, View};

Expand Down Expand Up @@ -308,7 +308,13 @@ pub fn import_some_refs(
// about abandoned commits for now. We may want to change this if we ever
// add a way of preserving change IDs across rewrites by `git` (e.g. by
// putting them in the commit message).
let abandoned_commits = revset::walk_revs(mut_repo, &hidable_git_heads, &pinned_heads)
let abandoned_expression = RevsetExpression::commits(pinned_heads)
.range(&RevsetExpression::commits(hidable_git_heads))
.intersection(&RevsetExpression::visible_heads().ancestors());
let abandoned_commits = revset::optimize(abandoned_expression)
.resolve(mut_repo)
.unwrap()
.evaluate(mut_repo)
.unwrap()
.iter()
.collect_vec();
Expand Down

0 comments on commit 147bca3

Please sign in to comment.