refactor: simplify pass (trekexecute)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-26 20:39:40 +01:00
commit 52c382c198
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
8 changed files with 45 additions and 52 deletions

View file

@ -98,8 +98,10 @@ function headIsUnborn(root) {
if (sym.error || sym.status !== 0) return false;
const ref = String(sym.stdout ?? '').trim();
if (!/^refs\/heads\/./.test(ref)) return false;
if (lexists(resolve(root, git(root, ['rev-parse', '--git-path', ref]).trim()))) return false;
const packed = resolve(root, git(root, ['rev-parse', '--git-path', 'packed-refs']).trim());
// One call, one output line per --git-path, in argument order.
const [loosePath = '', packedPath = ''] = git(root, ['rev-parse', '--git-path', ref, '--git-path', 'packed-refs']).split('\n');
if (lexists(resolve(root, loosePath.trim()))) return false;
const packed = resolve(root, packedPath.trim());
if (lexists(packed)) {
const lines = readFileSync(packed, 'utf8').split('\n');
if (lines.some((l) => l.endsWith(` ${ref}`))) return false;