From: Taylor Blau <me@ttaylorr.com>
To: Bence Ferdinandy <bence@ferdinandy.com>
Cc: Jeff King <peff@peff.net>,
Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
git@vger.kernel.org
Subject: Re: [RFC PATCH] object-name: add @{upstreamhead} shorthand
Date: Sun, 27 Oct 2024 19:45:21 -0400 [thread overview]
Message-ID: <Zx7QkaQ5IKxQFskK@nand.local> (raw)
In-Reply-To: <D56XI8GBH2GF.3MP02MGQGP5M@ferdinandy.com>
On Sun, Oct 27, 2024 at 11:07:07PM +0100, Bence Ferdinandy wrote:
>
> On Fri Oct 25, 2024 at 08:24, Jeff King <peff@peff.net> wrote:
> > On Thu, Oct 24, 2024 at 08:48:29PM +0200, Bence Ferdinandy wrote:
> >
> >> > So I think rather than "branch --show-current-remote", we'd want
> >> > some option to make "branch --list" show only the currently checked out
> >> > branch, and then you could apply --format to it to get whatever
> >> > information you wanted. Something like:
> >> >
> >> > git branch --list --is-head --format='%(upstream:remotename)'
> >>
> >> Thanks for running through this in such detail! This would be more widely
> >> useful for sure.
> >>
> >> I'd probably call the flag something like "--current", "--current-only" rather
> >> than "--is-head" though. "--is-head" sounds as if it would filter --list but
> >> not necessarily end up with a single entry.
> >
> > Yeah, I think --current would be fine.
>
> I was looking through git branch and there is a --show-current option. I was
> wondering, would it not be better to teach --show-current to also obey
> --format? It would avoid having a "--current" that only works with "--list"
> besides having a "--show-current".
Yeah, I think that supporting '--format' specifiers via 'git branch
--show-current' makes sense.
In the interim you could do something gross like:
git branch --list --format='%(upstream:remotename)' \
--end-of-options "$(git branch --show-current)"
, but... yuck :-).
I think the right thing to do would be to teach 'git branch
--show-current' to support the full range of --format specifiers. And I
think the way to do that would be to treat --show-current as a special
case of --list.
In the existing implementation, we special-case handling the current
branch with --show-current via a separate code path in
builtin/branch.c::show_current_branch_name().
It would be nice to change the implementation there to pretend as if
the current branch as the pattern given to --list instead of handling
printing it out separately.
I think that would be a nice small-ish project for anybody looking to
get their hands dirty in the 'branch' builtin's implementation.
Thanks,
Taylor
next prev parent reply other threads:[~2024-10-27 23:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-20 20:24 [RFC PATCH] object-name: add @{upstreamhead} shorthand Bence Ferdinandy
2024-10-20 20:40 ` Kristoffer Haugsbakk
2024-10-20 21:42 ` Bence Ferdinandy
2024-10-21 19:14 ` Jeff King
2024-10-21 20:09 ` Bence Ferdinandy
2024-10-21 20:35 ` Taylor Blau
2024-10-23 21:56 ` Jeff King
2024-10-24 18:48 ` Bence Ferdinandy
2024-10-25 6:24 ` Jeff King
2024-10-27 22:07 ` Bence Ferdinandy
2024-10-27 23:45 ` Taylor Blau [this message]
2024-10-28 5:33 ` Jeff King
2024-10-21 19:45 ` Taylor Blau
2024-10-21 20:11 ` Bence Ferdinandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zx7QkaQ5IKxQFskK@nand.local \
--to=me@ttaylorr.com \
--cc=bence@ferdinandy.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).