From: Phillip Wood <phillip.wood123@gmail.com>
To: Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH] status: compare against both upstream and push branch by default
Date: Tue, 20 Oct 2026 10:33:42 +0100 [thread overview]
Message-ID: <5030377b-58c8-4193-8d72-79955082269f@gmail.com> (raw)
In-Reply-To: <pull.2458.git.git.1792437798463.gitgitgadget@gmail.com>
Hi Harald
On 19/10/2026 20:23, Harald Nordgren via GitGitGadget wrote:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> In a triangular workflow, where a branch is pulled from one place and
> pushed to another, "git status" only compares the branch to its
> upstream. It says nothing about the branch it is pushed to unless
> status.compareBranches is configured.
>
> Show both comparisons by default. When the two resolve to the same
> branch, which is the common case, only one comparison is shown, so the
> output for most users does not change. Setting status.compareBranches
> to "@{upstream}" gives the previous output.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
> status: compare against both upstream and push branch by default
>
> Make @{upstream} @{push} the default for status.compareBranches. When
> both resolve to the same branch only one comparison is shown, so most
> users see no change.
If you want to change the default value of a config variable it is
helpful to explain why the current default was chosen as well as why you
think the new default is better. In this case wasn't there some
discussion about the default value when the variable was introduced?
Providing that context would make it much easier for people to judge if
this change is a good idea.
Thanks
Phillip
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2458%2FHaraldNordgren%2Fstatus-compare-branches-default-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2458/HaraldNordgren/status-compare-branches-default-v1
> Pull-Request: https://github.com/git/git/pull/2458
>
> Documentation/config/status.adoc | 11 ++++++-----
> remote.c | 1 +
> t/t5505-remote.sh | 1 -
> t/t6040-tracking-info.sh | 30 +++++++++++++++---------------
> 4 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/Documentation/config/status.adoc b/Documentation/config/status.adoc
> index b5dd85b761..1d847d3a8a 100644
> --- a/Documentation/config/status.adoc
> +++ b/Documentation/config/status.adoc
> @@ -23,8 +23,9 @@ status.compareBranches::
> are supported. They are interpreted as `branch@{upstream}` and
> `branch@{push}` for the current branch.
> +
> -If not set, the default behavior is equivalent to `@{upstream}`, which
> -compares against the configured upstream tracking branch.
> +If not set, the default behavior is equivalent to `@{upstream} @{push}`,
> +which compares against both the configured upstream and push tracking
> +branches.
> +
> The entries are shown in the order they appear in the configuration.
> Duplicate entries that resolve to the same ref are suppressed after
> @@ -36,11 +37,11 @@ Example:
> +
> ----
> [status]
> - compareBranches = @{upstream} @{push}
> + compareBranches = @{upstream}
> ----
> +
> -This would show comparisons against both the configured upstream and push
> -tracking branches for the current branch.
> +This would only show the comparison against the configured upstream
> +tracking branch for the current branch.
>
> status.displayCommentPrefix::
> If set to true, linkgit:git-status[1] will insert a comment
> diff --git a/remote.c b/remote.c
> index 71170f36a9..6fdb4b84da 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2465,6 +2465,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
> string_list_remove_empty_items(&branches, 0);
> } else {
> string_list_append(&branches, "@{upstream}");
> + string_list_append(&branches, "@{push}");
> }
>
> upstream_ref = branch_get_upstream(branch, NULL);
> diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
> index 5fbfcb0848..f77753605f 100755
> --- a/t/t5505-remote.sh
> +++ b/t/t5505-remote.sh
> @@ -34,7 +34,6 @@ setup_url_pushremote () {
> git checkout -b topic --track origin/main &&
> git commit --allow-empty -m topic-change &&
> git config push.default current &&
> - git config status.compareBranches "@{upstream} @{push}" &&
> git config branch.topic.pushRemote "$fork_url" &&
> git push
> )
> diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
> index e95d420972..e10cde090d 100755
> --- a/t/t6040-tracking-info.sh
> +++ b/t/t6040-tracking-info.sh
> @@ -331,19 +331,6 @@ test_expect_success 'status.compareBranches deduplicates when upstream and push
> test_cmp expect actual
> '
>
> -test_expect_success 'status.compareBranches with only upstream shows only upstream' '
> - test_config -C test status.compareBranches "@{upstream}" &&
> - git -C test checkout main &&
> - git -C test status >actual &&
> - cat >expect <<-EOF &&
> - On branch main
> - Your branch is up to date with ${SQ}origin/main${SQ}.
> -
> - nothing to commit, working tree clean
> - EOF
> - test_cmp expect actual
> -'
> -
> test_expect_success 'status.compareBranches with only push shows only push' '
> test_config -C test push.default current &&
> test_config -C test status.compareBranches "@{push}" &&
> @@ -361,9 +348,8 @@ test_expect_success 'status.compareBranches with only push shows only push' '
> test_cmp expect actual
> '
>
> -test_expect_success 'status.compareBranches shows ahead of both upstream and push branch' '
> +test_expect_success 'status shows ahead of both upstream and push branch by default' '
> test_config -C test push.default current &&
> - test_config -C test status.compareBranches "@{upstream} @{push}" &&
> git -C test checkout -b feature3 origin/main &&
> git -C test push origin HEAD &&
> (cd test && advance work) &&
> @@ -380,6 +366,20 @@ test_expect_success 'status.compareBranches shows ahead of both upstream and pus
> test_cmp expect actual
> '
>
> +test_expect_success 'status.compareBranches with only upstream shows only upstream' '
> + test_config -C test push.default current &&
> + test_config -C test status.compareBranches "@{upstream}" &&
> + git -C test checkout feature3 &&
> + git -C test status >actual &&
> + cat >expect <<-EOF &&
> + On branch feature3
> + Your branch is ahead of ${SQ}origin/main${SQ} by 1 commit.
> +
> + nothing to commit, working tree clean
> + EOF
> + test_cmp expect actual
> +'
> +
> test_expect_success 'checkout with status.compareBranches shows both branches' '
> test_config -C test push.default current &&
> test_config -C test status.compareBranches "@{upstream} @{push}" &&
>
> base-commit: c51408889c3b372814bc20b9431c3b74d0d268eb
next prev parent reply other threads:[~2026-10-20 9:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 19:23 [PATCH] status: compare against both upstream and push branch by default Harald Nordgren via GitGitGadget
2026-10-19 22:54 ` Junio C Hamano
2026-10-20 9:16 ` Harald Nordgren
2026-10-20 9:33 ` Phillip Wood [this message]
2026-10-20 10:19 ` Harald Nordgren
2026-10-20 10:56 ` Kristoffer Haugsbakk
2026-10-20 13:22 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5030377b-58c8-4193-8d72-79955082269f@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox