Skip to content

Commit d27e318

Browse files
authored
improve: make git installs use a blobless clone (#123835)
* perf: use blobless clone in git installer * refactor(install): move clone-filter rationale above the call Keep the file's comment convention (comments on their own lines) instead of a 150-column trailing comment, and record why blob:none is preferred over --depth 1 plus why no fallback is needed. Narrow the ordering test's source needle to the stable prefix so it stops duplicating the behavioral flag assertion and no longer breaks whenever the clone flags change.
1 parent e7255b9 commit d27e318

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

‎scripts/install.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,11 @@ install_openclaw_from_git() {
28742874
validate_git_checkout_head "$repo_dir" || return 1
28752875
if [[ ! -d "$repo_dir" ]]; then
28762876
mkdir -p "$(dirname "$repo_dir")"
2877-
run_quiet_step "Cloning OpenClaw" git clone "$repo_url" "$repo_dir"
2877+
# Blobless clone: the installer checks out one release tag, so full blob
2878+
# history is downloaded and then discarded. blob:none keeps ref metadata
2879+
# (unlike --depth 1) so ref switching and later updates still work, and
2880+
# git warns and falls back to a full clone if the server cannot filter.
2881+
run_quiet_step "Cloning OpenClaw" git clone --filter=blob:none "$repo_url" "$repo_dir"
28782882
fi
28792883

28802884
local git_ref

‎test/scripts/install-sh.test.ts‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,14 +1017,47 @@ NODE
10171017
const output = result?.stdout ?? "";
10181018
expect(output).toContain(`git=${join(openclawHome, "openclaw")}`);
10191019
const mkdirParentIndex = script.indexOf('mkdir -p "$(dirname "$repo_dir")"');
1020-
const cloneIndex = script.indexOf(
1021-
'run_quiet_step "Cloning OpenClaw" git clone "$repo_url" "$repo_dir"',
1022-
);
1020+
// Ordering only. The clone flags are asserted behaviorally below, so this
1021+
// needle stays short enough to survive future changes to them.
1022+
const cloneIndex = script.indexOf('run_quiet_step "Cloning OpenClaw" git clone');
10231023
expect(mkdirParentIndex).toBeGreaterThan(-1);
10241024
expect(cloneIndex).toBeGreaterThan(-1);
10251025
expect(mkdirParentIndex).toBeLessThan(cloneIndex);
10261026
});
10271027

1028+
it("uses a blobless partial clone for new git installs", () => {
1029+
const result = runInstallShell(`
1030+
set -euo pipefail
1031+
source "${SCRIPT_PATH}"
1032+
repo="$HOME/openclaw"
1033+
check_git() { return 0; }
1034+
ensure_pnpm() { :; }
1035+
ensure_pnpm_binary_for_scripts() { :; }
1036+
resolve_git_openclaw_ref() { printf 'main\\n'; }
1037+
checkout_git_openclaw_ref() { :; }
1038+
cleanup_legacy_submodules() { :; }
1039+
activate_repo_pnpm_version() { :; }
1040+
git_install_lockfile_flag() { printf '%s\\n' '--frozen-lockfile'; }
1041+
run_quiet_step() {
1042+
printf 'step:%s|%s\\n' "$1" "\${*:2}"
1043+
[[ "$1" == "Cloning OpenClaw" ]] && mkdir -p "$repo"
1044+
return 0
1045+
}
1046+
ensure_user_local_bin_on_path() { mkdir -p "$HOME/.local/bin"; }
1047+
ui_info() { :; }
1048+
ui_success() { :; }
1049+
ui_error() { printf 'error:%s\\n' "$*"; }
1050+
git() { return 0; }
1051+
1052+
install_openclaw_from_git "$repo"
1053+
`);
1054+
1055+
expect(result.status).toBe(0);
1056+
expect(result.stdout).toContain(
1057+
"step:Cloning OpenClaw|git clone --filter=blob:none https://github.com/openclaw/openclaw.git",
1058+
);
1059+
});
1060+
10281061
it("does not treat OS HOME config as active when OPENCLAW_HOME is set", () => {
10291062
const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-legacy-config-"));
10301063
const osHome = join(tmp, "os-home");

0 commit comments

Comments
 (0)