git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* changed output in git branch -a
@ 2025-06-30 10:23 Olaf Hering
  2025-06-30 11:13 ` Kristoffer Haugsbakk
  2025-06-30 13:31 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Olaf Hering @ 2025-06-30 10:23 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

Hello,

my dumb script parses the output of "git --git-dir=some/dir/.git branch -a".
With git 2.43 it gets the expected list of "remote/branch".
With git 2.50 it also gets something like "remote/HEAD -> remote/branch".

The newer version runs on a different system. It might be that the repository
was already cloned with a different format. For some reason it does have
.git/refs/remotes/${remote}/HEAD, but the system with the older git lacks
that entry.

Is there a way to suppress such lines, or do I need to filter them manually?
There is no obvious knob mentioned in git-branch(1).


Thanks,
Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: changed output in git branch -a
  2025-06-30 10:23 changed output in git branch -a Olaf Hering
@ 2025-06-30 11:13 ` Kristoffer Haugsbakk
  2025-06-30 13:31 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Kristoffer Haugsbakk @ 2025-06-30 11:13 UTC (permalink / raw)
  To: Olaf Hering, git

On Mon, Jun 30, 2025, at 12:23, Olaf Hering wrote:
> Hello,
>
> my dumb script parses the output of "git --git-dir=some/dir/.git branch -a".
> With git 2.43 it gets the expected list of "remote/branch".
> With git 2.50 it also gets something like "remote/HEAD -> remote/branch".
>
> The newer version runs on a different system. It might be that the repository
> was already cloned with a different format. For some reason it does have
> .git/refs/remotes/${remote}/HEAD, but the system with the older git lacks
> that entry.
>
> Is there a way to suppress such lines, or do I need to filter them manually?
> There is no obvious knob mentioned in git-branch(1).

Can you use something like

    git for-each-ref --format='%(refname:short)' --exclude='**/HEAD'

Instead?  The output of this f-e-r command is stable.

-- 
Kristoffer Haugsbakk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: changed output in git branch -a
  2025-06-30 10:23 changed output in git branch -a Olaf Hering
  2025-06-30 11:13 ` Kristoffer Haugsbakk
@ 2025-06-30 13:31 ` Junio C Hamano
  2025-06-30 14:19   ` Olaf Hering
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2025-06-30 13:31 UTC (permalink / raw)
  To: Olaf Hering; +Cc: git

Olaf Hering <olaf@aepfle.de> writes:

> my dumb script parses the output of "git --git-dir=some/dir/.git branch -a".
> With git 2.43 it gets the expected list of "remote/branch".
> With git 2.50 it also gets something like "remote/HEAD -> remote/branch".
>
> The newer version runs on a different system. It might be that the repository
> was already cloned with a different format. For some reason it does have
> .git/refs/remotes/${remote}/HEAD, but the system with the older git lacks
> that entry.

I somehow do not think this is a version difference.  Assuming that
your default remote is called "origin", I suspect that you have
refs/remotes/origin/HEAD symbolic ref in the repository you use with
Git 2.50, while in the other repository you do not.  Both versions
are capable of showing that symbolic ref information.

You can try in the repository where you use Git 2.43

    $ git remote set-head origin -a
    $ git branch -a

to see if the difference indeed is coming from different versions.


> Is there a way to suppress such lines, or do I need to filter them manually?
> There is no obvious knob mentioned in git-branch(1).

Scripts should be reading "git for-each-ref" output in the first
place. Output from "git branch" is meant for human consumption and
is subject to change any time (even though in this case I suspect it
has not changed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: changed output in git branch -a
  2025-06-30 13:31 ` Junio C Hamano
@ 2025-06-30 14:19   ` Olaf Hering
  0 siblings, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2025-06-30 14:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

Mon, 30 Jun 2025 06:31:29 -0700 Junio C Hamano <gitster@pobox.com>:

> You can try in the repository where you use Git 2.43
>     $ git remote set-head origin -a
>     $ git branch -a
> to see if the difference indeed is coming from different versions.

Thanks, it does not depend on the version. For some reason the repository
on the system with the older git had no default branch set. The repository
was cloned a long time ago, maybe default branches were never set initially.

I changed my script to use for-each-ref.


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-30 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 10:23 changed output in git branch -a Olaf Hering
2025-06-30 11:13 ` Kristoffer Haugsbakk
2025-06-30 13:31 ` Junio C Hamano
2025-06-30 14:19   ` Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).