Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Caleb Cushing <xenoterracide@gmail.com>
Cc: Bence Ferdinandy <bence@ferdinandy.com>, git@vger.kernel.org
Subject: Re: git remote set-head automatically
Date: Tue, 19 Nov 2024 13:44:04 -0500	[thread overview]
Message-ID: <20241119184404.GA15723@coredump.intra.peff.net> (raw)
In-Reply-To: <CAAHKNRF4AnvceiTDLdpNS94yRnoZYMSD0Wkg7V+4YBwSej7NSA@mail.gmail.com>

On Tue, Nov 19, 2024 at 12:06:21PM -0500, Caleb Cushing wrote:

> 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

  reply	other threads:[~2024-11-19 18:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 14:34 git remote set-head automatically Caleb Cushing
2024-11-16  3:36 ` Jeff King
2024-11-16 15:01   ` Bence Ferdinandy
2024-11-19 15:40     ` Caleb Cushing
2024-11-19 17:06       ` Caleb Cushing
2024-11-19 18:44         ` Jeff King [this message]
2024-11-20  1:10       ` Junio C Hamano
2024-11-20  1:17       ` Junio C Hamano
2024-11-20  8:58         ` Bence Ferdinandy
2025-01-12  8:19       ` 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=20241119184404.GA15723@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=bence@ferdinandy.com \
    --cc=git@vger.kernel.org \
    --cc=xenoterracide@gmail.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