From 354805aeb3f871358426753198275738ff76a47e Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 20 Apr 2026 09:12:54 +0200 Subject: [PATCH] cli/test: Fix failures related to remote HEAD Two tests assumed that `refs/remotes/rad/HEAD` would automatically be crated. It turns out, however, that this only the case if executed with Git 2.48.0 or newer. Git versions older than 2.48.0 do not touch 'refs/remotes//HEAD'. Git 2.48.0 and newer will update `refs/remotes//HEAD` by default. This can be disabled by setting `remote..followRemoteHEAD` to "never". Thus, with these versions, setting that configuration to "never" emulates the behaviour of older versions. Therefore, to ensure that test results are consistent across Git versions before and after 2.48.0, the fixture of test repositories now include setting 'remote.rad.followRemoteHEAD = never'. The affected tests are adjusted accordingly. This change can possibly be reverted once Radicle requires usage of Git 2.48.0 or newer. Co-authored-by: Lorenz Leutgeb --- crates/radicle-cli/examples/rad-patch-fetch-2.md | 1 - crates/radicle-cli/examples/rad-patch-via-push.md | 1 - crates/radicle/src/test/fixtures.rs | 11 +++++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/radicle-cli/examples/rad-patch-fetch-2.md b/crates/radicle-cli/examples/rad-patch-fetch-2.md index 4b260917..a9392665 100644 --- a/crates/radicle-cli/examples/rad-patch-fetch-2.md +++ b/crates/radicle-cli/examples/rad-patch-fetch-2.md @@ -22,7 +22,6 @@ $ 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-via-push.md b/crates/radicle-cli/examples/rad-patch-via-push.md index e00c5ada..73b16427 100644 --- a/crates/radicle-cli/examples/rad-patch-via-push.md +++ b/crates/radicle-cli/examples/rad-patch-via-push.md @@ -62,7 +62,6 @@ 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/src/test/fixtures.rs b/crates/radicle/src/test/fixtures.rs index b329d154..c9018705 100644 --- a/crates/radicle/src/test/fixtures.rs +++ b/crates/radicle/src/test/fixtures.rs @@ -122,6 +122,17 @@ fn repository_with>( let mut config = repo.config().unwrap(); config.set_str("user.name", USER_NAME).unwrap(); config.set_str("user.email", USER_EMAIL).unwrap(); + + // In Git 2.48.0, the option `remote..followRemoteHEAD` was added. + // Git versions older than 2.48.0 behave as if this option is set to + // `never`. + // We set it explicitly here for testing purposes, for consistent output + // of commands like `git branch -r` and `git show-ref`. + // Once Radicle requires Git 2.48.0 or newer, we can remove this + // (and adjust our tests to the new default behavior, creating `HEAD`). + config + .set_str("remote.rad.followRemoteHEAD", "never") + .unwrap(); } let sig = git::raw::Signature::new(