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

git: expand RefName match arms in import_refs()

This prepares for the removal of merge_single_refs().
This commit is contained in:
Yuya Nishihara 2023-10-20 20:15:58 +09:00
parent ffe7e5f142
commit 6dfe1572a0

View file

@ -271,22 +271,30 @@ pub fn import_some_refs(
default_remote_ref_state_for(ref_name, git_settings)
},
};
if let RefName::RemoteBranch { branch, remote } = ref_name {
if new_remote_ref.is_tracking() {
let local_ref_name = RefName::LocalBranch(branch.clone());
mut_repo.merge_single_ref(&local_ref_name, base_target, &new_remote_ref.target);
}
// Remote-tracking branch is the last known state of the branch in the remote.
// It shouldn't diverge even if we had inconsistent view.
mut_repo.set_remote_branch(branch, remote, new_remote_ref);
} else {
if new_remote_ref.is_tracking() {
mut_repo.merge_single_ref(ref_name, base_target, &new_remote_ref.target);
}
if let RefName::LocalBranch(branch) = ref_name {
match ref_name {
RefName::LocalBranch(branch) => {
if new_remote_ref.is_tracking() {
mut_repo.merge_single_ref(ref_name, base_target, &new_remote_ref.target);
}
// Update Git-tracking branch like the other remote branches.
mut_repo.set_remote_branch(branch, REMOTE_NAME_FOR_LOCAL_GIT_REPO, new_remote_ref);
}
RefName::RemoteBranch { branch, remote } => {
if new_remote_ref.is_tracking() {
let local_ref_name = RefName::LocalBranch(branch.clone());
mut_repo.merge_single_ref(&local_ref_name, base_target, &new_remote_ref.target);
}
// Remote-tracking branch is the last known state of the branch in the remote.
// It shouldn't diverge even if we had inconsistent view.
mut_repo.set_remote_branch(branch, remote, new_remote_ref);
}
RefName::Tag(_) => {
if new_remote_ref.is_tracking() {
mut_repo.merge_single_ref(ref_name, base_target, &new_remote_ref.target);
}
// TODO: If we add Git-tracking tag, it will be updated here.
}
RefName::GitRef(_) => unreachable!(),
}
}