forge
Explore
Log in

Don't you dare go Hollow

Git clone --depth works: uploadpack.allowRefInWant is off, since with it the server sent wanted-refs before shallow-info and the client stopped with expected 'packfile', received 'shallow-info'

Browse files at this commit

6b26e8221dbb08ffdcc62aa0d6c963e235ad4b96Ahmet Kaan GümüşParent: 1e33617
  • fix
    • git clone --depth works: uploadpack.allowRefInWant is off, since with it the server sent wanted-refs before shallow-info and the client stopped with expected 'packfile', received 'shallow-info'
Show full message
🐛 fix: git clone --depth works: uploadpack.allowRefInWant is off, since with it the server sent wanted-refs before shallow-info and the client stopped with expected 'packfile', received 'shallow-info'
crates/forge-git/src/setup.rsmodified+2 -1
@@ -53,6 +53,8 @@ pub fn write_managed_gitconfig(data_dir: &Path) -> Result<()> {
53 let hooks = quote_config_value(hooks)?;53 let hooks = quote_config_value(hooks)?;
54 54
55 // `committed` hardens loose objects and packs; `reference` hardens ref updates.55 // `committed` hardens loose objects and packs; `reference` hardens ref updates.
56+ // `uploadpack.allowRefInWant` stays off: with it, upload-pack writes wanted-refs before
57+ // shallow-info, the client wants the reverse, and `git clone --depth` fails.
56 let body = format!(58 let body = format!(
57 "[core]\n\59 "[core]\n\
58 \thooksPath = {hooks}\n\60 \thooksPath = {hooks}\n\
@@ -71,7 +73,6 @@ pub fn write_managed_gitconfig(data_dir: &Path) -> Result<()> {
71 \twriteCommitGraph = true\n\73 \twriteCommitGraph = true\n\
72 [uploadpack]\n\74 [uploadpack]\n\
73 \tallowFilter = true\n\75 \tallowFilter = true\n\
74- \tallowRefInWant = true\n\
75 \thideRefs = refs/forge-internal/\n\76 \thideRefs = refs/forge-internal/\n\
76 [protocol \"file\"]\n\77 [protocol \"file\"]\n\
77 \tallow = never\n\78 \tallow = never\n\
crates/forge-web/tests/e2e/git_e2e.rsmodified+9 -0
@@ -269,6 +269,15 @@ async fn git_end_to_end() {
269 "anonymous clone of public repo",269 "anonymous clone of public repo",
270 );270 );
271 assert_eq!(read(pub_anon.join("hello.txt")), "hello over https\n");271 assert_eq!(read(pub_anon.join("hello.txt")), "hello over https\n");
272+ let pub_shallow = dir.join("pub-shallow");
273+ ok(
274+ &git(
275+ &dir,
276+ &["clone", "--depth", "1", &anon_url, path_str(&pub_shallow)],
277+ &[],
278+ ),
279+ "anonymous shallow clone",
280+ );
272 281
273 // SSH: push to the private repo with the registered key, then read it back.282 // SSH: push to the private repo with the registered key, then read it back.
274 let ssh_cmd = ssh_command(&key, ssh_port);283 let ssh_cmd = ssh_command(&key, ssh_port);
docs/architecture.mdmodified+2 -1
@@ -341,7 +341,8 @@ Written at boot by `write_managed_gitconfig()`. Keys:
341 - `core.hooksPath=<data_dir>/hooks`341 - `core.hooksPath=<data_dir>/hooks`
342 - `receive.fsckObjects=true`, `transfer.fsckObjects=true`342 - `receive.fsckObjects=true`, `transfer.fsckObjects=true`
343 - `core.fsync` and `core.fsyncMethod` set explicitly. The default `committed,-loose-object` risks losing recent work.343 - `core.fsync` and `core.fsyncMethod` set explicitly. The default `committed,-loose-object` risks losing recent work.
344-- `uploadpack.allowFilter=true`, `uploadpack.allowRefInWant=true`344+- `uploadpack.allowFilter=true`
345+- `uploadpack.allowRefInWant` stays unset. With it, upload-pack sends `wanted-refs` before `shallow-info`, the client expects the reverse, and `git clone --depth` fails.
345 - `receive.advertisePushOptions=true`346 - `receive.advertisePushOptions=true`
346 - `protocol.file.allow=user`347 - `protocol.file.allow=user`
347 - Later: `uploadpack.hideRefs` and `transfer.hideRefs` for internal refs (`refs/pull/*` as needed)348 - Later: `uploadpack.hideRefs` and `transfer.hideRefs` for internal refs (`refs/pull/*` as needed)