Re: [PATCH 7/8] refs: add 'update-symref' command to 'update-ref'
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Apr 1, 2024, 10:38 UTC
- Message-ID
- <CAOLa=ZRiTVGs9k5O0+RcNSnu=yyVVS8F2TF+VZOtPGg6EaDDLQ@mail.gmail.com>
- In-Reply-To
- <CAPx1GvdXdH3OdY1nC2ijVSdpWfg8jn5=j0KB+Wgv70wWeCNH5g@mail.gmail.com>
Chris Torek <chris.torek@gmail.com> writes:
Show 13 quoted lines
> Meanwhile, for testing purposes I was curious as to what happens > if you ask `git update-ref` to delete an existing symref, so after > creating a test repository: > > $ git branch > * main > symref -> main > $ git update-ref --stdin > delete refs/heads/symref > $ git branch > > Whoops, this doesn't look good... >
This is expected though. Remember that `git-update-ref(1)` by default does dereferencing of symlinks. So in your case, 'refs/heads/symref' is dereferenced to 'refs/heads/main' and when a delete command is issued, 'main' is deleted.
Try the same with the `git update-ref --no-deref --stdin` instead.
Show 11 quoted lines
> Restoring the branch name (I had saved the hash ID Just In Case): > > $ echo d88ee82e6a5c29c95f712030f5efc9d43116ae79 > .git/refs/heads/main > > brings things back, after which this works properly: > > $ git branch -d symref > Deleted branch symref (was refs/heads/main). > $ git branch > * main >
Here you switch to using 'git-branch(1)' and that doesn't dereference by default. So there is a difference in the two attempts.