[PATCH v21 0/2] status: show comparison with push remote tracking branch
- From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Jan 10, 2026, 15:24 UTC
- Message-ID
- <pull.2138.v21.git.git.1768058653.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2138.v20.git.git.1768051831.gitgitgadget@gmail.com>
cc: Chris Torek chris.torek@gmail.com cc: Yee Cheng Chin ychin.macvim@gmail.com cc: "brian m. carlson" sandals@crustytoothpaste.net cc: Ben Knoble ben.knoble@gmail.com cc: "Kristoffer Haugsbakk" kristofferhaugsbakk@fastmail.com cc: Phillip Wood phillip.wood123@gmail.com cc: Nico Williams nico@cryptonector.com cc: Patrick Steinhardt ps@pks.im
Harald Nordgren (2): refactor format_branch_comparison in preparation status: show comparison with push remote tracking branch
remote.c | 183 ++++++++++++++++++++------- t/t6040-tracking-info.sh | 262 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 403 insertions(+), 42 deletions(-)
base-commit: d529f3a197364881746f558e5652f0236131eb86 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2138%2FHaraldNordgren%2Fahead_of_main_status-v21 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2138/HaraldNordgren/ahead_of_main_status-v21 Pull-Request: https://github.com/git/git/pull/2138
Range-diff vs v20:
1: bb3e00863b ! 1: ce1f1eebb5 refactor format_branch_comparison in preparation
@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
+ enum ahead_behind_flags abf,
+ int show_divergence_advice)
+{
-+ int ours, theirs, sti;
++ int ours, theirs, cmp_fetch;
+ const char *full_base;
+ char *base;
+ int upstream_is_gone = 0;
+
-+ sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
-+ if (sti < 0) {
++ cmp_fetch = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
++ if (cmp_fetch < 0) {
+ if (!full_base)
+ return 0;
+ upstream_is_gone = 1;
@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
+ strbuf_addstr(sb,
+ _(" (use \"git branch --unset-upstream\" to fixup)\n"));
+ } else {
-+ format_branch_comparison(sb, !sti, ours, theirs, base, abf, show_divergence_advice);
++ format_branch_comparison(sb, !cmp_fetch, ours, theirs, base, abf, show_divergence_advice);
+ }
+
free(base);
2: 050197eac3 ! 2: 51d8486fe0 status: show comparison with push remote tracking branch
@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
char *base;
int upstream_is_gone = 0;
+ unsigned base_branch_modes = BRANCH_MODE_PULL | BRANCH_MODE_PUSH;
-+ int push_ours, push_theirs, push_sti;
++ int push_ours, push_theirs, push_cmp_fetch;
+ char *full_push = NULL;
+ char *push = NULL;
+ unsigned push_branch_modes = 0;
- sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
- if (sti < 0) {
+ cmp_fetch = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
+ if (cmp_fetch < 0) {
@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
base = refs_shorten_unambiguous_ref(get_main_ref_store(the_repository),
full_base, 0);
+ push = get_remote_push_branch(branch, &full_push);
+ if (push && strcmp(base, push)) {
-+ push_sti = stat_branch_pair(branch->refname, full_push,
++ push_cmp_fetch = stat_branch_pair(branch->refname, full_push,
+ &push_ours, &push_theirs, abf);
-+ if (push_sti >= 0) {
++ if (push_cmp_fetch >= 0) {
+ base_branch_modes = BRANCH_MODE_PULL;
+ push_branch_modes = BRANCH_MODE_PUSH;
+ }
@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
strbuf_addstr(sb,
_(" (use \"git branch --unset-upstream\" to fixup)\n"));
} else {
-- format_branch_comparison(sb, !sti, ours, theirs, base, abf, show_divergence_advice);
-+ format_branch_comparison(sb, !sti, ours, theirs, base, abf,
+- format_branch_comparison(sb, !cmp_fetch, ours, theirs, base, abf, show_divergence_advice);
++ format_branch_comparison(sb, !cmp_fetch, ours, theirs, base, abf,
+ base_branch_modes, show_divergence_advice);
+ }
+
+ if (push_branch_modes & BRANCH_MODE_PUSH) {
+ strbuf_addstr(sb, "\n");
-+ format_branch_comparison(sb, !push_sti, push_ours, push_theirs, push, abf,
++ format_branch_comparison(sb, !push_cmp_fetch, push_ours, push_theirs, push, abf,
+ push_branch_modes, show_divergence_advice);
}
-- gitgitgadget