remote-helper: List `HEAD`

Report the default branch correctly via the symbolic reference `HEAD`.
This commit is contained in:
Lorenz Leutgeb 2025-09-13 22:12:32 +02:00
parent 101fbff809
commit ef27961866
No known key found for this signature in database
9 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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
```

View File

@ -54,6 +54,7 @@ List the canonical refs:
```
$ git ls-remote rad
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 HEAD
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 refs/heads/master
```

View File

@ -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':

View File

@ -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':

View File

@ -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
```

View File

@ -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
```

View File

@ -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
```

View File

@ -46,8 +46,15 @@ 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.
// 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<R: ReadRepository + cob::Store<Namespace = NodeId> + '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}");
}