ok/jj
1
0
Fork 0
forked from mirrors/jj

git: skip tags pointing to GPG keys and similar when importing refs

This commit is contained in:
Martin von Zweigbergk 2021-03-14 13:39:45 -07:00
parent 429a1ad7ab
commit 1e9d428406
2 changed files with 9 additions and 1 deletions

View file

@ -50,7 +50,13 @@ pub fn import_refs(
// TODO: Is it useful to import HEAD (especially if it's detached)?
continue;
}
let git_commit = git_ref.peel_to_commit()?;
let git_commit = match git_ref.peel_to_commit() {
Ok(git_commit) => git_commit,
Err(_) => {
// Perhaps a tag pointing to a GPG key or similar. Just skip it.
continue;
}
};
let id = CommitId(git_commit.id().as_bytes().to_vec());
let commit = store.get_commit(&id).unwrap();
tx.add_head(&commit);

View file

@ -110,6 +110,8 @@ fn test_import_refs_reimport() {
let commit2 = empty_git_commit(&git_repo, "refs/heads/main", &[&commit1]);
let commit3 = empty_git_commit(&git_repo, "refs/heads/feature1", &[&commit2]);
let commit4 = empty_git_commit(&git_repo, "refs/heads/feature2", &[&commit2]);
let pgp_key_oid = git_repo.blob(b"my PGP key").unwrap();
git_repo.reference("refs/tags/my-gpg-key", pgp_key_oid, false, "").unwrap();
let heads_before = repo.view().heads().clone();
let mut tx = repo.start_transaction("test");