diff --git a/radicle-cli/examples/git/git-push-delete.md b/radicle-cli/examples/git/git-push-delete.md index b2b7c606..9ca29cdf 100644 --- a/radicle-cli/examples/git/git-push-delete.md +++ b/radicle-cli/examples/git/git-push-delete.md @@ -3,6 +3,7 @@ Finally, we can also delete branches with `git push`: ``` $ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi refs/heads/* 145e1e69bef3ad93d14946ea212249c2fa9b9828 refs/heads/alice/1 +ddcc1f164eacfd7dba41da9bff3261da3ee79fd3 refs/heads/alice/2 f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/heads/master ``` @@ -14,5 +15,6 @@ To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkE ``` $ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi refs/heads/* +ddcc1f164eacfd7dba41da9bff3261da3ee79fd3 refs/heads/alice/2 f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/heads/master ``` diff --git a/radicle-cli/examples/git/git-push.md b/radicle-cli/examples/git/git-push.md index 9abbaa9d..63263982 100644 --- a/radicle-cli/examples/git/git-push.md +++ b/radicle-cli/examples/git/git-push.md @@ -76,3 +76,15 @@ If you pass an unsupported push option, you get an error: $ git push -o alien rad HEAD:alice/2 error: unknown push option "alien" ``` + +We can also push a SHA-1: + +``` +$ git commit -m "Something good" --allow-empty -s +[alice/1 ddcc1f1] Something good +``` +``` (stderr) +$ git push -o no-sync rad ddcc1f164eacfd7dba41da9bff3261da3ee79fd3:refs/heads/alice/2 +To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi + * [new branch] ddcc1f164eacfd7dba41da9bff3261da3ee79fd3 -> alice/2 +``` diff --git a/radicle-remote-helper/src/push.rs b/radicle-remote-helper/src/push.rs index b9834fe5..3a11c82d 100644 --- a/radicle-remote-helper/src/push.rs +++ b/radicle-remote-helper/src/push.rs @@ -553,8 +553,18 @@ fn push( patches: patch::Cache, cob::cache::StoreWriter>, signer: &G, ) -> Result, Error> { - let head = working.find_reference(src.as_str())?; - let head = head.peel_to_commit()?.id(); + let head = match working.find_reference(src.as_str()) { + Ok(obj) => obj.peel_to_commit()?, + Err(e) => { + if let Ok(oid) = git::Oid::from_str(src.as_str()) { + working.find_commit(oid.into())? + } else { + return Err(e.into()); + } + } + } + .id(); + let dst = dst.with_namespace(nid.into()); // It's ok for the destination reference to be unknown, eg. when pushing a new branch. let old = stored.backend.find_reference(dst.as_str()).ok();