Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Feat: Add `--branches` flag to `list` command
Maximilian Roosd5b273dd7b61
diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rsindex 30cb79819..0bd893452 100644--- a/src/commands/list/layout.rs+++ b/src/commands/list/layout.rs@@ -2,7 +2,7 @@ use crate::display::{find_common_prefix, get_terminal_width};use std::path::{Path, PathBuf};use unicode_width::UnicodeWidthStr;-use super::WorktreeInfo;+use super::ListItem;/// Helper: Check if a column is "dense" (appears in >50% of all rows)fn is_dense_for_all_rows(count: usize, total: usize) -> bool {@@ -42,7 +42,7 @@ pub struct LayoutConfig {pub max_message_len: usize,}-pub fn calculate_column_widths(infos: &[WorktreeInfo]) -> ColumnWidths {+pub fn calculate_column_widths(items: &[ListItem]) -> ColumnWidths {// Initialize with header label widths to ensure headers always fitlet mut max_branch = "Branch".width();let mut max_time = "Age".width();@@ -53,40 +53,35 @@ pub fn calculate_column_widths(infos: &[WorktreeInfo]) -> ColumnWidths {let mut max_upstream = "Remote".width();let mut max_states = "State".width();- for info in infos {+ for item in items {// Branch name- let branch_len = info- .worktree- .branch- .as_deref()- .unwrap_or("(detached)")- .width();- max_branch = max_branch.max(branch_len);+ max_branch = max_branch.max(item.branch_name().width());// Time- let time_str = crate::display::format_relative_time(info.timestamp);+ let time_str = crate::display::format_relative_time(item.timestamp());max_time = max_time.max(time_str.width());// Message (truncate to 50 chars max)- let msg_len = info.commit_message.chars().take(50).count();+ let msg_len = item.commit_message().chars().take(50).count();max_message = max_message.max(msg_len);- // Ahead/behind- if !info.is_primary && (info.ahead > 0 || info.behind > 0) {- let ahead_behind_len = format!("↑{} ↓{}", info.ahead, info.behind).width();+ // Ahead/behind (only for non-primary items)+ if !item.is_primary() && (item.ahead() > 0 || item.behind() > 0) {+ let ahead_behind_len = format!("↑{} ↓{}", item.ahead(), item.behind()).width();max_ahead_behind = max_ahead_behind.max(ahead_behind_len);}- // Working tree diff- let (wt_added, wt_deleted) = info.working_tree_diff;- if wt_added > 0 || wt_deleted > 0 {+ // Working tree diff (worktrees only)+ if let Some((wt_added, wt_deleted)) = item.working_tree_diff()+ && (wt_added > 0 || wt_deleted > 0)+ {let working_diff_len = format!("+{} -{}", wt_added, wt_deleted).width();max_working_diff = max_working_diff.max(working_diff_len);}- // Branch diff- if !info.is_primary {- let (br_added, br_deleted) = info.branch_diff;+ // Branch diff (only for non-primary items)+ if !item.is_primary() {+ let (br_added, br_deleted) = item.branch_diff();if br_added > 0 || br_deleted > 0 {let branch_diff_len = format!("+{} -{}", br_added, br_deleted).width();max_branch_diff = max_branch_diff.max(branch_diff_len);@@ -94,20 +89,18 @@ pub fn calculate_column_widths(infos: &[WorktreeInfo]) -> ColumnWidths {}// Upstream tracking- if info.upstream_ahead > 0 || info.upstream_behind > 0 {- let remote_name = info.upstream_remote.as_deref().unwrap_or("origin");- let upstream_len = format!(- "{} ↑{} ↓{}",- remote_name, info.upstream_ahead, info.upstream_behind- )- .width();+ if let Some((remote_name, upstream_ahead, upstream_behind)) = item.upstream_info() {+ let upstream_len =+ format!("{} ↑{} ↓{}", remote_name, upstream_ahead, upstream_behind).width();max_upstream = max_upstream.max(upstream_len);}- // States (including worktree_state)- let states = super::render::format_all_states(info);- if !states.is_empty() {- max_states = max_states.max(states.width());+ // States (worktrees only)+ if let Some(worktree_info) = item.worktree_info() {+ let states = super::render::format_all_states(worktree_info);+ if !states.is_empty() {+ max_states = max_states.max(states.width());+ }}}@@ -124,49 +117,56 @@ pub fn calculate_column_widths(infos: &[WorktreeInfo]) -> ColumnWidths {}/// Calculate responsive layout based on terminal width-pub fn calculate_responsive_layout(infos: &[WorktreeInfo]) -> LayoutConfig {+pub fn calculate_responsive_layout(items: &[ListItem]) -> LayoutConfig {let terminal_width = get_terminal_width();- let paths: Vec<&Path> = infos+ let paths: Vec<&Path> = items.iter()- .map(|info| info.worktree.path.as_path())+ .filter_map(|item| {+ item.worktree_info()+ .map(|info| info.worktree.path.as_path())+ }).collect();let common_prefix = find_common_prefix(&paths);// Count how many rows have each sparse column- let non_primary_count = infos.iter().filter(|i| !i.is_primary).count();- let ahead_behind_count = infos+ let non_primary_count = items.iter().filter(|item| !item.is_primary()).count();+ let ahead_behind_count = items.iter()- .filter(|i| !i.is_primary && (i.ahead > 0 || i.behind > 0))+ .filter(|item| !item.is_primary() && (item.ahead() > 0 || item.behind() > 0)).count();- let working_diff_count = infos+ let working_diff_count = items.iter()- .filter(|i| {- let (added, deleted) = i.working_tree_diff;- added > 0 || deleted > 0+ .filter(|item| {+ item.working_tree_diff()+ .map(|(added, deleted)| added > 0 || deleted > 0)+ .unwrap_or(false)}).count();- let branch_diff_count = infos+ let branch_diff_count = items.iter()- .filter(|i| {- if i.is_primary {- return false;+ .filter(|item| {+ !item.is_primary() && {+ let (added, deleted) = item.branch_diff();+ added > 0 || deleted > 0}- let (added, deleted) = i.branch_diff;- added > 0 || deleted > 0}).count();- let upstream_count = infos+ let upstream_count = items.iter()- .filter(|i| i.upstream_ahead > 0 || i.upstream_behind > 0)+ .filter(|item| item.upstream_info().is_some()).count();- let states_count = infos+ let states_count = items.iter()- .filter(|i| {- i.worktree_state.is_some()- || (i.worktree.detached && i.worktree.branch.is_some())- || i.worktree.bare- || i.worktree.locked.is_some()- || i.worktree.prunable.is_some()+ .filter(|item| {+ item.worktree_info()+ .map(|i| {+ i.worktree_state.is_some()+ || (i.worktree.detached && i.worktree.branch.is_some())+ || i.worktree.bare+ || i.worktree.locked.is_some()+ || i.worktree.prunable.is_some()+ })+ .unwrap_or(false)}).count();@@ -174,13 +174,13 @@ pub fn calculate_responsive_layout(infos: &[WorktreeInfo]) -> LayoutConfig {// For ahead/behind and branch_diff, applicable = non-primary rows// For others, applicable = all rowslet ahead_behind_is_dense = is_dense_for_non_primary(ahead_behind_count, non_primary_count);- let working_diff_is_dense = is_dense_for_all_rows(working_diff_count, infos.len());+ let working_diff_is_dense = is_dense_for_all_rows(working_diff_count, items.len());let branch_diff_is_dense = is_dense_for_non_primary(branch_diff_count, non_primary_count);- let upstream_is_dense = is_dense_for_all_rows(upstream_count, infos.len());- let states_is_dense = is_dense_for_all_rows(states_count, infos.len());+ let upstream_is_dense = is_dense_for_all_rows(upstream_count, items.len());+ let states_is_dense = is_dense_for_all_rows(states_count, items.len());// Calculate ideal column widths- let ideal_widths = calculate_column_widths(infos);+ let ideal_widths = calculate_column_widths(items);// Essential columns (always shown):// - current indicator: 2 chars@@ -310,7 +310,7 @@ mod tests {worktree_state: None,};- let widths = calculate_column_widths(&[info1]);+ let widths = calculate_column_widths(&[super::ListItem::Worktree(info1)]);// "↑3 ↓2" has visual width 5 (not 9 bytes)assert_eq!(widths.ahead_behind, 5, "↑3 ↓2 should have width 5");diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rsindex 48c6e1810..1ccb85f3d 100644--- a/src/commands/list/mod.rs+++ b/src/commands/list/mod.rs@@ -8,7 +8,7 @@ use rayon::prelude::*;use worktrunk::git::{GitError, Repository};use layout::calculate_responsive_layout;-use render::{format_header_line, format_worktree_line};+use render::{format_header_line, format_list_item_line};#[derive(serde::Serialize)]pub struct WorktreeInfo {@@ -26,6 +26,187 @@ pub struct WorktreeInfo {pub worktree_state: Option<String>,}+#[derive(serde::Serialize)]+pub struct BranchInfo {+ pub name: String,+ pub head: String,+ pub timestamp: i64,+ pub commit_message: String,+ pub ahead: usize,+ pub behind: usize,+ pub branch_diff: (usize, usize),+ pub upstream_remote: Option<String>,+ pub upstream_ahead: usize,+ pub upstream_behind: usize,+}++/// Unified type for displaying worktrees and branches in the same table+#[derive(serde::Serialize)]+#[serde(tag = "type", rename_all = "lowercase")]+pub enum ListItem {+ Worktree(WorktreeInfo),+ Branch(BranchInfo),+}++impl ListItem {+ pub fn timestamp(&self) -> i64 {+ match self {+ ListItem::Worktree(wt) => wt.timestamp,+ ListItem::Branch(br) => br.timestamp,+ }+ }++ pub fn worktree_info(&self) -> Option<&WorktreeInfo> {+ match self {+ ListItem::Worktree(wt) => Some(wt),+ ListItem::Branch(_) => None,+ }+ }++ pub fn branch_name(&self) -> &str {+ match self {+ ListItem::Worktree(wt) => wt.worktree.branch.as_deref().unwrap_or("(detached)"),+ ListItem::Branch(br) => &br.name,+ }+ }++ pub fn commit_head(&self) -> &str {+ match self {+ ListItem::Worktree(wt) => &wt.worktree.head,+ ListItem::Branch(br) => &br.head,+ }+ }++ pub fn commit_message(&self) -> &str {+ match self {+ ListItem::Worktree(wt) => &wt.commit_message,+ ListItem::Branch(br) => &br.commit_message,+ }+ }++ pub fn ahead(&self) -> usize {+ match self {+ ListItem::Worktree(wt) => wt.ahead,+ ListItem::Branch(br) => br.ahead,+ }+ }++ pub fn behind(&self) -> usize {+ match self {+ ListItem::Worktree(wt) => wt.behind,+ ListItem::Branch(br) => br.behind,+ }+ }++ pub fn is_primary(&self) -> bool {+ match self {+ ListItem::Worktree(wt) => wt.is_primary,+ ListItem::Branch(_) => false,+ }+ }++ pub fn branch_diff(&self) -> (usize, usize) {+ match self {+ ListItem::Worktree(wt) => wt.branch_diff,+ ListItem::Branch(br) => br.branch_diff,+ }+ }++ pub fn working_tree_diff(&self) -> Option<(usize, usize)> {+ match self {+ ListItem::Worktree(wt) => Some(wt.working_tree_diff),+ ListItem::Branch(_) => None,+ }+ }++ pub fn upstream_info(&self) -> Option<(&str, usize, usize)> {+ match self {+ ListItem::Worktree(wt) => {+ if wt.upstream_ahead > 0 || wt.upstream_behind > 0 {+ Some((+ wt.upstream_remote.as_deref().unwrap_or("origin"),+ wt.upstream_ahead,+ wt.upstream_behind,+ ))+ } else {+ None+ }+ }+ ListItem::Branch(br) => {+ if br.upstream_ahead > 0 || br.upstream_behind > 0 {+ Some((+ br.upstream_remote.as_deref().unwrap_or("origin"),+ br.upstream_ahead,+ br.upstream_behind,+ ))+ } else {+ None+ }+ }+ }+ }+}++impl BranchInfo {+ /// Create BranchInfo from a branch name, enriching it with git metadata+ fn from_branch(+ branch: &str,+ repo: &Repository,+ primary_branch: Option<&str>,+ ) -> Result<Self, GitError> {+ // Get the commit SHA for this branch+ let head = repo.run_command(&["rev-parse", branch])?.trim().to_string();++ // Get commit timestamp+ let timestamp = repo.commit_timestamp(&head)?;++ // Get commit message+ let commit_message = repo.commit_message(&head)?;++ // Calculate ahead/behind relative to primary branch+ let (ahead, behind) = if let Some(pb) = primary_branch {+ repo.ahead_behind(pb, &head)?+ } else {+ (0, 0)+ };++ // Get branch diff stats (line diff relative to primary)+ let branch_diff = if let Some(pb) = primary_branch {+ repo.branch_diff_stats(pb, &head)?+ } else {+ (0, 0)+ };++ // Get upstream tracking info+ let (upstream_remote, upstream_ahead, upstream_behind) =+ match repo.upstream_branch(branch).ok().flatten() {+ Some(upstream_branch) => {+ let remote = upstream_branch+ .split_once('/')+ .map(|(remote, _)| remote)+ .unwrap_or("origin")+ .to_string();+ let (ahead, behind) = repo.ahead_behind(&upstream_branch, &head)?;+ (Some(remote), ahead, behind)+ }+ None => (None, 0, 0),+ };++ Ok(BranchInfo {+ name: branch.to_string(),+ head,+ timestamp,+ commit_message,+ ahead,+ behind,+ branch_diff,+ upstream_remote,+ upstream_ahead,+ upstream_behind,+ })+ }+}+impl WorktreeInfo {/// Create WorktreeInfo from a Worktree, enriching it with git metadatafn from_worktree(@@ -99,7 +280,7 @@ impl WorktreeInfo {}}-pub fn handle_list(format: crate::OutputFormat) -> Result<(), GitError> {+pub fn handle_list(format: crate::OutputFormat, show_branches: bool) -> Result<(), GitError> {let repo = Repository::current();let worktrees = repo.list_worktrees()?;@@ -125,41 +306,47 @@ pub fn handle_list(format: crate::OutputFormat) -> Result<(), GitError> {//// TODO: Could parallelize the 5 git commands within each worktree if needed,// but worktree-level parallelism provides the best cost/benefit tradeoff- let mut infos: Vec<WorktreeInfo> = if std::env::var("WT_SEQUENTIAL").is_ok() {- // Sequential iteration (for benchmarking)- worktrees- .iter()- .map(|wt| WorktreeInfo::from_worktree(wt, &primary))- .collect::<Result<Vec<_>, _>>()?- } else {- // Parallel iteration (default)- worktrees- .par_iter()- .map(|wt| WorktreeInfo::from_worktree(wt, &primary))- .collect::<Result<Vec<_>, _>>()?- };+ let worktree_infos: Vec<WorktreeInfo> = worktrees+ .par_iter()+ .map(|wt| WorktreeInfo::from_worktree(wt, &primary))+ .collect::<Result<Vec<_>, _>>()?;++ // Build list of items to display (worktrees + optional branches)+ let mut items: Vec<ListItem> = worktree_infos.into_iter().map(ListItem::Worktree).collect();++ // Add branches if requested+ if show_branches {+ let available_branches = repo.available_branches()?;+ let primary_branch = primary.branch.as_deref();+ for branch in available_branches {+ match BranchInfo::from_branch(&branch, &repo, primary_branch) {+ Ok(branch_info) => items.push(ListItem::Branch(branch_info)),+ Err(e) => eprintln!("Warning: Failed to enrich branch '{}': {}", branch, e),+ }+ }+ }// Sort by most recent commit (descending)- infos.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));+ items.sort_by_key(|b| std::cmp::Reverse(b.timestamp()));match format {crate::OutputFormat::Json => {// Output JSON format- let json = serde_json::to_string_pretty(&infos).map_err(|e| {+ let json = serde_json::to_string_pretty(&items).map_err(|e| {GitError::CommandFailed(format!("Failed to serialize to JSON: {}", e))})?;println!("{}", json);}crate::OutputFormat::Table => {// Calculate responsive layout based on terminal width- let layout = calculate_responsive_layout(&infos);+ let layout = calculate_responsive_layout(&items);// Display headerformat_header_line(&layout);// Display formatted output- for info in &infos {- format_worktree_line(info, &layout, current_worktree_path.as_ref());+ for item in &items {+ format_list_item_line(item, &layout, current_worktree_path.as_ref());}}}diff --git a/src/commands/list/render.rs b/src/commands/list/render.rsindex a209ca929..8ae1498ea 100644--- a/src/commands/list/render.rs+++ b/src/commands/list/render.rs@@ -4,8 +4,8 @@ use worktrunk::styling::{primary_style,};-use super::WorktreeInfo;use super::layout::LayoutConfig;+use super::{ListItem, WorktreeInfo};pub fn format_all_states(info: &WorktreeInfo) -> String {let mut states = Vec::new();@@ -121,8 +121,17 @@ pub fn format_header_line(layout: &LayoutConfig) {println!("{}", line.render());}-pub fn format_worktree_line(- info: &WorktreeInfo,+/// Render a list item (worktree or branch) as a formatted line+pub fn format_list_item_line(+ item: &ListItem,+ layout: &LayoutConfig,+ current_worktree_path: Option<&std::path::PathBuf>,+) {+ format_item_line(item, layout, current_worktree_path)+}++fn format_item_line(+ item: &ListItem,layout: &LayoutConfig,current_worktree_path: Option<&std::path::PathBuf>,) {@@ -134,24 +143,25 @@ pub fn format_worktree_line(let yellow = neutral_style();let dim = dim_style();- let branch_display = info.worktree.branch.as_deref().unwrap_or("(detached)");- let short_head = &info.worktree.head[..8.min(info.worktree.head.len())];-- // Determine styles: current worktree is bold magenta, primary is cyan- let is_current = current_worktree_path- .map(|p| p == &info.worktree.path)- .unwrap_or(false);- let text_style = match (is_current, info.is_primary) {- (true, _) => Some(current),- (_, true) => Some(primary),- _ => None,- };+ let short_head = &item.commit_head()[..8.min(item.commit_head().len())];++ // Determine styling (worktree-specific)+ let text_style = item.worktree_info().and_then(|info| {+ let is_current = current_worktree_path+ .map(|p| p == &info.worktree.path)+ .unwrap_or(false);+ match (is_current, item.is_primary()) {+ (true, _) => Some(current),+ (_, true) => Some(primary),+ _ => None,+ }+ });// Start building the linelet mut line = StyledLine::new();// Branch name- let branch_text = format!("{:width$}", branch_display, width = widths.branch);+ let branch_text = format!("{:width$}", item.branch_name(), width = widths.branch);if let Some(style) = text_style {line.push_styled(branch_text, style);} else {@@ -163,137 +173,133 @@ pub fn format_worktree_line(if widths.time > 0 {let time_str = format!("{:width$}",- format_relative_time(info.timestamp),+ format_relative_time(item.timestamp()),width = widths.time);line.push_styled(time_str, dim);line.push_raw(" ");}- // Ahead/behind (commits difference) - always reserve space if ANY row uses it+ // Ahead/behind (commits difference)if layout.ideal_widths.ahead_behind > 0 {- if !info.is_primary && (info.ahead > 0 || info.behind > 0) {+ if !item.is_primary() && (item.ahead() > 0 || item.behind() > 0) {let ahead_behind_text = format!("{:width$}",- format!("↑{} ↓{}", info.ahead, info.behind),+ format!("↑{} ↓{}", item.ahead(), item.behind()),width = layout.ideal_widths.ahead_behind);line.push_styled(ahead_behind_text, yellow);} else {- // No data for this row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.ahead_behind));}line.push_raw(" ");}- // Branch diff (line diff in commits) - always reserve space if ANY row uses it+ // Branch diff (line diff in commits)if layout.ideal_widths.branch_diff > 0 {- if !info.is_primary {- let (br_added, br_deleted) = info.branch_diff;+ if !item.is_primary() {+ let (br_added, br_deleted) = item.branch_diff();if br_added > 0 || br_deleted > 0 {- // Build the diff as a mini styled linelet mut diff_segment = StyledLine::new();diff_segment.push_styled(format!("+{}", br_added), green);diff_segment.push_raw(" ");diff_segment.push_styled(format!("-{}", br_deleted), red);diff_segment.pad_to(layout.ideal_widths.branch_diff);- // Append all segments from diff_segment to main linefor segment in diff_segment.segments {line.push(segment);}} else {- // No data for this row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.branch_diff));}} else {- // Primary row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.branch_diff));}line.push_raw(" ");}- // Working tree diff (line diff in working tree) - always reserve space if ANY row uses it+ // Working tree diff (worktrees only)if layout.ideal_widths.working_diff > 0 {- let (wt_added, wt_deleted) = info.working_tree_diff;- if wt_added > 0 || wt_deleted > 0 {- // Build the diff as a mini styled line- let mut diff_segment = StyledLine::new();- diff_segment.push_styled(format!("+{}", wt_added), green);- diff_segment.push_raw(" ");- diff_segment.push_styled(format!("-{}", wt_deleted), red);- diff_segment.pad_to(layout.ideal_widths.working_diff);- // Append all segments from diff_segment to main line- for segment in diff_segment.segments {- line.push(segment);+ if let Some((wt_added, wt_deleted)) = item.working_tree_diff() {+ if wt_added > 0 || wt_deleted > 0 {+ let mut diff_segment = StyledLine::new();+ diff_segment.push_styled(format!("+{}", wt_added), green);+ diff_segment.push_raw(" ");+ diff_segment.push_styled(format!("-{}", wt_deleted), red);+ diff_segment.pad_to(layout.ideal_widths.working_diff);+ for segment in diff_segment.segments {+ line.push(segment);+ }+ } else {+ line.push_raw(" ".repeat(layout.ideal_widths.working_diff));}} else {- // No data for this row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.working_diff));}line.push_raw(" ");}- // Upstream tracking - always reserve space if ANY row uses it+ // Upstream trackingif layout.ideal_widths.upstream > 0 {- if info.upstream_ahead > 0 || info.upstream_behind > 0 {- let remote_name = info.upstream_remote.as_deref().unwrap_or("origin");- // Build the upstream as a mini styled line+ if let Some((remote_name, upstream_ahead, upstream_behind)) = item.upstream_info() {let mut upstream_segment = StyledLine::new();upstream_segment.push_styled(remote_name, dim);upstream_segment.push_raw(" ");- upstream_segment.push_styled(format!("↑{}", info.upstream_ahead), green);+ upstream_segment.push_styled(format!("↑{}", upstream_ahead), green);upstream_segment.push_raw(" ");- upstream_segment.push_styled(format!("↓{}", info.upstream_behind), red);+ upstream_segment.push_styled(format!("↓{}", upstream_behind), red);upstream_segment.pad_to(layout.ideal_widths.upstream);- // Append all segments from upstream_segment to main linefor segment in upstream_segment.segments {line.push(segment);}} else {- // No data for this row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.upstream));}line.push_raw(" ");}- // Commit (short HEAD, fixed width: 8 chars)+ // Commit (short HEAD)if let Some(style) = text_style {line.push_styled(short_head, style);} else {- line.push_raw(short_head);+ line.push_styled(short_head, dim);}line.push_raw(" ");- // Message (left-aligned, truncated at word boundary)+ // Messageif widths.message > 0 {let msg = format!("{:width$}",- truncate_at_word_boundary(&info.commit_message, layout.max_message_len),+ truncate_at_word_boundary(item.commit_message(), layout.max_message_len),width = widths.message);line.push_styled(msg, dim);line.push_raw(" ");}- // States - always reserve space if ANY row uses it+ // States (worktrees only)if layout.ideal_widths.states > 0 {- let states = format_all_states(info);- if !states.is_empty() {- let states_text = format!("{:width$}", states, width = layout.ideal_widths.states);- line.push_raw(states_text);+ if let Some(worktree_info) = item.worktree_info() {+ let states = format_all_states(worktree_info);+ if !states.is_empty() {+ let states_text = format!("{:width$}", states, width = layout.ideal_widths.states);+ line.push_raw(states_text);+ } else {+ line.push_raw(" ".repeat(layout.ideal_widths.states));+ }} else {- // No data for this row: pad with spacesline.push_raw(" ".repeat(layout.ideal_widths.states));}line.push_raw(" ");}- // Path (no padding needed, it's the last column, use shortened path)- let path_str = shorten_path(&info.worktree.path, &layout.common_prefix);- if let Some(style) = text_style {- line.push_styled(path_str, style);- } else {- line.push_raw(path_str);+ // Path (worktrees only)+ if let Some(worktree_info) = item.worktree_info() {+ let path_str = shorten_path(&worktree_info.worktree.path, &layout.common_prefix);+ if let Some(style) = text_style {+ line.push_styled(path_str, style);+ } else {+ line.push_raw(path_str);+ }}println!("{}", line.render());diff --git a/src/main.rs b/src/main.rsindex 1f0f567b8..ddb705113 100644--- a/src/main.rs+++ b/src/main.rs@@ -62,6 +62,10 @@ enum Commands {/// Output format#[arg(long, value_enum, default_value = "table")]format: OutputFormat,++ /// Also display branches that don't have worktrees+ #[arg(long)]+ branches: bool,},/// Switch to a worktree@@ -154,7 +158,7 @@ fn main() {}}).map_err(GitError::CommandFailed),- Commands::List { format } => handle_list(format),+ Commands::List { format, branches } => handle_list(format, branches),Commands::Switch {branch,create,diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rsindex c1023699f..62df05eb2 100644--- a/tests/integration_tests/list.rs+++ b/tests/integration_tests/list.rs@@ -68,6 +68,48 @@ fn snapshot_list_json(test_name: &str, repo: &TestRepo) {});}+/// Helper to create snapshot with --branches flag+fn snapshot_list_with_branches(test_name: &str, repo: &TestRepo) {+ let mut settings = Settings::clone_current();+ settings.set_snapshot_path("../snapshots");++ // Normalize paths - replace absolute paths with semantic names+ settings.add_filter(repo.root_path().to_str().unwrap(), "[REPO]");+ for (name, path) in &repo.worktrees {+ settings.add_filter(+ path.to_str().unwrap(),+ format!("[WORKTREE_{}]", name.to_uppercase().replace('-', "_")),+ );+ }++ // Normalize git SHAs (7-40 hex chars) to [SHA] padded to 8 chars+ settings.add_filter(r"\b[0-9a-f]{7,40}\b", "[SHA] ");++ // Normalize Windows paths to Unix style+ settings.add_filter(r"\\", "/");++ settings.bind(|| {+ let mut cmd = Command::new(get_cargo_bin("wt"));+ // Clean environment to avoid interference from global git config+ repo.clean_cli_env(&mut cmd);+ cmd.arg("list")+ .arg("--branches")+ .current_dir(repo.root_path());++ assert_cmd_snapshot!(test_name, cmd);+ });+}++/// Helper to create a branch without a worktree+fn create_branch(repo: &TestRepo, branch_name: &str) {+ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.args(["branch", branch_name])+ .current_dir(repo.root_path())+ .output()+ .expect("Failed to create branch");+}+#[test]fn test_list_single_worktree() {let repo = TestRepo::new();@@ -222,3 +264,44 @@ fn test_list_json_with_metadata() {snapshot_list_json("json_with_metadata", &repo);}++#[test]+fn test_list_with_branches_flag() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create some branches without worktrees+ create_branch(&repo, "feature-without-worktree");+ create_branch(&repo, "another-branch");+ create_branch(&repo, "fix-bug");++ // Create one branch with a worktree+ repo.add_worktree("feature-with-worktree", "feature-with-worktree");++ snapshot_list_with_branches("with_branches_flag", &repo);+}++#[test]+fn test_list_with_branches_flag_no_available() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");++ // All branches have worktrees (only main exists and has worktree)+ repo.add_worktree("feature-a", "feature-a");+ repo.add_worktree("feature-b", "feature-b");++ snapshot_list_with_branches("with_branches_flag_none_available", &repo);+}++#[test]+fn test_list_with_branches_flag_only_branches() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create several branches without worktrees+ create_branch(&repo, "branch-alpha");+ create_branch(&repo, "branch-beta");+ create_branch(&repo, "branch-gamma");++ snapshot_list_with_branches("with_branches_flag_only_branches", &repo);+}diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex d50b14a80..0ef1c31a9 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -205,7 +205,7 @@ _wt() {return 0;;wt__list)- opts="-h --format --help"+ opts="-h --format --branches --help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap b/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snapdeleted file mode 100644index 47e892289..000000000--- a/tests/snapshots/integration__integration_tests__init__init_bash_all_options.snap+++ /dev/null@@ -1,292 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - bash- - "--cmd"- - wt- - "--hook"- - prompt- env:- CLICOLOR_FORCE: "1"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for bash--# Helper function to parse wt output and handle directives-_wt_exec() {- local output line exit_code- output="$(command wt "$@" 2>&1)"- exit_code=$?-- # Parse output line by line- while IFS= read -r line; do- if [[ "$line" == __WORKTRUNK_CD__* ]]; then- # Extract path and change directory- \cd "${line#__WORKTRUNK_CD__}"- else- # Regular output - print it- echo "$line"- fi- done <<< "$output"-- return $exit_code-}--# Override wt command to add --internal flag for switch and remove-wt() {- local subcommand="$1"-- case "$subcommand" in- switch|remove)- # Commands that need --internal for directory change support- shift- _wt_exec "$subcommand" --internal "$@"- ;;- *)- # All other commands pass through directly- command wt "$@"- ;;- esac-}---# Prompt hook for tracking current worktree-_wt_prompt_hook() {- # Call wt to update tracking- command wt hook prompt 2>/dev/null || true-}--# Add to PROMPT_COMMAND-if [[ -z "${PROMPT_COMMAND}" ]]; then- PROMPT_COMMAND="_wt_prompt_hook"-else- PROMPT_COMMAND="${PROMPT_COMMAND}; _wt_prompt_hook"-fi---# Dynamic completion function-_wt_complete() {- local cur="${COMP_WORDS[COMP_CWORD]}"-- # Call wt complete with current command line- local completions=$(command wt complete "${COMP_WORDS[@]}" 2>/dev/null)- COMPREPLY=($(compgen -W "$completions" -- "$cur"))-}--# Register dynamic completion-complete -F _wt_complete wt--# Static completions (commands and flags)-_wt() {- local i cur prev opts cmd- COMPREPLY=()- if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then- cur="$2"- else- cur="${COMP_WORDS[COMP_CWORD]}"- fi- prev="$3"- cmd=""- opts=""-- for i in "${COMP_WORDS[@]:0:COMP_CWORD}"- do- case "${cmd},${i}" in- ",$1")- cmd="wt"- ;;- wt,complete)- cmd="wt__complete"- ;;- wt,hook)- cmd="wt__hook"- ;;- wt,init)- cmd="wt__init"- ;;- wt,list)- cmd="wt__list"- ;;- wt,merge)- cmd="wt__merge"- ;;- wt,push)- cmd="wt__push"- ;;- wt,remove)- cmd="wt__remove"- ;;- wt,switch)- cmd="wt__switch"- ;;- *)- ;;- esac- done-- case "${cmd}" in- wt)- opts="-h -V --help --version init list switch remove push merge hook complete"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__complete)- opts="-h --help [ARGS]..."- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__hook)- opts="-h --help <HOOK_TYPE>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__init)- opts="-h --cmd --hook --help <SHELL>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- --cmd)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- --hook)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__list)- opts="-h --help"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__merge)- opts="-s -k -h --squash --keep --help [TARGET]"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__push)- opts="-h --allow-merge-commits --help [TARGET]"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__remove)- opts="-h --internal --help"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__switch)- opts="-c -b -h --create --base --internal --help <BRANCH>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- --base)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- -b)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- esac-}--if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then- complete -F _wt -o nosort -o bashdefault -o default wt-else- complete -F _wt -o bashdefault -o default wt-fi------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snapindex 3286ac704..cfb6d42cd 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash_custom_prefix.snap@@ -207,7 +207,7 @@ _wt() {return 0;;wt__list)- opts="-h --format --help"+ opts="-h --format --branches --help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0diff --git a/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snapdeleted file mode 100644index 00b9af0f8..000000000--- a/tests/snapshots/integration__integration_tests__init__init_bash_prompt_hook.snap+++ /dev/null@@ -1,290 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - bash- - "--hook"- - prompt- env:- CLICOLOR_FORCE: "1"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for bash--# Helper function to parse wt output and handle directives-_wt_exec() {- local output line exit_code- output="$(command wt "$@" 2>&1)"- exit_code=$?-- # Parse output line by line- while IFS= read -r line; do- if [[ "$line" == __WORKTRUNK_CD__* ]]; then- # Extract path and change directory- \cd "${line#__WORKTRUNK_CD__}"- else- # Regular output - print it- echo "$line"- fi- done <<< "$output"-- return $exit_code-}--# Override wt command to add --internal flag for switch and remove-wt() {- local subcommand="$1"-- case "$subcommand" in- switch|remove)- # Commands that need --internal for directory change support- shift- _wt_exec "$subcommand" --internal "$@"- ;;- *)- # All other commands pass through directly- command wt "$@"- ;;- esac-}---# Prompt hook for tracking current worktree-_wt_prompt_hook() {- # Call wt to update tracking- command wt hook prompt 2>/dev/null || true-}--# Add to PROMPT_COMMAND-if [[ -z "${PROMPT_COMMAND}" ]]; then- PROMPT_COMMAND="_wt_prompt_hook"-else- PROMPT_COMMAND="${PROMPT_COMMAND}; _wt_prompt_hook"-fi---# Dynamic completion function-_wt_complete() {- local cur="${COMP_WORDS[COMP_CWORD]}"-- # Call wt complete with current command line- local completions=$(command wt complete "${COMP_WORDS[@]}" 2>/dev/null)- COMPREPLY=($(compgen -W "$completions" -- "$cur"))-}--# Register dynamic completion-complete -F _wt_complete wt--# Static completions (commands and flags)-_wt() {- local i cur prev opts cmd- COMPREPLY=()- if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then- cur="$2"- else- cur="${COMP_WORDS[COMP_CWORD]}"- fi- prev="$3"- cmd=""- opts=""-- for i in "${COMP_WORDS[@]:0:COMP_CWORD}"- do- case "${cmd},${i}" in- ",$1")- cmd="wt"- ;;- wt,complete)- cmd="wt__complete"- ;;- wt,hook)- cmd="wt__hook"- ;;- wt,init)- cmd="wt__init"- ;;- wt,list)- cmd="wt__list"- ;;- wt,merge)- cmd="wt__merge"- ;;- wt,push)- cmd="wt__push"- ;;- wt,remove)- cmd="wt__remove"- ;;- wt,switch)- cmd="wt__switch"- ;;- *)- ;;- esac- done-- case "${cmd}" in- wt)- opts="-h -V --help --version init list switch remove push merge hook complete"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__complete)- opts="-h --help [ARGS]..."- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__hook)- opts="-h --help <HOOK_TYPE>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__init)- opts="-h --cmd --hook --help <SHELL>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- --cmd)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- --hook)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__list)- opts="-h --help"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__merge)- opts="-s -k -h --squash --keep --help [TARGET]"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__push)- opts="-h --allow-merge-commits --help [TARGET]"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__remove)- opts="-h --internal --help"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- wt__switch)- opts="-c -b -h --create --base --internal --help <BRANCH>"- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- fi- case "${prev}" in- --base)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- -b)- COMPREPLY=($(compgen -f "${cur}"))- return 0- ;;- *)- COMPREPLY=()- ;;- esac- COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )- return 0- ;;- esac-}--if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then- complete -F _wt -o nosort -o bashdefault -o default wt-else- complete -F _wt -o bashdefault -o default wt-fi------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_elvish.snap b/tests/snapshots/integration__integration_tests__init__init_elvish.snapdeleted file mode 100644index d66cf19eb..000000000--- a/tests/snapshots/integration__integration_tests__init__init_elvish.snap+++ /dev/null@@ -1,76 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - elvish- env:- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for elvish--# Helper function to parse wt output and handle directives-fn _wt_exec {|@args|- var exit-code = 0- var output = ""-- # Capture output and handle potential non-zero exit- try {- set output = (e:wt $@args 2>&1 | slurp)- } catch e {- set exit-code = 1- set output = $e[reason][content]- }-- # Parse output line by line- var lines = [(str:split "\n" $output)]- for line $lines {- if (str:has-prefix $line "__WORKTRUNK_CD__") {- # Extract path and change directory- var path = (str:trim-prefix $line "__WORKTRUNK_CD__")- cd $path- } else {- # Regular output - print it- echo $line- }- }-- # Return exit code (will throw exception if non-zero)- if (!=s $exit-code 0) {- fail "command failed with exit code "$exit-code- }-}--# Override wt command to add --internal flag for switch and finish-fn wt {|@args|- if (== (count $args) 0) {- e:wt- return- }-- var subcommand = $args[0]-- if (or (eq $subcommand "switch") (eq $subcommand "finish")) {- # Commands that need --internal for directory change support- var rest-args = $args[1..]- _wt_exec $subcommand --internal $@rest-args- } else {- # All other commands pass through directly- e:wt $@args- }-}--------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapindex fb89db7d6..08f446f1a 100644--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -117,6 +117,7 @@ complete -c wt -n "__fish_wt_using_subcommand configure-shell" -l dry-run -d 'Shcomplete -c wt -n "__fish_wt_using_subcommand configure-shell" -s h -l help -d 'Print help'complete -c wt -n "__fish_wt_using_subcommand list" -l format -d 'Output format' -r -f -a "table\t'Human-readable table format'json\t'JSON format'"+complete -c wt -n "__fish_wt_using_subcommand list" -l branches -d 'Also display branches that don\'t have worktrees'complete -c wt -n "__fish_wt_using_subcommand list" -s h -l help -d 'Print help (see more with \'--help\')'complete -c wt -n "__fish_wt_using_subcommand switch" -s b -l base -d 'Base branch to create from (only with --create)' -rcomplete -c wt -n "__fish_wt_using_subcommand switch" -s c -l create -d 'Create a new branch'diff --git a/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap b/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snapdeleted file mode 100644index 2c205282e..000000000--- a/tests/snapshots/integration__integration_tests__init__init_fish_prompt_hook.snap+++ /dev/null@@ -1,133 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - fish- - "--hook"- - prompt- env:- CLICOLOR_FORCE: "1"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for fish--# Helper function to parse wt output and handle directives-function _wt_exec- set -l output (command wt $argv 2>&1)- set -l exit_code $status-- # Parse output line by line- for line in (string split \n -- $output)- if string match -q '__WORKTRUNK_CD__*' -- $line- # Extract path and change directory- cd (string replace '__WORKTRUNK_CD__' '' -- $line)- else- # Regular output - print it- echo $line- end- end-- return $exit_code-end--# Override wt command to add --internal flag for switch and remove-function wt- set -l subcommand $argv[1]-- switch $subcommand- case switch remove- # Commands that need --internal for directory change support- _wt_exec $subcommand --internal $argv[2..-1]- case '*'- # All other commands pass through directly- command wt $argv- end-end---# Prompt hook for tracking current worktree-function _wt_prompt_hook --on-event fish_prompt- # Call wt to update tracking- command wt hook prompt 2>/dev/null; or true-end---# Dynamic completion function-function __wt_complete- # Call wt complete with current command line- set -l cmd (commandline -opc)- command wt complete $cmd 2>/dev/null-end--# Register dynamic completions-complete -c wt -n '__fish_seen_subcommand_from switch' -f -a '(__wt_complete)' -d 'Branch'-complete -c wt -n '__fish_seen_subcommand_from push' -f -a '(__wt_complete)' -d 'Target branch'-complete -c wt -n '__fish_seen_subcommand_from merge' -f -a '(__wt_complete)' -d 'Target branch'-complete -c wt -l base -f -a '(__wt_complete)' -d 'Base branch'--# Static completions (commands and flags)-# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.-function __fish_wt_global_optspecs- string join \n h/help V/version-end--function __fish_wt_needs_command- # Figure out if the current invocation already has a command.- set -l cmd (commandline -opc)- set -e cmd[1]- argparse -s (__fish_wt_global_optspecs) -- $cmd 2>/dev/null- or return- if set -q argv[1]- # Also print the command, so this can be used to figure out what it is.- echo $argv[1]- return 1- end- return 0-end--function __fish_wt_using_subcommand- set -l cmd (__fish_wt_needs_command)- test -z "$cmd"- and return 1- contains -- $cmd[1] $argv-end--complete -c wt -n "__fish_wt_needs_command" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_needs_command" -s V -l version -d 'Print version'-complete -c wt -n "__fish_wt_needs_command" -f -a "init" -d 'Generate shell integration code'-complete -c wt -n "__fish_wt_needs_command" -f -a "list" -d 'List all worktrees'-complete -c wt -n "__fish_wt_needs_command" -f -a "switch" -d 'Switch to a worktree'-complete -c wt -n "__fish_wt_needs_command" -f -a "remove" -d 'Finish current worktree, returning to primary if current'-complete -c wt -n "__fish_wt_needs_command" -f -a "push" -d 'Push changes between worktrees'-complete -c wt -n "__fish_wt_needs_command" -f -a "merge" -d 'Merge worktree into target branch'-complete -c wt -n "__fish_wt_using_subcommand init" -l cmd -d 'Command prefix (default: wt)' -r-complete -c wt -n "__fish_wt_using_subcommand init" -l hook -d 'Hook mode (none, prompt)' -r-complete -c wt -n "__fish_wt_using_subcommand init" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand list" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand switch" -s b -l base -d 'Base branch to create from (only with --create)' -r-complete -c wt -n "__fish_wt_using_subcommand switch" -s c -l create -d 'Create a new branch'-complete -c wt -n "__fish_wt_using_subcommand switch" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'-complete -c wt -n "__fish_wt_using_subcommand switch" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand remove" -l internal -d 'Use internal mode (outputs directives for shell wrapper)'-complete -c wt -n "__fish_wt_using_subcommand remove" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand push" -l allow-merge-commits -d 'Allow pushing merge commits (non-linear history)'-complete -c wt -n "__fish_wt_using_subcommand push" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand merge" -s s -l squash -d 'Squash all commits into one before merging'-complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t remove)'-complete -c wt -n "__fish_wt_using_subcommand merge" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand hook" -s h -l help -d 'Print help'-complete -c wt -n "__fish_wt_using_subcommand complete" -s h -l help -d 'Print help'------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_nushell.snap b/tests/snapshots/integration__integration_tests__init__init_nushell.snapdeleted file mode 100644index 06d40308a..000000000--- a/tests/snapshots/integration__integration_tests__init__init_nushell.snap+++ /dev/null@@ -1,66 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - nushell- env:- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for nushell--# Helper function to parse wt output and handle directives-export def --env _wt_exec [...args] {- let result = (do { ^wt ...$args } | complete)-- # Parse output line by line- let lines = ($result.stdout | lines)- for line in $lines {- if ($line | str starts-with "__WORKTRUNK_CD__") {- # Extract path and change directory- let path = ($line | str substring 16..)- cd $path- } else {- # Regular output - print it- print $line- }- }-- # Return the exit code- return $result.exit_code-}--# Override wt command to add --internal flag for switch and finish-# Use --wrapped to pass through all flags without parsing them-export def --env --wrapped wt [...rest] {- let subcommand = ($rest | get 0? | default "")-- match $subcommand {- "switch" | "finish" => {- # Commands that need --internal for directory change support- let rest_args = ($rest | skip 1)- let internal_args = ([$subcommand, "--internal"] | append $rest_args)- let exit_code = (_wt_exec ...$internal_args)- return $exit_code- }- _ => {- # All other commands pass through directly- ^wt ...$rest- }- }-}--------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_oil.snap b/tests/snapshots/integration__integration_tests__init__init_oil.snapdeleted file mode 100644index 2420bc4b6..000000000--- a/tests/snapshots/integration__integration_tests__init__init_oil.snap+++ /dev/null@@ -1,62 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - oil- env:- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for oil--# Helper function to parse wt output and handle directives-_wt_exec() {- local output line exit_code- output="$(command wt "$@" 2>&1)"- exit_code=$?-- # Parse output line by line- while IFS= read -r line; do- if [[ "$line" == __WORKTRUNK_CD__* ]]; then- # Extract path and change directory- \cd "${line#__WORKTRUNK_CD__}"- else- # Regular output - print it- echo "$line"- fi- done <<< "$output"-- return $exit_code-}--# Override wt command to add --internal flag for switch and finish-wt() {- local subcommand="$1"-- case "$subcommand" in- switch|finish)- # Commands that need --internal for directory change support- shift- _wt_exec "$subcommand" --internal "$@"- ;;- *)- # All other commands pass through directly- command wt "$@"- ;;- esac-}--------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_powershell.snap b/tests/snapshots/integration__integration_tests__init__init_powershell.snapdeleted file mode 100644index 3e3a06549..000000000--- a/tests/snapshots/integration__integration_tests__init__init_powershell.snap+++ /dev/null@@ -1,80 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - powershell- env:- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for PowerShell--# Helper function to parse wt output and handle directives-function _wt_exec {- param(- [Parameter(ValueFromRemainingArguments=$true)]- [string[]]$Arguments- )-- # Capture output and exit code- $output = & wt @Arguments 2>&1- $exitCode = $LASTEXITCODE-- # Parse output line by line- foreach ($line in $output) {- if ($line -match '^__WORKTRUNK_CD__(.+)$') {- # Extract path and change directory- Set-Location $matches[1]- } else {- # Regular output - write it- Write-Output $line- }- }-- # Return the exit code- return $exitCode-}--# Override wt command to add --internal flag for switch and finish-function wt {- param(- [Parameter(ValueFromRemainingArguments=$true)]- [string[]]$Arguments- )-- if ($Arguments.Count -eq 0) {- & wt- return $LASTEXITCODE- }-- $subcommand = $Arguments[0]-- switch ($subcommand) {- { $_ -in @("switch", "finish") } {- # Commands that need --internal for directory change support- $restArgs = $Arguments[1..($Arguments.Count-1)]- $exitCode = _wt_exec $subcommand --internal @restArgs- return $exitCode- }- default {- # All other commands pass through directly- & wt @Arguments- return $LASTEXITCODE- }- }-}--------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_xonsh.snap b/tests/snapshots/integration__integration_tests__init__init_xonsh.snapdeleted file mode 100644index 551e5cff7..000000000--- a/tests/snapshots/integration__integration_tests__init__init_xonsh.snap+++ /dev/null@@ -1,65 +0,0 @@-----source: tests/integration_tests/init.rs-info:- program: wt- args:- - init- - xonsh- env:- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: /dev/null- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- LANG: C- LC_ALL: C- SOURCE_DATE_EPOCH: "1704067200"-----success: true-exit_code: 0------ stdout ------# worktrunk shell integration for xonsh--def _wt_exec(args):- """Helper function to parse wt output and handle directives"""- # Capture full output including return code- result = !(wt @(args))-- # Parse output line by line- if result.out:- for line in result.out.splitlines():- if line.startswith("__WORKTRUNK_CD__"):- # Extract path and change directory- path = line[17:] # Remove prefix- cd @(path)- else:- # Regular output - print it- print(line)-- # Return the exit code- return result.returncode--def _wt_wrapper(args):- """Override wt command to add --internal flag for switch and finish"""- if not args:- # No arguments, just run wt- wt- return-- subcommand = args[0]-- if subcommand in ["switch", "finish"]:- # Commands that need --internal for directory change support- rest_args = args[1:]- return _wt_exec([subcommand, "--internal"] + rest_args)- else:- # All other commands pass through directly- result = !(wt @(args))- return result.returncode--# Register the alias-aliases['wt'] = _wt_wrapper--------- stderr -----diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex 630cc07ac..eaa2fbb7b 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -122,6 +122,7 @@ _arguments "${_arguments_options[@]}" : \_arguments "${_arguments_options[@]}" : \'--format=[Output format]:FORMAT:((table\:"Human-readable table format"json\:"JSON format"))' \+'--branches[Also display branches that don'\''t have worktrees]' \'-h[Print help (see more with '\''--help'\'')]' \'--help[Print help (see more with '\''--help'\'')]' \&& ret=0diff --git a/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap b/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snapindex 1c8f724e1..056fb815d 100644--- a/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap+++ b/tests/snapshots/integration__integration_tests__list__json_multiple_worktrees.snap@@ -21,6 +21,7 @@ exit_code: 0----- stdout -----[{+ "type": "worktree","worktree": {"path": "[REPO]","head": "[SHA]",@@ -49,6 +50,7 @@ exit_code: 0"worktree_state": null},{+ "type": "worktree","worktree": {"path": "[WORKTREE_FEATURE_A]","head": "[SHA]",@@ -77,6 +79,7 @@ exit_code: 0"worktree_state": null},{+ "type": "worktree","worktree": {"path": "[WORKTREE_FEATURE_B]","head": "[SHA]",diff --git a/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap b/tests/snapshots/integration__integration_tests__list__json_single_worktree.snapindex 685764e33..bc2b2d836 100644--- a/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap+++ b/tests/snapshots/integration__integration_tests__list__json_single_worktree.snap@@ -21,6 +21,7 @@ exit_code: 0----- stdout -----[{+ "type": "worktree","worktree": {"path": "[REPO]","head": "[SHA]",diff --git a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snapindex 8eb365080..19a584093 100644--- a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap+++ b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap@@ -21,6 +21,7 @@ exit_code: 0----- stdout -----[{+ "type": "worktree","worktree": {"path": "[REPO]","head": "[SHA]",@@ -49,6 +50,7 @@ exit_code: 0"worktree_state": null},{+ "type": "worktree","worktree": {"path": "[WORKTREE_FEATURE_DETACHED]","head": "[SHA]",@@ -77,6 +79,7 @@ exit_code: 0"worktree_state": null},{+ "type": "worktree","worktree": {"path": "[WORKTREE_LOCKED_FEATURE]","head": "[SHA]",diff --git a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snapindex 074311edd..3065e4f0e 100644--- a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap+++ b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap@@ -20,6 +20,6 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState [0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m-locked-no-reason [2m9 months ago[0m [SHA] (locked) ./locked-no-reason+locked-no-reason [2m9 months ago[0m [2mb834638e[0m (locked) ./locked-no-reason----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap b/tests/snapshots/integration__integration_tests__list__locked_worktree.snapindex cf0bcb200..89cf95fa2 100644--- a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap+++ b/tests/snapshots/integration__integration_tests__list__locked_worktree.snap@@ -20,6 +20,6 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState [0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m-locked-feature [2m9 months ago[0m [SHA] (locked: Testing lock functionality) ./locked-feature+locked-feature [2m9 months ago[0m [2mb834638e[0m (locked: Testing lock functionality) ./locked-feature----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__long_branch_name.snap b/tests/snapshots/integration__integration_tests__list__long_branch_name.snapindex 1daa23ef1..46679da8c 100644--- a/tests/snapshots/integration__integration_tests__list__long_branch_name.snap+++ b/tests/snapshots/integration__integration_tests__list__long_branch_name.snap@@ -20,6 +20,6 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [1m[35mb834638e[0m [1m[35m./main[0m-feature-this-is-a-very-long-branch-name-that-should-test-column-alignment [SHA] ./feature-this-is-a-very-long-branch-name-that-should-test-column-alignment+feature-this-is-a-very-long-branch-name-that-should-test-column-alignment [2mb834638e[0m ./feature-this-is-a-very-long-branch-name-that-should-test-column-alignment----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap b/tests/snapshots/integration__integration_tests__list__long_commit_message.snapindex 3038f1011..847bc3096 100644--- a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap+++ b/tests/snapshots/integration__integration_tests__list__long_commit_message.snap@@ -20,6 +20,6 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts [0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35m1310bfb9[0m [2mShort message [0m [1m[35m./main[0m-feature-a [2m9 months ago[0m [33m↑0 ↓1[0m [SHA] [2mThis is a very... [0m ./feature-a+feature-a [2m9 months ago[0m [33m↑0 ↓1[0m [2mf078644e[0m [2mThis is a very... [0m ./feature-a----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap b/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snapindex fa9c5240d..0d1cd2e52 100644--- a/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap+++ b/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap@@ -20,9 +20,9 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m-medium-name [2m9 months ago[0m [SHA] ./medium-name-short [2m9 months ago[0m [SHA] ./short-very-long-branch-name-here [2m9 months ago[0m [SHA] ./very-long-branch-name-here-with-changes [2m9 months ago[0m [SHA] ./with-changes+medium-name [2m9 months ago[0m [2mb834638e[0m ./medium-name+short [2m9 months ago[0m [2mb834638e[0m ./short+very-long-branch-name-here [2m9 months ago[0m [2mb834638e[0m ./very-long-branch-name-here+with-changes [2m9 months ago[0m [2mb834638e[0m ./with-changes----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snapindex 42a7f7cae..1044d5c27 100644--- a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap+++ b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap@@ -20,7 +20,7 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [2mInitial commit[0m [1m[35m./main[0m-feature-a [2m9 months ago[0m [SHA] [2mInitial commit[0m ./feature-a-feature-b [2m9 months ago[0m [SHA] [2mInitial commit[0m ./feature-b+feature-a [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./feature-a+feature-b [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./feature-b----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap b/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snapindex 2150a5f78..b7816ff99 100644--- a/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap+++ b/tests/snapshots/integration__integration_tests__list__unicode_branch_name.snap@@ -20,7 +20,7 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m-feature-日本語-test [2m9 months ago[0m [SHA] ./feature-日本語-test-fix-émoji-🎉 [2m9 months ago[0m [SHA] ./fix-émoji-🎉+feature-日本語-test [2m9 months ago[0m [2mb834638e[0m ./feature-日本語-test+fix-émoji-🎉 [2m9 months ago[0m [2mb834638e[0m ./fix-émoji-🎉----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snapindex 43a4b9dec..7b1379fda 100644--- a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap+++ b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap@@ -20,6 +20,6 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts [0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35me4614cb7[0m [1m[35m./main[0m-feature-test [2m9 months ago[0m [33m↑0 ↓1[0m [SHA] ./feature-test+feature-test [2m9 months ago[0m [33m↑0 ↓1[0m [2m0c53695b[0m ./feature-test----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag.snapnew file mode 100644index 000000000..f1b721cce--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap@@ -0,0 +1,29 @@+---+source: tests/integration_tests/list.rs+info:+ program: wt+ args:+ - list+ - "--branches"+ env:+ CLICOLOR_FORCE: "1"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: /dev/null+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1704067200"+---+success: true+exit_code: 0+----- stdout -----+[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m+[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m+feature-with-worktree [2m9 months ago[0m [2mb834638e[0m ./feature-with-worktree+another-branch [2m9 months ago[0m [2mb834638e[0m+feature-without-worktree [2m9 months ago[0m [2mb834638e[0m+fix-bug [2m9 months ago[0m [2mb834638e[0m++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snapnew file mode 100644index 000000000..65efe3250--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap@@ -0,0 +1,27 @@+---+source: tests/integration_tests/list.rs+info:+ program: wt+ args:+ - list+ - "--branches"+ env:+ CLICOLOR_FORCE: "1"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: /dev/null+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1704067200"+---+success: true+exit_code: 0+----- stdout -----+[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m+[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [2mInitial commit[0m [1m[35m./main[0m+feature-a [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./feature-a+feature-b [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./feature-b++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snapnew file mode 100644index 000000000..3b577bd04--- /dev/null+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap@@ -0,0 +1,28 @@+---+source: tests/integration_tests/list.rs+info:+ program: wt+ args:+ - list+ - "--branches"+ env:+ CLICOLOR_FORCE: "1"+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_CONFIG_GLOBAL: /dev/null+ GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1704067200"+---+success: true+exit_code: 0+----- stdout -----+[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m+[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m.[0m+branch-alpha [2m9 months ago[0m [2mb834638e[0m+branch-beta [2m9 months ago[0m [2mb834638e[0m+branch-gamma [2m9 months ago[0m [2mb834638e[0m++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snapindex 364260c9f..1e41026a1 100644--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap@@ -20,8 +20,8 @@ exit_code: 0----- stdout -----[2mBranch [0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [1m[35m./main[0m-another-extremely-long-name-here [2m9 months ago[0m [SHA] ./another-extremely-long-name-here-short [2m9 months ago[0m [SHA] ./short-very-long-feature-branch-name [2m9 months ago[0m [SHA] ./very-long-feature-branch-name+another-extremely-long-name-here [2m9 months ago[0m [2mb834638e[0m ./another-extremely-long-name-here+short [2m9 months ago[0m [2mb834638e[0m ./short+very-long-feature-branch-name [2m9 months ago[0m [2mb834638e[0m ./very-long-feature-branch-name----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snapindex 668061bc2..2ed349526 100644--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap@@ -20,8 +20,8 @@ exit_code: 0----- stdout -----[2mBranch[0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [2mInitial commit[0m [1m[35m./main[0m-long [2m9 months ago[0m [SHA] [2mInitial commit[0m ./extremely-long-branch-name-that-might-cause-layout-issues-medium [2m9 months ago[0m [SHA] [2mInitial commit[0m ./medium-length-name-x [2m9 months ago[0m [SHA] [2mInitial commit[0m ./x+long [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./extremely-long-branch-name-that-might-cause-layout-issues+medium [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./medium-length-name+x [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./x----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snapindex 547a31ca8..473448070 100644--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap@@ -20,8 +20,8 @@ exit_code: 0----- stdout -----[2mBranch[0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [2mInitial commit[0m [1m[35m./main[0m-a [2m9 months ago[0m [SHA] [2mInitial commit[0m ./a-bb [2m9 months ago[0m [SHA] [2mInitial commit[0m ./bb-ccc [2m9 months ago[0m [SHA] [2mInitial commit[0m ./ccc+a [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./a+bb [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./bb+ccc [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./ccc----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snapindex 2e90d9f27..87ec4f539 100644--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap@@ -20,8 +20,8 @@ exit_code: 0----- stdout -----[2mBranch[0m [2mAge [0m [2mCmts[0m [2mCmt +/-[0m [2mWT +/-[0m [2mRemote[0m [2mCommit [0m [2mMessage [0m [2mState[0m [2mPath[0m[1m[35mmain [0m [2m9 months ago[0m [1m[35mb834638e[0m [2mInitial commit[0m [1m[35m./main[0m-cafe [2m9 months ago[0m [SHA] [2mInitial commit[0m ./café-naive [2m9 months ago[0m [SHA] [2mInitial commit[0m ./naïve-resume [2m9 months ago[0m [SHA] [2mInitial commit[0m ./résumé+cafe [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./café+naive [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./naïve+resume [2m9 months ago[0m [2mb834638e[0m [2mInitial commit[0m ./résumé----- stderr -----