mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 16:25:30 +00:00
Merge reviewed PR #3584: preserve exact lifecycle worktree paths
This commit is contained in:
3 files changed
+76
-11
No files matched your search
@@ -60,23 +60,23 @@ function createGitRunner(repoRoot, runImpl = defaultRunImpl) {
|
||||
return succeeds(['show-ref', '--verify', '--quiet', `refs/heads/${branch}`]);
|
||||
},
|
||||
|
||||
// Porcelain worktree list -> [{ path, branch, head, detached, bare }]
|
||||
// Git 2.36+ NUL-delimited porcelain preserves whitespace within paths.
|
||||
listWorktrees() {
|
||||
const result = run(['worktree', 'list', '--porcelain']);
|
||||
const result = run(['worktree', 'list', '--porcelain', '-z']);
|
||||
if (result.status !== 0) {
|
||||
return [];
|
||||
const reason = (result.stderr || '').trim() || `git exited with status ${result.status}`;
|
||||
throw new Error(`Unable to list worktrees safely (Git 2.36+ required): ${reason}`);
|
||||
}
|
||||
|
||||
const worktrees = [];
|
||||
let current = null;
|
||||
|
||||
for (const rawLine of (result.stdout || '').split('\n')) {
|
||||
const line = rawLine.trim();
|
||||
for (const line of (result.stdout || '').split('\0')) {
|
||||
if (line.startsWith('worktree ')) {
|
||||
if (current) {
|
||||
worktrees.push(current);
|
||||
}
|
||||
current = { path: line.slice('worktree '.length).trim(), branch: null, head: null, detached: false, bare: false };
|
||||
current = { path: line.slice('worktree '.length), branch: null, head: null, detached: false, bare: false };
|
||||
} else if (current && line.startsWith('branch ')) {
|
||||
current.branch = line.slice('branch '.length).replace(/^refs\/heads\//, '').trim();
|
||||
} else if (current && line.startsWith('HEAD ')) {
|
||||
|
||||
@@ -55,6 +55,8 @@ function usage() {
|
||||
'conflicts without touching the working tree (git merge-tree) and proposes',
|
||||
'a safe cleanup plan that never removes dirty or unmerged worktrees.',
|
||||
'',
|
||||
'Requires Git 2.36+ for NUL-delimited worktree paths.',
|
||||
'',
|
||||
'Options:',
|
||||
' --json Print the full ecc.worktree-lifecycle.v1 report as JSON',
|
||||
' --conflicts Only show worktrees that would conflict on merge',
|
||||
|
||||
Reference in new issue
Block a user