Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
remote-helper: List `HEAD`
✗ CI failure Lorenz Leutgeb committed 7 months ago
commit 9b6683739e60d930ad2bd63f3e0cfdd46118c60d
parent 5bff08f75044330991dc6f0e1e9e986d5441caf5
2 failed (2 total) View logs
15 files changed +70 -17
modified CHANGELOG.md
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `rad clone` now supports the flag `--bare` which works analoguously to 
  `git clone --bare`.
- `rad init --setup-signing` now works on bare repositories.
+
- `git-remote-rad` now correctly reports the default branch to Git by listing
+
  the symbolic reference `HEAD`.

## Fixed Bugs

modified crates/radicle-cli/examples/git/git-push-converge.md
@@ -35,6 +35,7 @@ pushing to their `rad` remote -- but they won't sync to the network just yet:
$ git commit -m "Alice's commit" --allow-empty -q
$ git push rad -o no-sync
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
```

@@ -43,6 +44,7 @@ $ git add README
$ git commit -m "Bob's commit" -q
$ git push rad -o no-sync
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
```

@@ -51,6 +53,7 @@ $ git add README
$ git commit -m "Eve's commit" -q
$ git push rad -o no-sync
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
```

modified crates/radicle-cli/examples/git/git-push.md
@@ -54,6 +54,7 @@ List the canonical refs:

```
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
```

modified crates/radicle-cli/examples/rad-init-existing-bare.md
@@ -40,7 +40,7 @@ $ git remote show rad
* remote rad
  Fetch URL: rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji
  Push  URL: rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
  HEAD branch: (unknown)
+
  HEAD branch: master
  Remote branch:
    master new (next fetch will store in remotes/rad)
  Local ref configured for 'git push':
modified crates/radicle-cli/examples/rad-init-existing.md
@@ -37,7 +37,7 @@ $ git remote show rad
* remote rad
  Fetch URL: rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji
  Push  URL: rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
  HEAD branch: (unknown)
+
  HEAD branch: master
  Remote branch:
    master new (next fetch will store in remotes/rad)
  Local ref configured for 'git push':
modified crates/radicle-cli/examples/rad-patch-fetch-2.md
@@ -22,6 +22,7 @@ $ git branch -r
$ git pull
Already up to date.
$ git branch -r
+
  rad/HEAD -> rad/master
  rad/master
  rad/patches/5e2dedcc5d515fcbc1cca483d3376609fe889bfb
```
modified crates/radicle-cli/examples/rad-patch-pull-update.md
@@ -112,6 +112,7 @@ $ rad patch show 55b9721
│ ↑ updated to f91e056da05b2d9a58af1160c76245bc3debf7a8 (cad2666) now │
╰─────────────────────────────────────────────────────────────────────╯
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
cad2666a8a2250e4dee175ed5044be2c251ff08b	refs/heads/patches/55b9721ed7f6bfec38f43729e9b6631c5dc812fb
```
modified crates/radicle-cli/examples/rad-patch-via-push.md
@@ -61,6 +61,7 @@ And let's look at our local and remote refs:
$ git show-ref
42d894a83c9c356552a57af09ccdbd5587a99045 refs/heads/feature/1
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/heads/master
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/remotes/rad/HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/remotes/rad/master
42d894a83c9c356552a57af09ccdbd5587a99045 refs/remotes/rad/patches/6035d2f582afbe01ff23ea87528ae523d76875b6
```
modified crates/radicle-remote-helper/src/list.rs
@@ -46,20 +46,36 @@ pub fn for_fetch<R: ReadRepository + cob::Store<Namespace = NodeId> + 'static>(
            println!("{oid} {name}");
        }
    } else {
-
        // Listing canonical refs.
-
        // We skip over `refs/rad/*`, since those are not meant to be fetched into a working copy.
-
        for glob in [
-
            git::refspec::pattern!("refs/heads/*"),
-
            git::refspec::pattern!("refs/tags/*"),
-
        ] {
-
            for (name, oid) in stored.references_glob(&glob)? {
-
                println!("{oid} {name}");
+
        {
+
            // List the symbolic reference `HEAD`, which is interpreted by
+
            // Git clients to determine the default branch.
+
            let head = git::refname!("HEAD");
+

+
            if let Some(target) = stored
+
                .find_reference(&head)?
+
                .symbolic_target() { println!("@{target} {head}") }
+
        }
+

+
        {
+
            // List canonical references.
+
            // Skip over `refs/rad/*`, since those are not meant to be fetched into a working copy.
+
            for glob in [
+
                git::refspec::pattern!("refs/heads/*"),
+
                git::refspec::pattern!("refs/tags/*"),
+
            ] {
+
                for (name, oid) in stored.references_glob(&glob)? {
+
                    println!("{oid} {name}");
+
                }
            }
        }
-
        // List the patch refs, but don't abort if there's an error, as this would break
-
        // all fetch behavior. Instead, just output an error to the user.
-
        if let Err(e) = patch_refs(profile, stored) {
-
            eprintln!("remote: error listing patch refs: {e}");
+

+
        {
+
            // List the patch refs, but do not abort if there is an error,
+
            // as this would break all fetch behavior.
+
            // Instead, just output an error to the user.
+
            if let Err(e) = patch_refs(profile, stored) {
+
                eprintln!("remote: error listing patch refs: {e}");
+
            }
        }
    }
    println!();
modified crates/radicle-remote-helper/src/main.rs
@@ -366,4 +366,4 @@ pub(crate) fn patches_mut<'a>(
        }
        Err(err) => Err(err.into()),
    }
-
}

