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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Peff

On 14/11/2023 20:18, Jeff King wrote:
On Tue, Nov 14, 2023 at 03:02:04PM +0000, Phillip Wood wrote:

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.

Oh of course, I'd somehow forgotten that "refs/heads/master" did not exist so it makes sense that for-each-ref does not print anything.

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).

Yeah, maybe we should look at fixing that - I didn't suggest it because I knew it did not work on an unborn branch but as you say there is no obvious reason why it shouldn't

Best Wishes

Phillip

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux