Skip to content

Commit d95023d

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 13eaa33 commit d95023d

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
@@ -298,9 +302,19 @@ fn print_branch_sections(
298302
let commit_short = &commit.id.to_string()[..7];
299303
let commit_id = CliId::commit(commit.id).to_string().underline().blue();
300304
let message_line = format_commit_message(&commit.message);
305+
306+
// Check if this upstream commit also exists in local commits (pushed)
307+
let is_also_local = branch.commits.iter().any(|local| local.id == commit.id);
308+
let status_decoration = if is_also_local {
309+
"P".yellow() // Pushed (exists both upstream and locally)
310+
} else {
311+
"R".red() // Remote-only (upstream only)
312+
};
313+
301314
println!(
302-
"{}● {} {} {}",
315+
"{}● {} {} {} {}",
303316
prefix,
317+
status_decoration,
304318
commit_id,
305319
commit_short.blue(),
306320
message_line
@@ -330,14 +344,25 @@ fn print_branch_sections(
330344
}
331345
}
332346

333-
// Show local commits
347+
// Show local commits (but skip ones already shown as upstream)
334348
for commit in &branch.commits {
349+
// Skip if this commit was already shown in upstream commits
350+
let already_shown = branch.upstream_commits.iter().any(|upstream| upstream.id == commit.id);
351+
if already_shown {
352+
continue;
353+
}
354+
335355
let commit_short = &commit.id.to_string()[..7];
336356
let commit_id = CliId::commit(commit.id).to_string().underline().blue();
337357
let message_line = format_commit_message(&commit.message);
358+
359+
// Local-only commits (not pushed)
360+
let status_decoration = "L".green();
361+
338362
println!(
339-
"{}● {} {} {}",
363+
"{}● {} {} {} {}",
340364
prefix,
365+
status_decoration,
341366
commit_id,
342367
commit_short.blue(),
343368
message_line

0 commit comments

Comments
 (0)