\ No newline at end of file
+
}
modified crates/radicle-remote-helper/src/push.rs
@@ -566,7 +566,8 @@ where

            if let Some(upstream) = upstream {
                // Setup current branch so that pushing updates the patch.
-
                if let Some(branch) = rad::setup_patch_upstream(&patch, head, working, upstream, false)?
+
                if let Some(branch) =
+
                    rad::setup_patch_upstream(&patch, head, working, upstream, false)?
                {
                    if let Some(name) = branch.name()? {
                        if profile.hints() {
modified crates/radicle/src/storage.rs
@@ -588,6 +588,12 @@ pub trait ReadRepository: Sized + ValidateRepository {
    /// Check whether the given commit is an ancestor of another commit.
    fn is_ancestor_of(&self, ancestor: Oid, head: Oid) -> Result<bool, git::ext::Error>;

+
    /// Look up a reference to one of the objects in a repository.
+
    fn find_reference(
+
        &self,
+
        reference: &git::RefStr,
+
    ) -> Result<git2::Reference<'_>, git::ext::Error>;
+

    /// Get the object id of a reference under the given remote.
    fn reference_oid(
        &self,
modified crates/radicle/src/storage/git.rs
@@ -27,7 +27,7 @@ use crate::storage::{
use crate::{git, node};

pub use crate::git::{
-
    ext, raw, refname, refspec, Oid, PatternStr, Qualified, RefError, RefString, UserInfo,
+
    ext, raw, refname, refspec, Oid, PatternStr, Qualified, RefError, RefStr, RefString, UserInfo,
};
pub use crate::storage::{Error, RepositoryError};

@@ -695,6 +695,13 @@ impl ReadRepository for Repository {
        Ok(oid.into())
    }

+
    fn find_reference(
+
        &self,
+
        reference: &git::RefStr,
+
    ) -> Result<git2::Reference<'_>, git::ext::Error> {
+
        Ok(self.backend.find_reference(reference.as_str())?)
+
    }
+

    fn commit(&self, oid: Oid) -> Result<git2::Commit, git::Error> {
        self.backend
            .find_commit(oid.into())
modified crates/radicle/src/storage/git/cob.rs
@@ -376,6 +376,13 @@ impl<R: storage::ReadRepository> ReadRepository for DraftStore<'_, R> {
    fn merge_base(&self, left: &Oid, right: &Oid) -> Result<Oid, git::ext::Error> {
        self.repo.merge_base(left, right)
    }
+

+
    fn find_reference(
+
        &self,
+
        _reference: &super::RefStr,
+
    ) -> Result<git2::Reference<'_>, git::ext::Error> {
+
        todo!()
+
    }
}

impl<R: storage::WriteRepository> cob::object::Storage for DraftStore<'_, R> {
modified crates/radicle/src/test/storage.rs
@@ -319,6 +319,13 @@ impl ReadRepository for MockRepository {
    fn merge_base(&self, _left: &Oid, _right: &Oid) -> Result<Oid, git::ext::Error> {
        todo!()
    }
+

+
    fn find_reference(
+
        &self,
+
        _reference: &git::RefStr,
+
    ) -> Result<git2::Reference<'_>, git::ext::Error> {
+
        todo!()
+
    }
}

impl WriteRepository for MockRepository {