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

Re: Feature request: git status --branch-only

From
Jeff King <peff@peff.net>
Date
Nov 14, 2023, 20:18 UTC
Message-ID
<20231114201808.GE2092538@coredump.intra.peff.net>
In-Reply-To
<00033c86-dbd7-4c88-bfbd-8f6766cd66c9@gmail.com>
On Tue, Nov 14, 2023 at 03:02:04PM +0000, Phillip Wood wrote:
Show 18 quoted lines
> Hi Ondra
> 
> On 14/11/2023 12:40, Ondra Medek wrote:
> > Hi Phillip,
> > 
> > it does not work for a fresh clone of an empty repository
> > 
> >      git for-each-ref --format="%(upstream:short)" refs/heads/master
> > 
> > outputs nothing, while
> 
> Oh dear, that's a shame. I wonder if it is a bug because the documentation
> says that
> 
> 	--format="%(upstream:track)"
> 
> should print "[gone]" whenever an unknown upstream ref is encountered but
> trying that on a clone of an empty repository gives no output.

I think it would print "gone" if the upstream branch went missing. But in this case the actual local branch is missing. And for-each-ref will not show an entry at all for a ref that does not exist. The "refs/heads/master" on your command line is not a ref, but a pattern, and that pattern does not match anything. So it's working as intended.

I think a more direct tool would be:
  git rev-parse --symbolic-full-name master@{upstream}

That convinces branch_get_upstream() to return the value we want, but sadly it seems to get lost somewhere in the resolution process, and we spit out an error. Arguably that is a bug (with --symbolic or --symbolic-full-name, I think it would be OK to resolve names even if they don't point to something, but it's possible that would have other unexpected side effects).

-Peff
Previous: Ondra MedekNext: phillip.wood123@gmail.com
Message 6 of 7 in “Feature request: git status --branch-only”
  1. Ondra MedekNov 14, 2023
  2. Phillip WoodNov 14, 2023
  3. Ondra MedekNov 14, 2023
  4. Phillip WoodNov 14, 2023
  5. Ondra MedekNov 14, 2023
  6. Jeff KingNov 14, 2023
  7. phillip.wood123@gmail.comNov 16, 2023

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.