From: Junio C Hamano Date: Mon, 06 Mar 2023 18:48:45 GMT Subject: Re: [PATCH 1/8] ahead-behind: create empty builtin Message-ID: In-Reply-To: <0fd18b6d740f1e8a6f62a25947bc3ad49c2674a6.1678111599.git.gitgitgadget@gmail.com> "Derrick Stolee via GitGitGadget" 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?