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

Re: [PATCH] status: reword message for a missing upstream branch

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Oct 20, 2026, 07:29 UTC
Message-ID
<20261020072924.42026-1-gitter.spiros@gmail.com>
In-Reply-To
<xmqqzew91i5g.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Ahh, "does not exist".  Clever.  That does cover both cases and
> reads reasonably natural.  If we wanted to have something short that
> we can reuse elsewhere (like inside [] in place of [gone]), we could
> say which is "missing", perhaps.

"missing" sounds good to me for the short form. I'd rather keep it out of this patch, though; see below for why the bracketed label needs a bit more care than the long message.

> Do we emit "git push" suggestion unconditionally (meaning, does "git
> push" immediately in this state always create the "upstream" that
> does not exist yet), or do we have to check if "git push" will
> create it before saying so?

We check, as the next paragraph of the log says: the hint is given only when @{push} resolves to the upstream itself, and push.default is not "matching".

The check errs on the side of not giving the hint. For example, with push.default=matching but an explicit remote.<name>.push refspec, "git push" uses the refspec and would create the upstream, but we still do not suggest it, because push_creates() looks at push.default without checking whether a refspec overrides it. I'll fix that in v2 by checking push.default only when the remote has no push refspec and is not a mirror, which is the same order branch_get_push_1() follows.

> Does this refer to what wt_shortstatus_print_tracking() says?  It is
> _(translated), so in a sense it is a fair game to be improved.

Yes, and you are right, the justification in the log message is wrong for some of the commands it lists. Looking more closely:

 - "git status -sb" uses LABEL(N_("gone")) in
   wt_shortstatus_print_tracking(), so it is translated (e.g.
   "[sparito]" in Italian).
 - "git status --porcelain -b" goes through the same function, but
   wt_porcelain_print() sets s->no_gettext, so it always says
   "[gone]". That one has to stay.
 - "git status --porcelain=v2" never says "gone"; it prints
   "# branch.upstream" and omits the "# branch.ab" line.
 - "%(upstream:track)" in "git for-each-ref" uses the untranslated
   "gone" from ref-filter.c, which is documented in
   git-for-each-ref.adoc, so that one has to stay too. But "git
   branch" (and "git tag") call setup_ref_filter_porcelain_msg(),
   so "git branch -vv" and "git branch --format=%(upstream:track)"
   show the translated label.

So "scripts may depend on it" is true only for --porcelain and for-each-ref. The other two are human-readable output and could be changed.

I am still hesitant to change the label in "git branch -vv" as part of this patch. Translated or not, under LC_ALL=C it says "gone", and

    git branch -vv | grep ': gone]'

is a very common recipe for finding branches whose upstream was pruned. To keep the porcelain output as "gone" while changing the human output, wt_shortstatus_print_tracking() also could not keep using LABEL() with a single msgid.

So for v2 I plan to leave the bracketed label alone and correct the log message to say what is really going on. If we want "[missing]" in "git status -sb" and "git branch -vv", I'd do it as a separate follow-up patch, where we can discuss the compatibility question separately.

Thanks for the review.
Previous: Junio C HamanoNext: Elia Pinto
Message 4 of 14 in “status: reword message for a missing upstream branch”
  1. status: reword message for a missing upstream branchElia Pinto, Oct 19, 2026
  2. Harald NordgrenOct 19, 2026
  3. Junio C HamanoOct 19, 2026
  4. Elia PintoOct 20, 2026
  5. status: reword message for a missing upstream branchElia Pinto, Oct 21, 2026
  6. Elia PintoOct 30, 2026
  7. Elia PintoNov 17, 2026
  8. Harald NordgrenNov 17, 2026
  9. Junio C HamanoNov 17, 2026
  10. Junio C HamanoNov 18, 2026
  11. Elia PintoNov 19, 2026
  12. Junio C HamanoNov 19, 2026
  13. status: reword message for a missing upstream branchElia Pinto, Nov 19, 2026
  14. Junio C HamanoNov 19, 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.