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

Bug sorting git branch output by ahead-behind:HEAD

From
RGRoss Goldberg <ross.goldberg@gmail.com>
Date
Jan 5, 2025, 09:48 UTC
Message-ID
<CAAEcvMovcZucuq4H70ouQzKS=_wHnBi1DqJ-4MMFVXX9XLEciw@mail.gmail.com>
Bug sorting git branch output by ahead-behind:HEAD
What did you do before the bug happened? (Steps to reproduce your issue)

$ git branch --format '%(refname:short) %(ahead-behind:HEAD)' (HEAD detached at 6aab6bfe) 0 0 190-json 1 6 560-swupd 3 6 667-reset-no-process 2 6 678-completions 2 0 693-readme-accordions 3 6 705-branch-in-version 2 6 main 0 6

$ git branch --format '%(refname:short) %(ahead-behind:HEAD)' --sort 'ahead-behind:HEAD' (HEAD detached at 6aab6bfe) 190-json 560-swupd 667-reset-no-process 678-completions 693-readme-accordions 705-branch-in-version main

What did you expect to happen? (Expected behavior)
I expected the second command's output to:
- include the value of `ahead-behind:HEAD` on each line
- have been sorted by each line's value of `ahead-behind:HEAD`
What happened instead? (Actual behavior)
Second command's output missing `ahead-behind:HEAD` & sorted by `refname`
What's different between what you expected and what actually happened?
Fields missing from second command's output
Incorrect sorting of second command's output lines
Anything else you want to add:
If I sort by the `objectsize` field:
- all requested fields are output
- sorting works (except `(HEAD detached at 6aab6bfe)` is always listed first)

If I do not include `%(ahead-behind:HEAD)` in the format string, sorting by `ahead-behind:HEAD` still doesn't work.

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.47.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon libcurl: 7.79.1 zlib: 1.2.11 uname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE_X86_64 x86_64 compiler info: clang: 14.0.0 (clang-1400.0.29.202) libc info: no libc information available $SHELL (typically, interactive shell): /usr/local/bin/zsh

[Enabled Hooks]
Next: René Scharfe
Message 1 of 19 in “Bug sorting git branch output by ahead-behind:HEAD”
  1. Ross GoldbergJan 5, 2025
  2. ref-filter: share bases and is_base_tips between formatting and sortingRené Scharfe, Jan 12, 2025
  3. Jeff KingJan 13, 2025
  4. Jeff KingJan 13, 2025
  5. Junio C HamanoJan 13, 2025
  6. René ScharfeJan 14, 2025
  7. Jeff KingJan 16, 2025
  8. Jeff KingJan 16, 2025
  9. Jeff KingJan 16, 2025
  10. Junio C HamanoJan 16, 2025
  11. René ScharfeJan 18, 2025
  12. René ScharfeJan 19, 2025
  13. René ScharfeJan 19, 2025
  14. René ScharfeJan 19, 2025
  15. Jeff KingJan 19, 2025
  16. René ScharfeJan 18, 2025
  17. 1/3 ref-filter: move ahead-behind bases into used_atomRené Scharfe, Jan 18, 2025
  18. 3/3 ref-filter: remove ref_format_clear()René Scharfe, Jan 18, 2025
  19. 2/3 ref-filter: move is-base tip to used_atomRené Scharfe, Jan 18, 2025

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.