From 29f10a76dfe21bc28c0a6e529f8890e5cbe5d163 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 | 5 ----- lib/src/git.rs | 10 +--------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 2f3ddc50ee..c1dceeb7c2 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -1015,11 +1015,6 @@ fn cmd_git_push( }) .map_err(|err| match err { GitPushError::InternalGitError(err) => map_git_error(err), - GitPushError::NotFastForward => user_error_with_hint( - "The push conflicts with changes made on the remote (it is not fast-forwardable).", - "Try fetching from the remote, then make the branch point to where you want it to be, \ - and push again.", - ), GitPushError::RefInUnexpectedLocation(refs) => user_error_with_hint( format!( "Refusing to push a branch that unexpectedly moved on the remote. Affected refs: \ diff --git a/lib/src/git.rs b/lib/src/git.rs index 4d2b883503..d437d500aa 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -1209,9 +1209,6 @@ pub enum GitPushError { name = REMOTE_NAME_FOR_LOCAL_GIT_REPO )] RemoteReservedForLocalGitRepo, - // TODO: Delete this? It should never trigger - #[error("Push is not fast-forwardable")] - NotFastForward, #[error("Refs in unexpected location: {0:?}")] RefInUnexpectedLocation(Vec), #[error("Remote rejected the update of some refs (do you have permission to push to {0:?}?)")] @@ -1424,12 +1421,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