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.
This commit is contained in:
Alexis Sellier 2024-03-04 12:43:00 +01:00 committed by cloudhead
parent 786ce40f95
commit 1c4a2cd167
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View File

@ -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"
```

View File

@ -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 <msg>` 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");