pub fn parse_porcelain(text: &str) -> Vec<WorktreeRecord>Expand description
Parse porcelain records from attribute lines. The separator is the caller’s: \n for
--porcelain, \0 for --porcelain -z. A blank attribute ends a record.
Unknown attributes are ignored rather than refused: git adds them over time, and a new attribute is not a reason to stop answering questions about the ones that exist.
use majordomus_cli::worktree::parse_porcelain;
let text = "worktree /a/foo\nHEAD abc\nbranch refs/heads/main\n\n\
worktree /a/foo-wt/x\nHEAD def\ndetached\nlocked in use\n\n";
let r = parse_porcelain(text);
assert_eq!(r.len(), 2);
assert_eq!(r[0].branch.as_deref(), Some("main"));
assert!(r[1].detached);
assert_eq!(r[1].locked.as_deref(), Some("in use"));