fix(lib): use git symbolic-ref instead of branch -m for empty repos

Fix: #8538

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kovan 2026-02-13 16:35:30 +01:00 committed by Henrik Lissner
parent 09a0f36144
commit 7902c08729

View file

@ -111,7 +111,11 @@ package's name as a symbol, and whose CDR is the plist supplied to its
(make-directory repo-dir 'recursive)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "branch" "-m" straight-repository-branch)
;; HACK: `git branch -m' fails on empty repos with git
;; < 2.28. `git symbolic-ref' is a portable alternative
;; that works on all git versions. See #8538.
(funcall call "git" "symbolic-ref" "HEAD"
(format "refs/heads/%s" straight-repository-branch))
(funcall call "git" "remote" "add" "origin" repo-url
"--master" straight-repository-branch)
(funcall call "git" "fetch" "origin" pin