Skip to content

Commit

Permalink
jj git push: remove the NotFastForward error
Browse files Browse the repository at this point in the history
Now that we always force push, it should not occur in practice.
  • Loading branch information
ilyagr committed May 15, 2024
1 parent b4e9987 commit b658fb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
12 changes: 5 additions & 7 deletions cli/src/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
10 changes: 1 addition & 9 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b658fb3

Please sign in to comment.