git: inline subprocess_push_refs into push_updates

This commit is contained in:
Emily 2025-03-20 20:32:17 +00:00
parent 05fc0d4985
commit f29c784d7b

View File

@ -2321,7 +2321,7 @@ pub fn push_updates(
git_settings: &GitSettings,
remote_name: &RemoteName,
updates: &[GitRefUpdate],
callbacks: RemoteCallbacks<'_>,
mut callbacks: RemoteCallbacks<'_>,
) -> Result<GitPushStats, GitPushError> {
let mut qualified_remote_refs_expected_locations = HashMap::new();
let mut refspecs = vec![];
@ -2342,31 +2342,12 @@ pub fn push_updates(
refspecs.push(RefSpec::delete(&update.qualified_name));
}
}
// TODO(ilyagr): `push_refs`, or parts of it, should probably be inlined. This
// requires adjusting some tests.
let git_backend = get_git_backend(repo.store())?;
let git_repo = git_backend.git_repo();
let git_ctx =
GitSubprocessContext::from_git_backend(git_backend, &git_settings.executable_path);
subprocess_push_refs(
&git_repo,
&git_ctx,
remote_name,
&qualified_remote_refs_expected_locations,
&refspecs,
callbacks,
)
}
fn subprocess_push_refs(
git_repo: &gix::Repository,
git_ctx: &GitSubprocessContext,
remote_name: &RemoteName,
qualified_remote_refs_expected_locations: &HashMap<&GitRefName, Option<&CommitId>>,
refspecs: &[RefSpec],
mut callbacks: RemoteCallbacks<'_>,
) -> Result<GitPushStats, GitPushError> {
// check the remote exists
if git_repo.try_find_remote(remote_name.as_str()).is_none() {
return Err(GitPushError::NoSuchRemote(remote_name.to_owned()));
@ -2374,7 +2355,7 @@ fn subprocess_push_refs(
let refs_to_push: Vec<RefToPush> = refspecs
.iter()
.map(|full_refspec| RefToPush::new(full_refspec, qualified_remote_refs_expected_locations))
.map(|full_refspec| RefToPush::new(full_refspec, &qualified_remote_refs_expected_locations))
.collect();
let mut push_stats = git_ctx.spawn_push(remote_name, &refs_to_push, &mut callbacks)?;