mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 15:32:49 +00:00
git: inline subprocess_push_refs
into push_updates
This commit is contained in:
parent
05fc0d4985
commit
f29c784d7b
@ -2321,7 +2321,7 @@ pub fn push_updates(
|
|||||||
git_settings: &GitSettings,
|
git_settings: &GitSettings,
|
||||||
remote_name: &RemoteName,
|
remote_name: &RemoteName,
|
||||||
updates: &[GitRefUpdate],
|
updates: &[GitRefUpdate],
|
||||||
callbacks: RemoteCallbacks<'_>,
|
mut callbacks: RemoteCallbacks<'_>,
|
||||||
) -> Result<GitPushStats, GitPushError> {
|
) -> Result<GitPushStats, GitPushError> {
|
||||||
let mut qualified_remote_refs_expected_locations = HashMap::new();
|
let mut qualified_remote_refs_expected_locations = HashMap::new();
|
||||||
let mut refspecs = vec![];
|
let mut refspecs = vec![];
|
||||||
@ -2342,31 +2342,12 @@ pub fn push_updates(
|
|||||||
refspecs.push(RefSpec::delete(&update.qualified_name));
|
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_backend = get_git_backend(repo.store())?;
|
||||||
let git_repo = git_backend.git_repo();
|
let git_repo = git_backend.git_repo();
|
||||||
let git_ctx =
|
let git_ctx =
|
||||||
GitSubprocessContext::from_git_backend(git_backend, &git_settings.executable_path);
|
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
|
// check the remote exists
|
||||||
if git_repo.try_find_remote(remote_name.as_str()).is_none() {
|
if git_repo.try_find_remote(remote_name.as_str()).is_none() {
|
||||||
return Err(GitPushError::NoSuchRemote(remote_name.to_owned()));
|
return Err(GitPushError::NoSuchRemote(remote_name.to_owned()));
|
||||||
@ -2374,7 +2355,7 @@ fn subprocess_push_refs(
|
|||||||
|
|
||||||
let refs_to_push: Vec<RefToPush> = refspecs
|
let refs_to_push: Vec<RefToPush> = refspecs
|
||||||
.iter()
|
.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();
|
.collect();
|
||||||
|
|
||||||
let mut push_stats = git_ctx.spawn_push(remote_name, &refs_to_push, &mut callbacks)?;
|
let mut push_stats = git_ctx.spawn_push(remote_name, &refs_to_push, &mut callbacks)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user