threads / discuss / 55283

git branch: filtering by formatted ref when using --format and --list flags

Subject: git branch: filtering by formatted ref when using --format and --list flags

## tl;dr

One message between Mar 10, 2021 and Mar 10, 2021.

replies: 0people: 1as markdown or json

Aaron Lipman· Mar 10, 2021, 13:36 UTC · lore

A few days ago, I wanted to list my branches on a remote. (By "my branches", I mean branches whose head commit I authored.) The first command I tried was:

git branch -r --format '%(refname:short) %(authoremail)' \
              --list '*aaron@example.com*'

However, the --list flag only applies filtering using plain refname, not custom-formatted refs. So I just used grep:

git branch -r --format '%(refname:short) %(authoremail)' |
  grep 'aaron@example.com'

Even though grep works fine, I'd find it convenient for git branch/tag to filter formatted refs when passed both --format and --list flags. I have a patch series implementing this, but before I polish my work to get it submission ready, I wanted to check whether others feel this is a worthwhile change. Feedback welcome.

← back to recent threads