From 80daa7662397db338f92de6daad5519e16dd55f6 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Thu, 23 Apr 2026 00:59:42 +0200 Subject: [PATCH] fix git.branches: use pipe separator instead of null byte The null byte in the --format string didn't survive Process.run argument passing, so the output was unparseable and no branches were returned. Switched to pipe separator with lastIndexOf split to handle branch names containing pipes. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/src/git/operations.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/git/operations.dart b/lib/src/git/operations.dart index 9965285a..e36c4d4c 100644 --- a/lib/src/git/operations.dart +++ b/lib/src/git/operations.dart @@ -199,16 +199,18 @@ Future> gitBranches( Directory workDir) async { final r = await Process.run( 'git', - ['branch', '--format=%(refname:short)\x00%(HEAD)'], + ['branch', '--format=%(refname:short)|%(HEAD)'], workingDirectory: workDir.path, ); if (r.exitCode != 0) return const []; final out = <({String name, bool current})>[]; for (final line in (r.stdout as String).split('\n')) { if (line.trim().isEmpty) continue; - final parts = line.split('\x00'); - if (parts.length < 2) continue; - out.add((name: parts[0], current: parts[1].trim() == '*')); + final sep = line.lastIndexOf('|'); + if (sep < 0) continue; + final name = line.substring(0, sep); + final head = line.substring(sep + 1).trim(); + out.add((name: name, current: head == '*')); } return out; }