Subject: Re: [PATCH 1/8] ahead-behind: create empty builtin

From: Junio C Hamano <[email-masked]>
Date: Mon, 06 Mar 2023 10:48:45 -0800

"Derrick Stolee via GitGitGadget" <[email-masked]> writes:

> For example, we will be able to track all local branches relative to an
> upstream branch using an invocation such as
>
>   git for-each-ref --format=%(refname) refs/heads/* |
>     git ahead-behind --base=origin/main --stdin

Stepping back a bit, this motivating example makes me wonder if

 $ git for-each-ref --format='%(refname) %(aheadbehind)' refs/heads/\*

that computes the ahead-behind number for each ref (that matches the
pattern) based on their own "upstream" (presumably each branch is
configured to track the same, or different, upstreams), or
overrriding @{upstream}, a specified base, i.e.

 $ git for-each-ref --format='%(refname) %(aheadbehind:origin/main)' refs/heads/\*

would be a more intuitive interface to the end-users.

It would probably work well in conjunction with

    git for-each-ref --format='%(refname)' --merged origin/main refs/heads/\*

which is a way to list local branches that are already merged into
the upstream, to have the feature appear in the same command,
perhaps?