mumrah commented on PR #17204:
URL: https://github.com/apache/kafka/pull/17204#issuecomment-2368526553
@fonsdant, just updating the ref on the remote (GitHub) would indeed work.
In Git, a ref is simply a text file with a SHA in it. Conventionally, tags
are immutable since they are typically used to refer to a point in the history
(like a release), but as you know we can update them with the --force flag.
A branch is actually just a ref as well. In the .git/refs directory, the
branch refs are in the "heads" directory. On a fresh clone of Kafka, we see:
```
.git/refs
.git/refs/heads
.git/refs/heads/trunk
.git/refs/tags
.git/refs/remotes
.git/refs/remotes/origin
.git/refs/remotes/origin/HEAD
```
(note that other branches/tags are compacted into a "packed_refs" file)
The file `.git/refs/heads/trunk` contains the SHA of trunk's HEAD commit at
the time I fetched it. When I later do "git fetch", the commit objects will be
updated (they are stored elsewhere) and the `.git/refs/heads/trunk` file will
be overwritten with the new SHA for `trunk`.
> So, a ref seems to be a great option. It acts as an "alias" for the cached
commit and can be updated to point to a new cached commit.
You've described a branch :)
---
Looking at the "creating a ref" example from the API docs:
```
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/git/refs \
-f "ref=refs/heads/featureA" -f
"sha=aa218f56b14c9653891f9e74264a383fa43fefbd"
```
we can see they are actually creating "refs/heads/featureA" which is a
branch.
The approach we were taking using checkout/switch and merge was really just
a roundabout way of updating the `.git/refs/heads/trunk-cached` file.
If we use the API to update the "heads/trunk-cached" ref with force=true, I
think we will accomplish our goal.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]