Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
helper: Allow pushing a raw SHA-1
Merged did:key:z6MksFqX...wzpT opened 2 years ago
3 files changed +26 -2 4276a70e 0b5fa51a
modified 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
```
modified 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
+
```
modified radicle-remote-helper/src/push.rs
@@ -553,8 +553,18 @@ fn push<G: Signer>(
    patches: patch::Cache<patch::Patches<'_, storage::git::Repository>, cob::cache::StoreWriter>,
    signer: &G,
) -> Result<Option<ExplorerResource>, 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();