Oh, I knew that really. 🤦
If a Codeberg repo has a "pages" branch with some HTML pages, they are available as a web site. I have a repo that generates some HTML, so that's a handy feature. One curious side effect us that I have two branches with no files in common and no common ancestor commit.
To regenerate the content of the pages branch and push the changes is a bit of a faff, so I scripted it up and added the script to the main branch. While the script is running, it checks out the pages branch which means that the script no longer exists. Hmm. This is not a problem. Shells on Linux, etc. read a script when it starts. I can run this in Termux on my phone and all is well.
On my laptop, it's Windows, and while I could have run the same shell script in Cygwin, instead I tried writing it as a batch file. It seemed do-able because it's just calling some external commands and checking if they worked. Easy. But when I run it and it checks out the pages branch, that's when things get tricky. The batch file no longer exists. Windows batch files are NOT read at startup. When calling an external command, the command processor just remembers an offset into the file. When it's time to continue the script it can read the next line from there. Or not, in my case.
I've seen this behaviour described as a feature: a running batch file can edit itself! I can't think of a use case for that, but I haven't thought very hard. More likely it's a hangover from DOS machines with so little memory that anything you didn't need to keep meant you could run bigger programs. Hello, 1981, we're still compatible with you!
A workround might be to have two batch files, copy one to temp, and call that.