Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib git.rs: remove workaround for a now-fixed libgit2 bug #3516

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 6 additions & 25 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,50 +1275,31 @@ pub fn push_updates(
updates: &[GitRefUpdate],
callbacks: RemoteCallbacks<'_>,
) -> Result<(), GitPushError> {
let mut temp_refs = vec![];
let mut qualified_remote_refs = vec![];
let mut refspecs = vec![];
for update in updates {
qualified_remote_refs.push(update.qualified_name.as_str());
if let Some(new_target) = &update.new_target {
// Create a temporary ref to work around https://github.com/libgit2/libgit2/issues/3178
let temp_ref_name = format!("refs/jj/git-push/{}", new_target.hex());
temp_refs.push(git_repo.reference(
&temp_ref_name,
git2::Oid::from_bytes(new_target.as_bytes()).unwrap(),
true,
"temporary reference for git push",
)?);
refspecs.push(format!(
"{}{}:{}",
(if update.force { "+" } else { "" }),
temp_ref_name,
git2::Oid::from_bytes(new_target.as_bytes()).unwrap(),
ilyagr marked this conversation as resolved.
Show resolved Hide resolved
update.qualified_name
));
} else {
refspecs.push(format!(":{}", update.qualified_name));
}
}
let result = push_refs(
// TODO(ilyagr): this function will be reused to implement force-with-lease, so
// don't inline for now. If it's after 2024-06-01 or so, ilyagr may have
// forgotten to delete this comment.
push_refs(
git_repo,
remote_name,
&qualified_remote_refs,
&refspecs,
callbacks,
);
for mut temp_ref in temp_refs {
// TODO: Figure out how to do the equivalent of absl::Cleanup for
// temp_ref.delete().
if let Err(err) = temp_ref.delete() {
// Propagate error only if we don't already have an error to return and it's not
// NotFound (there may be duplicates if the list if multiple branches moved to
// the same commit).
if result.is_ok() && err.code() != git2::ErrorCode::NotFound {
return Err(GitPushError::InternalGitError(err));
}
}
}
result
)
}

fn push_refs(
Expand Down