diff --git a/radicle-cli/examples/rad-patch-ahead-behind.md b/radicle-cli/examples/rad-patch-ahead-behind.md index 7450743a..669e7be7 100644 --- a/radicle-cli/examples/rad-patch-ahead-behind.md +++ b/radicle-cli/examples/rad-patch-ahead-behind.md @@ -123,7 +123,7 @@ If we want to instead create a "stacked" patch, we can do so with the `patch.base` push option: ``` (stderr) -$ git push -o patch.message="Add Mel #2" -o patch.base=5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 rad HEAD:refs/patches +$ git push -o patch.message="Add Mel #2" -o patch.base=HEAD^ rad HEAD:refs/patches ✓ Patch 11ab7fbec82c3aed393d7a696d6b3c7714735056 opened To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi * [new reference] HEAD -> refs/patches diff --git a/radicle-remote-helper/src/lib.rs b/radicle-remote-helper/src/lib.rs index b96d7b58..713d3d5f 100644 --- a/radicle-remote-helper/src/lib.rs +++ b/radicle-remote-helper/src/lib.rs @@ -13,6 +13,7 @@ use std::str::FromStr; use std::time; use std::{env, io}; +use radicle_cli::git::Rev; use thiserror::Error; use radicle::git; @@ -25,6 +26,9 @@ use radicle_cli::terminal as cli; #[derive(Debug, Error)] pub enum Error { + /// Failed to parse `base`. + #[error("failed to parse base revision: {0}")] + Base(Box), /// Remote repository not found (or empty). #[error("remote repository `{0}` not found")] RepositoryNotFound(PathBuf), @@ -70,7 +74,7 @@ pub struct Options { /// Open patch in draft mode. draft: bool, /// Patch base to use, when opening or updating a patch. - base: Option, + base: Option, /// Patch message. message: cli::patch::Message, } @@ -138,7 +142,8 @@ pub fn run(profile: radicle::Profile) -> Result<(), Error> { opts.message.append(val); } "patch.base" => { - let base = val.parse()?; + let base = cli::args::rev(&val.into()) + .map_err(|e| Error::Base(e.into()))?; opts.base = Some(base); } _ => { diff --git a/radicle-remote-helper/src/push.rs b/radicle-remote-helper/src/push.rs index 4ea8aeec..57e3ca3f 100644 --- a/radicle-remote-helper/src/push.rs +++ b/radicle-remote-helper/src/push.rs @@ -309,7 +309,7 @@ fn patch_open( let (_, target) = stored.canonical_head()?; let head = commit.id().into(); let base = if let Some(base) = opts.base { - base + base.resolve(working)? } else { stored.merge_base(&target, &head)? }; @@ -425,7 +425,7 @@ fn patch_update( let (_, target) = stored.canonical_head()?; let head: git::Oid = commit.id().into(); let base = if let Some(base) = opts.base { - base + base.resolve(working)? } else { stored.merge_base(&target, &head)? };