From 6b26e8221dbb08ffdcc62aa0d6c963e235ad4b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 1 Nov 2026 08:25:29 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20git=20clone=20--depth=20w?= =?UTF-8?q?orks:=20uploadpack.allowRefInWant=20is=20off,=20since=20with=20?= =?UTF-8?q?it=20the=20server=20sent=20wanted-refs=20before=20shallow-info?= =?UTF-8?q?=20and=20the=20client=20stopped=20with=20expected=20'packfile',?= =?UTF-8?q?=20received=20'shallow-info'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-git/src/setup.rs | 3 ++- crates/forge-web/tests/e2e/git_e2e.rs | 9 +++++++++ docs/architecture.md | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/forge-git/src/setup.rs b/crates/forge-git/src/setup.rs index bdb9b85..c75aa8e 100644 --- a/crates/forge-git/src/setup.rs +++ b/crates/forge-git/src/setup.rs @@ -53,6 +53,8 @@ pub fn write_managed_gitconfig(data_dir: &Path) -> Result<()> { let hooks = quote_config_value(hooks)?; // `committed` hardens loose objects and packs; `reference` hardens ref updates. + // `uploadpack.allowRefInWant` stays off: with it, upload-pack writes wanted-refs before + // shallow-info, the client wants the reverse, and `git clone --depth` fails. let body = format!( "[core]\n\ \thooksPath = {hooks}\n\ @@ -71,7 +73,6 @@ pub fn write_managed_gitconfig(data_dir: &Path) -> Result<()> { \twriteCommitGraph = true\n\ [uploadpack]\n\ \tallowFilter = true\n\ - \tallowRefInWant = true\n\ \thideRefs = refs/forge-internal/\n\ [protocol \"file\"]\n\ \tallow = never\n\ diff --git a/crates/forge-web/tests/e2e/git_e2e.rs b/crates/forge-web/tests/e2e/git_e2e.rs index 20d436f..dcfba68 100644 --- a/crates/forge-web/tests/e2e/git_e2e.rs +++ b/crates/forge-web/tests/e2e/git_e2e.rs @@ -269,6 +269,15 @@ async fn git_end_to_end() { "anonymous clone of public repo", ); assert_eq!(read(pub_anon.join("hello.txt")), "hello over https\n"); + let pub_shallow = dir.join("pub-shallow"); + ok( + &git( + &dir, + &["clone", "--depth", "1", &anon_url, path_str(&pub_shallow)], + &[], + ), + "anonymous shallow clone", + ); // SSH: push to the private repo with the registered key, then read it back. let ssh_cmd = ssh_command(&key, ssh_port); diff --git a/docs/architecture.md b/docs/architecture.md index 8b8078b..4e20854 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -341,7 +341,8 @@ Written at boot by `write_managed_gitconfig()`. Keys: - `core.hooksPath=/hooks` - `receive.fsckObjects=true`, `transfer.fsckObjects=true` - `core.fsync` and `core.fsyncMethod` set explicitly. The default `committed,-loose-object` risks losing recent work. -- `uploadpack.allowFilter=true`, `uploadpack.allowRefInWant=true` +- `uploadpack.allowFilter=true` +- `uploadpack.allowRefInWant` stays unset. With it, upload-pack sends `wanted-refs` before `shallow-info`, the client expects the reverse, and `git clone --depth` fails. - `receive.advertisePushOptions=true` - `protocol.file.allow=user` - Later: `uploadpack.hideRefs` and `transfer.hideRefs` for internal refs (`refs/pull/*` as needed)