From 894cbc3446ba97ad67286b62bfb1279ff14fd61f Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 17 Apr 2024 21:59:33 -0700 Subject: [PATCH] jj git push: remove the NotFastForward error Now that we always force push, it should not occur in practice. --- cli/src/commands/git.rs | 12 +++++------- lib/src/git.rs | 10 +--------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 6ecf3af2e7..5437812519 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -1015,13 +1015,11 @@ fn cmd_git_push( }) .map_err(|err| match err { GitPushError::InternalGitError(err) => map_git_error(err), - GitPushError::NotFastForward | GitPushError::RefInUnexpectedLocation(_) => { - user_error_with_hint( - err.to_string(), - "Try fetching from the remote, then make the branch point to where you want it to \ - be, and push again.", - ) - } + GitPushError::RefInUnexpectedLocation(_) => user_error_with_hint( + err.to_string(), + "Try fetching from the remote, then make the branch point to where you want it to be, \ + and push again.", + ), _ => user_error(err), })?; writer.flush(ui)?; diff --git a/lib/src/git.rs b/lib/src/git.rs index 0d08c08eec..95ed6045bf 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -1208,9 +1208,6 @@ pub enum GitPushError { name = REMOTE_NAME_FOR_LOCAL_GIT_REPO )] RemoteReservedForLocalGitRepo, - // TODO: Delete this? It should never trigger - #[error("The push conflicts with changes made on the remote (it is not fast-forwardable).")] - NotFastForward, #[error("Refusing to push a branch that unexpectedly moved on the remote. {}", render_ref_in_unexpected_location_details(.0) )] @@ -1458,12 +1455,7 @@ fn push_refs( push_options.remote_callbacks(callbacks); remote .push(refspecs, Some(&mut push_options)) - .map_err(|err| match (err.class(), err.code()) { - (git2::ErrorClass::Reference, git2::ErrorCode::NotFastForward) => { - GitPushError::NotFastForward - } - _ => GitPushError::InternalGitError(err), - }) + .map_err(GitPushError::InternalGitError) }; if !failed_push_negotiations.is_empty() { // If the push negotiation returned an error, `remote.push` would not