From 3f843303fa116a041a9dd1eb01691bd36c529d00 Mon Sep 17 00:00:00 2001 From: darshanime Date: Mon, 13 Jul 2026 13:32:03 +0530 Subject: [PATCH] use --not instead of listing refs --- dist/index.js | 23 ++++++++++++----------- src/warpbuild/mirror-cache.ts | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3bbc325..9d945ed 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41988,14 +41988,17 @@ async function uploadBranchDelta(settings) { info(`Branch delta upload skipped (${grant.kind})`); return; } - const excludes = await baseRefExcludes(repoPath); - if (excludes.length === 0) { + if (!(await hasBaseRefs(repoPath))) { info('No base refs to diff against; branch delta skipped'); return; } const tmp = tempBundlePath('branch'); try { await exec_exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha]); + // Exclude the base with a single --glob, not one `^ref` arg per ref: a large repo + // has hundreds of base refs, and that many args overflows the Windows command-line + // limit (ENAMETOOLONG). The glob matches the multi-level seeded refs and yields the + // same base-relative (order-free) delta. await exec_exec('git', [ '-C', repoPath, @@ -42003,7 +42006,8 @@ async function uploadBranchDelta(settings) { 'create', tmp, UPLOAD_TIP_REF, - ...excludes + '--not', + `--glob=${BASE_REFNS}/*` ]); await httpPut(grant.url, tmp); info(`Uploaded branch delta for '${plan.refKey}'`); @@ -42015,15 +42019,12 @@ async function uploadBranchDelta(settings) { }); } } -// `^refname` for every seeded base ref — the exclusion set that makes the delta bundle -// base-relative (and therefore order-free). -async function baseRefExcludes(repoPath) { +// Whether any base ref was seeded — the guard that keeps the delta base-relative. The +// base is excluded by glob (see uploadBranchDelta), so we only need existence here. +async function hasBaseRefs(repoPath) { let out = ''; - await exec_exec('git', ['-C', repoPath, 'for-each-ref', '--format=^%(refname)', BASE_REFNS], { silent: true, listeners: { stdout: (d) => (out += d.toString()) } }); - return out - .split('\n') - .map(s => s.trim()) - .filter(Boolean); + await exec_exec('git', ['-C', repoPath, 'for-each-ref', '--count=1', '--format=1', BASE_REFNS], { silent: true, listeners: { stdout: (d) => (out += d.toString()) } }); + return out.trim().length > 0; } async function downloadTo(url, dest) { const res = await fetch(url, { diff --git a/src/warpbuild/mirror-cache.ts b/src/warpbuild/mirror-cache.ts index 14ddefe..35b3938 100644 --- a/src/warpbuild/mirror-cache.ts +++ b/src/warpbuild/mirror-cache.ts @@ -254,8 +254,7 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise { return } - const excludes = await baseRefExcludes(repoPath) - if (excludes.length === 0) { + if (!(await hasBaseRefs(repoPath))) { core.info('No base refs to diff against; branch delta skipped') return } @@ -263,6 +262,10 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise { const tmp = tempBundlePath('branch') try { await exec.exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha]) + // Exclude the base with a single --glob, not one `^ref` arg per ref: a large repo + // has hundreds of base refs, and that many args overflows the Windows command-line + // limit (ENAMETOOLONG). The glob matches the multi-level seeded refs and yields the + // same base-relative (order-free) delta. await exec.exec('git', [ '-C', repoPath, @@ -270,7 +273,8 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise { 'create', tmp, UPLOAD_TIP_REF, - ...excludes + '--not', + `--glob=${BASE_REFNS}/*` ]) await httpPut(grant.url, tmp) core.info(`Uploaded branch delta for '${plan.refKey}'`) @@ -286,19 +290,16 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise { } } -// `^refname` for every seeded base ref — the exclusion set that makes the delta bundle -// base-relative (and therefore order-free). -async function baseRefExcludes(repoPath: string): Promise { +// Whether any base ref was seeded — the guard that keeps the delta base-relative. The +// base is excluded by glob (see uploadBranchDelta), so we only need existence here. +async function hasBaseRefs(repoPath: string): Promise { let out = '' await exec.exec( 'git', - ['-C', repoPath, 'for-each-ref', '--format=^%(refname)', BASE_REFNS], + ['-C', repoPath, 'for-each-ref', '--count=1', '--format=1', BASE_REFNS], {silent: true, listeners: {stdout: (d: Buffer) => (out += d.toString())}} ) - return out - .split('\n') - .map(s => s.trim()) - .filter(Boolean) + return out.trim().length > 0 } async function downloadTo(url: string, dest: string): Promise {