Skip to content

Commit b1535e9

Browse files
committed
Decorate commits with status letters (R/P/L)
Add simple colored status decorations to commits to indicate whether a commit is remote-only (R), pushed/both (P), or local-only (L). This makes it easier to visually distinguish commits that exist only upstream, those already pushed and present locally, and local-only commits.
1 parent f24aa12 commit b1535e9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

crates/but/src/status/mod.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ pub(crate) fn worktree(repo_path: &Path, json: bool, show_base: bool, show_files
6767
// Print branches with commits and assigned files
6868
if !stacks.is_empty() {
6969
print_branch_sections(&stacks, &assignments_by_file, &changes, &project, show_files, ctx)?;
70+
71+
// Print legend for commit status decorations
72+
println!("Legend: {} Remote-only {} Pushed {} Local-only",
73+
"R".red(), "P".yellow(), "L".green());
7074
}
7175

7276
// Print unassigned files
@@ -360,9 +364,19 @@ fn print_branch_sections(
360364
let commit_short = &commit.id.to_string()[..7];
361365
let commit_id = CliId::commit(commit.id).to_string().underline().blue();
362366
let message_line = format_commit_message(&commit.message);
367+
368+
// Check if this upstream commit also exists in local commits (pushed)
369+
let is_also_local = branch.commits.iter().any(|local| local.id == commit.id);
370+
let status_decoration = if is_also_local {
371+
"P".yellow() // Pushed (exists both upstream and locally)
372+
} else {
373+
"R".red() // Remote-only (upstream only)
374+
};
375+
363376
println!(
364-
"{}● {} {} {}",
377+
"{}● {} {} {} {}",
365378
prefix,
379+
status_decoration,
366380
commit_id,
367381
commit_short.blue(),
368382
message_line
@@ -392,14 +406,25 @@ fn print_branch_sections(
392406
}
393407
}
394408

395-
// Show local commits
409+
// Show local commits (but skip ones already shown as upstream)
396410
for commit in &branch.commits {
411+
// Skip if this commit was already shown in upstream commits
412+
let already_shown = branch.upstream_commits.iter().any(|upstream| upstream.id == commit.id);
413+
if already_shown {
414+
continue;
415+
}
416+
397417
let commit_short = &commit.id.to_string()[..7];
398418
let commit_id = CliId::commit(commit.id).to_string().underline().blue();
399419
let message_line = format_commit_message(&commit.message);
420+
421+
// Local-only commits (not pushed)
422+
let status_decoration = "L".green();
423+
400424
println!(
401-
"{}● {} {} {}",
425+
"{}● {} {} {} {}",
402426
prefix,
427+
status_decoration,
403428
commit_id,
404429
commit_short.blue(),
405430
message_line

0 commit comments

Comments
 (0)