From 1c4a2cd1673e91f6a0fc0ee96650446995552b26 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Mon, 4 Mar 2024 12:43:00 +0100 Subject: [PATCH] helper: Fix error message Git was outputting a confusing message when an unuspported option was used: fatal: helper rad does not support 'push-option' This fixes it. --- radicle-cli/examples/git/git-push.md | 6 ++++++ radicle-remote-helper/src/lib.rs | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/radicle-cli/examples/git/git-push.md b/radicle-cli/examples/git/git-push.md index c7762dcb..d216d7a9 100644 --- a/radicle-cli/examples/git/git-push.md +++ b/radicle-cli/examples/git/git-push.md @@ -69,3 +69,9 @@ $ git push rad :master error: refusing to delete default branch ref 'refs/heads/master' error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi' ``` + +If you pass an unsupported push option, you get an error: +``` (stderr) (fail) +$ git push -o alien rad HEAD:alice/2 +error: unknown push option "alien" +``` diff --git a/radicle-remote-helper/src/lib.rs b/radicle-remote-helper/src/lib.rs index 7ada7d44..47644d76 100644 --- a/radicle-remote-helper/src/lib.rs +++ b/radicle-remote-helper/src/lib.rs @@ -146,11 +146,12 @@ pub fn run(profile: radicle::Profile) -> Result<(), Error> { println!("ok"); } ["option", "push-option", args @ ..] => { - if push_option(args, &mut opts).is_ok() { - println!("ok"); - } else { - println!("unsupported"); - } + // Nb. Git documentation says that we can print `error ` or `unsupported` + // for options that are not supported, but this results in Git saying that + // "push-option" itself is an unsupported option, which is not helpful or correct. + // Hence, we just exit with an error in this case. + push_option(args, &mut opts)?; + println!("ok"); } ["option", "progress", ..] => { println!("unsupported");