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

Re: git remote set-head automatically

From
Jeff King <peff@peff.net>
Date
Nov 19, 2024, 18:44 UTC
Message-ID
<20241119184404.GA15723@coredump.intra.peff.net>
In-Reply-To
<CAAHKNRF4AnvceiTDLdpNS94yRnoZYMSD0Wkg7V+4YBwSej7NSA@mail.gmail.com>
On Tue, Nov 19, 2024 at 12:06:21PM -0500, Caleb Cushing wrote:
Show 10 quoted lines
> A little more progress on what I'm going to have to do, github action,
> without set-head the ref/HEAD isn't present
> 
> - uses: actions/checkout@v4
>   with:
>     ref: ${{ github.event.workflow_run.head_branch}}
>     filter: "blob:none"
>     fetch-depth: 0
> - run: git remote set-head origin --auto # fixes otherwise the cat
> will not find a file

We do create the HEAD symref in clone by default, but IIRC actions/checkout does a more limited clone with --depth and --single-branch.

The separate set-head should work, but it is a shame that it will have to hit the server for a second request.

You might look for options in actions/checkout to change the way it invokes Git. Though I suspect there might not be a way to trigger git-clone to do a single-branch clone _and_ create the HEAD symref. So you may be stuck with the two calls.

> - run: cat .git/refs/remotes/origin/HEAD

Don't access the file directly; it will break if the ref storage format changes. Use "git symbolic-ref refs/remotes/origin/HEAD" instead.

(Not sure if this was just illustrative or what you are planning to do in a real CI job).

-Peff
Previous: Caleb CushingNext: Junio C Hamano
Message 6 of 10 in “git remote set-head automatically”
  1. Caleb CushingNov 15, 2024
  2. Jeff KingNov 16, 2024
  3. Bence FerdinandyNov 16, 2024
  4. Caleb CushingNov 19, 2024
  5. Caleb CushingNov 19, 2024
  6. Jeff KingNov 19, 2024
  7. Junio C HamanoNov 20, 2024
  8. Junio C HamanoNov 20, 2024
  9. Bence FerdinandyNov 20, 2024
  10. Bence FerdinandyJan 12, 2025

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.