Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

status: add status.compareBranches config for multiple branch comparisons (+ peff's memory leak fix)#2170

Draft
HaraldNordgren wants to merge 3 commits intogit:masterfrom
HaraldNordgren:ahead_of_main_status__peff_memory_fix
Draft

status: add status.compareBranches config for multiple branch comparisons (+ peff's memory leak fix)#2170
HaraldNordgren wants to merge 3 commits intogit:masterfrom
HaraldNordgren:ahead_of_main_status__peff_memory_fix

Conversation

@HaraldNordgren
Copy link
Contributor

@HaraldNordgren HaraldNordgren commented Jan 19, 2026

No description provided.

@HaraldNordgren HaraldNordgren changed the title refactor format_branch_comparison in preparation refactor format_branch_comparison in preparation (test peff's memory leak fix) Jan 19, 2026
@HaraldNordgren HaraldNordgren changed the title refactor format_branch_comparison in preparation (test peff's memory leak fix) status: add status.compareBranches config for multiple branch comparisons (test peff's memory leak fix) Jan 19, 2026
@HaraldNordgren HaraldNordgren force-pushed the ahead_of_main_status__peff_memory_fix branch from 28a24ab to 32e0bef Compare January 20, 2026 08:25
@HaraldNordgren HaraldNordgren changed the title status: add status.compareBranches config for multiple branch comparisons (test peff's memory leak fix) status: add status.compareBranches config for multiple branch comparisons (+ peff's memory leak fix) Jan 20, 2026
@HaraldNordgren HaraldNordgren force-pushed the ahead_of_main_status__peff_memory_fix branch 6 times, most recently from d45b5d7 to cc58378 Compare January 25, 2026 12:50
HaraldNordgren and others added 3 commits January 26, 2026 16:12
Refactor format_branch_comparison function in preparation for showing
comparison with push remote tracking branch.

Signed-off-by: Harald Nordgren <[email protected]>
…sons

Add a new configuration variable `status.compareBranches` that allows
users to specify a space-separated list of branches to compare against
the current branch in `git status` output.

Each branch in the list can be:
- A remote-tracking branch name (e.g., `origin/main`)
- The special reference `@{upstream}` for the tracking branch
- The special reference `@{push}` for the push destination

When not configured, the default behavior is equivalent to setting
`status.compareBranches = @{upstream}`, preserving backward compatibility.

The advice messages shown are context-aware:
- "git pull" advice is shown only when comparing against @{upstream}
- "git push" advice is shown only when comparing against @{push}
- Divergence advice is shown for upstream branch comparisons

This is useful for triangular workflows where the upstream tracking
branch differs from the push destination, allowing users to see their
status relative to both branches at once.

Example configuration:
    [status]
        compareBranches = @{upstream} @{push}

Signed-off-by: Harald Nordgren <[email protected]>
We have an error_buf() helper that functions a bit like our error()
helper, but returns NULL instead of -1. Its return type is "const char
*", but this is overly restrictive. If we use the helper in a function
that returns non-const "char *", the compiler will complain about
the implicit cast from const to non-const.

Meanwhile, the const in the helper is doing nothing useful, as it only
ever returns NULL. Let's drop the const, which will let us use it in
both types of function.

Signed-off-by: Jeff King <[email protected]>
@HaraldNordgren HaraldNordgren force-pushed the ahead_of_main_status__peff_memory_fix branch from cc58378 to 8de00dd Compare January 26, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants