Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Rename base_branch to default_branch

Maximilian Roos16c8a1366512
diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rs
index 2da84a491..935749f08 100644
--- a/src/commands/list/collect.rs
+++ b/src/commands/list/collect.rs
@@ -174,12 +174,12 @@ fn compute_divergences(
/// - `BranchState::None` otherwise
fn determine_worktree_branch_state(
is_main: bool,
- base_branch: Option<&str>,
+ default_branch: Option<&str>,
ahead: usize,
working_tree_diff: Option<&LineDiff>,
working_tree_diff_with_main: &Option<Option<LineDiff>>,
) -> BranchState {
- if is_main || base_branch.is_none() {
+ if is_main || default_branch.is_none() {
return BranchState::None;
}
@@ -211,7 +211,7 @@ fn determine_worktree_branch_state(
// differs from the branch name we associate with it (e.g., worktree exists but on another branch).
fn compute_item_status_symbols(
item: &mut ListItem,
- base_branch: Option<&str>,
+ default_branch: Option<&str>,
has_merge_tree_conflicts: bool,
user_status: Option<String>,
) {
@@ -225,7 +225,7 @@ fn compute_item_status_symbols(
match &item.kind {
ItemKind::Worktree(data) => {
// Full status computation for worktrees
- // Use base_branch directly (None for main worktree)
+ // Use default_branch directly (None for main worktree)
// Item attributes - priority: prunable > locked (1 char max)
let item_attrs = if data.prunable.is_some() {
@@ -239,7 +239,7 @@ fn compute_item_status_symbols(
// Determine branch state (only for non-main worktrees with base branch)
let branch_state = determine_worktree_branch_state(
data.is_main,
- base_branch,
+ default_branch,
counts.ahead,
data.working_tree_diff.as_ref(),
&data.working_tree_diff_with_main,
@@ -453,12 +453,12 @@ pub fn collect(
return Ok(None);
}
- let base_branch = repo.default_branch()?;
+ let default_branch = repo.default_branch()?;
// Main worktree is the worktree on the default branch (if exists), else first worktree
let main_worktree = worktrees
.worktrees
.iter()
- .find(|wt| wt.branch.as_deref() == Some(base_branch.as_str()))
+ .find(|wt| wt.branch.as_deref() == Some(default_branch.as_str()))
.cloned()
.unwrap_or_else(|| worktrees.worktrees[0].clone());
let current_worktree_path = repo.worktree_root().ok();
@@ -646,18 +646,18 @@ pub fn collect(
// Spawn worktree collection in background thread
let sorted_worktrees_clone = sorted_worktrees.clone();
let tx_worktrees = tx.clone();
- let base_branch_clone = base_branch.clone();
+ let default_branch_clone = default_branch.clone();
std::thread::spawn(move || {
sorted_worktrees_clone
.par_iter()
.enumerate()
.for_each(|(idx, wt)| {
- // Always pass base_branch for ahead/behind/diff computation
+ // Always pass default_branch for ahead/behind/diff computation
// Status symbols will filter based on is_main flag
super::collect_progressive_impl::collect_worktree_progressive(
wt,
idx,
- &base_branch_clone,
+ &default_branch_clone,
&options,
tx_worktrees.clone(),
);
@@ -669,7 +669,7 @@ pub fn collect(
let branches_clone = branches_without_worktrees.clone();
let main_path = main_worktree.path.clone();
let tx_branches = tx.clone();
- let base_branch_clone = base_branch.clone();
+ let default_branch_clone = default_branch.clone();
std::thread::spawn(move || {
branches_clone
.par_iter()
@@ -681,7 +681,7 @@ pub fn collect(
commit_sha,
&main_path,
item_idx,
- &base_branch_clone,
+ &default_branch_clone,
&options,
tx_branches.clone(),
);
@@ -702,14 +702,14 @@ pub fn collect(
|item_idx, info, has_merge_tree_conflicts, user_status| {
// Compute/recompute status symbols as data arrives (both modes)
// This is idempotent and updates status as new data (like upstream) arrives
- let item_base_branch = if info.is_main() {
+ let item_default_branch = if info.is_main() {
None
} else {
- Some(base_branch.as_str())
+ Some(default_branch.as_str())
};
compute_item_status_symbols(
info,
- item_base_branch,
+ item_default_branch,
has_merge_tree_conflicts,
user_status,
);
diff --git a/src/commands/list/collect_progressive_impl.rs b/src/commands/list/collect_progressive_impl.rs
index d2b6b6aeb..9a2a49b5e 100644
--- a/src/commands/list/collect_progressive_impl.rs
+++ b/src/commands/list/collect_progressive_impl.rs
@@ -30,7 +30,7 @@ struct TaskContext {
repo_path: PathBuf,
commit_sha: String,
branch: Option<String>,
- base_branch: Option<String>,
+ default_branch: Option<String>,
item_idx: usize,
}
@@ -75,7 +75,7 @@ fn spawn_ahead_behind<'scope>(
ctx: &TaskContext,
tx: Sender<CellUpdate>,
) {
- if let Some(base) = ctx.base_branch.as_deref() {
+ if let Some(base) = ctx.default_branch.as_deref() {
let item_idx = ctx.item_idx;
let sha = ctx.commit_sha.clone();
let path = ctx.repo_path.clone();
@@ -103,7 +103,7 @@ fn spawn_branch_diff<'scope>(
ctx: &TaskContext,
tx: Sender<CellUpdate>,
) {
- if let Some(base) = ctx.base_branch.as_deref() {
+ if let Some(base) = ctx.default_branch.as_deref() {
let item_idx = ctx.item_idx;
let sha = ctx.commit_sha.clone();
let path = ctx.repo_path.clone();
@@ -133,7 +133,7 @@ fn spawn_working_tree_diff<'scope>(
) {
let item_idx = ctx.item_idx;
let path = ctx.repo_path.clone();
- let base = ctx.base_branch.clone();
+ let base = ctx.default_branch.clone();
s.spawn(move || {
let repo = Repository::at(&path);
let status_output = match repo.run_command(&["status", "--porcelain"]) {
@@ -190,7 +190,7 @@ fn spawn_merge_tree_conflicts<'scope>(
tx: Sender<CellUpdate>,
) {
let item_idx = ctx.item_idx;
- if check_merge_tree_conflicts && let Some(base) = ctx.base_branch.as_deref() {
+ if check_merge_tree_conflicts && let Some(base) = ctx.default_branch.as_deref() {
let sha = ctx.commit_sha.clone();
let path = ctx.repo_path.clone();
let base = base.to_string();
@@ -353,7 +353,7 @@ fn spawn_ci_status<'scope>(
pub fn collect_worktree_progressive(
wt: &Worktree,
item_idx: usize,
- base_branch: &str,
+ default_branch: &str,
options: &CollectOptions,
tx: Sender<CellUpdate>,
) {
@@ -361,7 +361,7 @@ pub fn collect_worktree_progressive(
repo_path: wt.path.clone(),
commit_sha: wt.head.clone(),
branch: wt.branch.clone(),
- base_branch: Some(base_branch.to_string()),
+ default_branch: Some(default_branch.to_string()),
item_idx,
};
@@ -470,7 +470,7 @@ pub fn collect_branch_progressive(
commit_sha: &str,
repo_path: &std::path::Path,
item_idx: usize,
- base_branch: &str,
+ default_branch: &str,
options: &CollectOptions,
tx: Sender<CellUpdate>,
) {
@@ -478,7 +478,7 @@ pub fn collect_branch_progressive(
repo_path: repo_path.to_path_buf(),
commit_sha: commit_sha.to_string(),
branch: Some(branch_name.to_string()),
- base_branch: Some(base_branch.to_string()),
+ default_branch: Some(default_branch.to_string()),
item_idx,
};
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index eb1c0d775..bb48514c7 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -20,10 +20,7 @@ impl DiffDisplayConfig {
return None;
}
- let (positive_symbol, negative_symbol) = match self.variant {
- DiffVariant::Signs => ("+", "-"),
- DiffVariant::Arrows => ("↑", "↓"),
- };
+ let symbols = self.variant.symbols();
let mut parts = Vec::with_capacity(2);
@@ -31,7 +28,7 @@ impl DiffDisplayConfig {
parts.push(format!(
"{}{}{}{}",
self.positive_style,
- positive_symbol,
+ symbols.positive,
positive,
self.positive_style.render_reset()
));
@@ -41,7 +38,7 @@ impl DiffDisplayConfig {
parts.push(format!(
"{}{}{}{}",
self.negative_style,
- negative_symbol,
+ symbols.negative,
negative,
self.negative_style.render_reset()
));
@@ -120,21 +117,21 @@ impl PrStatus {
}
#[derive(Clone, Copy)]
-struct DiffRenderConfig {
- positive_symbol: &'static str,
- negative_symbol: &'static str,
+struct DiffSymbols {
+ positive: &'static str,
+ negative: &'static str,
}
impl DiffVariant {
- fn render_config(self) -> DiffRenderConfig {
+ fn symbols(self) -> DiffSymbols {
match self {
- DiffVariant::Signs => DiffRenderConfig {
- positive_symbol: "+",
- negative_symbol: "-",
+ DiffVariant::Signs => DiffSymbols {
+ positive: "+",
+ negative: "-",
},
- DiffVariant::Arrows => DiffRenderConfig {
- positive_symbol: "↑",
- negative_symbol: "↓",
+ DiffVariant::Arrows => DiffSymbols {
+ positive: "↑",
+ negative: "↓",
},
}
}
@@ -221,7 +218,7 @@ impl DiffColumnConfig {
}
fn render_segment(&self, positive: usize, negative: usize) -> StyledLine {
- let render_config = self.display.variant.render_config();
+ let symbols = self.display.variant.symbols();
let mut segment = StyledLine::new();
// Check for overflow
@@ -249,7 +246,7 @@ impl DiffColumnConfig {
if Self::should_render(positive, self.display.always_show_zeros) {
Self::render_subcolumn(
&mut segment,
- render_config.positive_symbol,
+ symbols.positive,
positive,
positive_width,
self.display.positive_style,
@@ -268,7 +265,7 @@ impl DiffColumnConfig {
if Self::should_render(negative, self.display.always_show_zeros) {
Self::render_subcolumn(
&mut segment,
- render_config.negative_symbol,
+ symbols.negative,
negative,
negative_width,
self.display.negative_style,