From: "Bence Ferdinandy" <bence@ferdinandy.com>
To: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>,
<git@vger.kernel.org>
Subject: Re: [RFC PATCH] object-name: add @{upstreamhead} shorthand
Date: Sun, 20 Oct 2024 23:42:38 +0200 [thread overview]
Message-ID: <D50YLOBHJTLS.367TMAOLKL019@ferdinandy.com> (raw)
In-Reply-To: <1c056d39-950c-4965-89d6-85f0c2c1bccd@app.fastmail.com>
On Sun Oct 20, 2024 at 22:40, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:
> Good evening
>
> On Sun, Oct 20, 2024, at 22:24, Bence Ferdinandy wrote:
>> The HEAD of the remote is useful in many situations, but currently one
>> would need to know the name of the remote to perform something like
>> "git log origin/HEAD..", which makes writing remote agnostic aliases
>> complicated. Introduce the new shorthand "@{upstreamhead}" which returns
>> <remote>/HEAD for the same <remote> "@{upstream}" would yield.
>>
>> Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
>> ---
>>
>> Notes:
>> RFC v1: Testing and documentation is completely missing, I'll add those
>> in a v2 if people think the patch has merit.
>
> Do you have some concrete examples? I’m not well versed in using
> remote HEAD.
N.b. I was intending to write s/many situations/some situations.
I basically use it for two things:
- variations of `git log remote/HEAD..` for which I currently have an alias
with "origin" hardcoded. E.g. I'm on a feature branch I'm reviewing and
I want to know what commits are new compared to origin/(master|main|trunk),
but I use HEAD, because I never know (and don't really want to pay attention
to) what project uses what. And although "origin" is usually ok, but not
always if there are forks in play, so @{upstreamhead} would make it agnostic
to the remote's name.
- I also use remote/HEAD in CICD, i.e. with `git rev-list origin/HEAD..` you
can run checks on a commit-by-commit bases instead of the end result of
a patch series or pull request. It's really useful to check have basic checks
for commit messages for example. In a CICD of course for a _specific_ project
you know what HEAD is, but still, using HEAD makes a step portable across
repos. And again of course, I think in CICD you almost certainly will always
end up with the remote being called "origin", so this change might not be
quite so useful there.
But so the long story short here is that for
(origin|upstream)/(master|main|trunk) we can already have agnostic code with
HEAD for the second part and with a patch like this we could have agnostic code
for the whole thing.
Best,
Bence
--
bence.ferdinandy.com
next prev parent reply other threads:[~2024-10-20 21:43 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 [this message]
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
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=D50YLOBHJTLS.367TMAOLKL019@ferdinandy.com \
--to=bence@ferdinandy.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
/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).