git: on import, update record of ref only if it changed

There's no need to update our record of the ref if it didn't
change. This is just about making it clearer; I doubt it will have
measurable performance impact.
This commit is contained in:
Martin von Zweigbergk 2022-12-03 10:06:22 -08:00 committed by Martin von Zweigbergk
parent 84a4dee673
commit 9df247f87c

View file

@ -109,10 +109,10 @@ pub fn import_refs(
new_git_heads.insert(id.clone());
// TODO: Make it configurable which remotes are publishing and update public
// heads here.
mut_repo.set_git_ref(full_name.clone(), RefTarget::Normal(id.clone()));
let old_target = existing_git_refs.remove(&full_name);
let new_target = Some(RefTarget::Normal(id.clone()));
if new_target != old_target {
mut_repo.set_git_ref(full_name.clone(), RefTarget::Normal(id.clone()));
let commit = store.get_commit(&id).unwrap();
mut_repo.add_head(&commit);
changed_git_refs.insert(full_name, (old_target, new_target));