git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] remote: qualify "git pull" advice for non-upstream compareBranches

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2026, 15:48 UTC
Message-ID
<xmqq7bo6xuok.fsf@gitster.g>
In-Reply-To
<pull.2301.v4.git.git.1779372367317.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 17 quoted lines
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> Enable ENABLE_ADVICE_PULL for push-branch comparisons too, not just
> the upstream entry, so the "use git pull" hint prints when the local
> branch is behind its push branch.
>
> Spell out "git pull <remote> <branch>" so running the suggested
> command actually pulls the ref the user was told about; plain
> "git pull" would fetch the upstream instead.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
>     remote: qualify "git pull" advice for non-upstream branches
>     
>      * Don't suggest git pull when we have no good command to suggest.
>      * New test for this. Asserts the behind line shows with no follow-up
>        advice.
Very well written.  

What does not happen in the "punt" case (the first bullet point above) may deserve to be given in the commit log message, but otherwise it is very clear what the change wanted to do to the future readers of "git log".

>  remote.c                 |  48 +++++++++++++++----
>  t/t6040-tracking-info.sh | 100 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 140 insertions(+), 8 deletions(-)

The code changes look correct, and the new tests checks the new suggestion as well as the "punt" case, which is good.

Shall we mark it for 'next' now?
Thanks for working on this.
Show 30 quoted lines
>> diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
> index 0242b5bf7a..91cbb8775d 100755
> --- a/t/t6040-tracking-info.sh
> +++ b/t/t6040-tracking-info.sh
> @@ -646,4 +646,104 @@ test_expect_success 'status.compareBranches with remapped push and upstream remo
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'status.compareBranches behind both upstream and push' '
> +	test_config -C test push.default current &&
> +	test_config -C test remote.pushDefault origin &&
> +	test_config -C test status.compareBranches "@{upstream} @{push}" &&
> +	git -C test checkout -b feature13 upstream/main &&
> +	(cd test && advance work13) &&
> +	git -C test push origin &&
> +	git -C test branch --set-upstream-to upstream/ahead &&
> +	git -C test reset --hard HEAD^ &&
> +	git -C test status >actual &&
> +	cat >expect <<-EOF &&
> +	On branch feature13
> +	Your branch is behind ${SQ}upstream/ahead${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull" to update your local branch)
> +
> +	Your branch is behind ${SQ}origin/feature13${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull origin feature13" to update your local branch)
> +
> +	nothing to commit, working tree clean
> +	EOF
> +	test_cmp expect actual
> +'
A good test that clearly shows how @{push} is described ;-)
Show 18 quoted lines
> +test_expect_success 'status.compareBranches with remapped push and behind push branch' '
> +	test_config -C test remote.pushDefault origin &&
> +	test_config -C test remote.origin.push refs/heads/feature14:refs/heads/remapped14 &&
> +	test_config -C test status.compareBranches "@{push}" &&
> +	git -C test checkout -b feature14 upstream/main &&
> +	(cd test && advance work14) &&
> +	git -C test push &&
> +	git -C test reset --hard HEAD^ &&
> +	git -C test status >actual &&
> +	cat >expect <<-EOF &&
> +	On branch feature14
> +	Your branch is behind ${SQ}origin/remapped14${SQ} by 1 commit, and can be fast-forwarded.
> +	  (use "git pull origin remapped14" to update your local branch)
> +
> +	nothing to commit, working tree clean
> +	EOF
> +	test_cmp expect actual
> +'
OK.
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren
Message 8 of 9 in “remote: qualify "git pull" advice for non-upstream branches”
  1. remote: qualify "git pull" advice for non-upstream branchesHarald Nordgren via GitGitGadget, May 12, 2026
  2. remote: qualify "git pull" advice for non-upstream branchesHarald Nordgren via GitGitGadget, May 13, 2026
  3. Junio C HamanoMay 19, 2026
  4. Harald NordgrenMay 20, 2026
  5. remote: qualify "git pull" advice for non-upstream compareBranchesHarald Nordgren via GitGitGadget, May 20, 2026
  6. Junio C HamanoMay 21, 2026
  7. remote: qualify "git pull" advice for non-upstream compareBranchesHarald Nordgren via GitGitGadget, May 21, 2026
  8. Junio C HamanoJun 10, 2026
  9. Harald NordgrenJun 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.