git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] object-name: add @{upstreamhead} shorthand

From
Bence Ferdinandy <bence@ferdinandy.com>
Date
Oct 20, 2024, 21:42 UTC
Message-ID
<D50YLOBHJTLS.367TMAOLKL019@ferdinandy.com>
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:
Show 18 quoted lines
> 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
Previous: Kristoffer HaugsbakkNext: Jeff King
Message 3 of 14 in “object-name: add @{upstreamhead} shorthand”
  1. object-name: add @{upstreamhead} shorthandBence Ferdinandy, Oct 20, 2024
  2. Kristoffer HaugsbakkOct 20, 2024
  3. Bence FerdinandyOct 20, 2024
  4. Jeff KingOct 21, 2024
  5. Bence FerdinandyOct 21, 2024
  6. Taylor BlauOct 21, 2024
  7. Jeff KingOct 23, 2024
  8. Bence FerdinandyOct 24, 2024
  9. Jeff KingOct 25, 2024
  10. Bence FerdinandyOct 27, 2024
  11. Taylor BlauOct 27, 2024
  12. Jeff KingOct 28, 2024
  13. Taylor BlauOct 21, 2024
  14. Bence FerdinandyOct 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.