diff --git a/CHANGELOG.md b/CHANGELOG.md index b14d148f..76fa87b2 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/crates/radicle-cli/examples/git/git-push-converge.md b/crates/radicle-cli/examples/git/git-push-converge.md index 0696c280..49e33711 100644 --- a/crates/radicle-cli/examples/git/git-push-converge.md +++ b/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 ``` diff --git a/crates/radicle-cli/examples/git/git-push.md b/crates/radicle-cli/examples/git/git-push.md index 9b29e55c..2c24faaf 100644 --- a/crates/radicle-cli/examples/git/git-push.md +++ b/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 ``` diff --git a/crates/radicle-cli/examples/rad-init-existing-bare.md b/crates/radicle-cli/examples/rad-init-existing-bare.md index ba2107ab..ea727896 100644 --- a/crates/radicle-cli/examples/rad-init-existing-bare.md +++ b/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': diff --git a/crates/radicle-cli/examples/rad-init-existing.md b/crates/radicle-cli/examples/rad-init-existing.md index aa326c1f..db77e809 100644 --- a/crates/radicle-cli/examples/rad-init-existing.md +++ b/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': diff --git a/crates/radicle-cli/examples/rad-patch-fetch-2.md b/crates/radicle-cli/examples/rad-patch-fetch-2.md index a9392665..4b260917 100644 --- a/crates/radicle-cli/examples/rad-patch-fetch-2.md +++ b/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 ``` diff --git a/crates/radicle-cli/examples/rad-patch-pull-update.md b/crates/radicle-cli/examples/rad-patch-pull-update.md index 294bbdbc..ce22fe60 100644 --- a/crates/radicle-cli/examples/rad-patch-pull-update.md +++ b/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 ``` diff --git a/crates/radicle-cli/examples/rad-patch-via-push.md b/crates/radicle-cli/examples/rad-patch-via-push.md index b21a8cc4..279ea93a 100644 --- a/crates/radicle-cli/examples/rad-patch-via-push.md +++ b/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 ``` diff --git a/crates/radicle-remote-helper/src/list.rs b/crates/radicle-remote-helper/src/list.rs index fef535d1..4d435a26 100644 --- a/crates/radicle-remote-helper/src/list.rs +++ b/crates/radicle-remote-helper/src/list.rs @@ -46,8 +46,15 @@ pub fn for_fetch + '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. + // List the symbolic reference `HEAD`, which is interpreted by + // Git clients to determine the default branch. + match stored.head() { + Ok((target, _)) => println!("@{target} HEAD"), + Err(err) => eprintln!("remote: error resolving HEAD: {err}"), + } + + // 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/*"), @@ -56,8 +63,10 @@ pub fn for_fetch + 'static>( 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. + + // 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}"); }