From aec94f5bb2c59382dd270a7496889b5f661b24ac Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 May 2020 17:52:01 -0400 Subject: [PATCH] Fix #3228: 'Failed to fetch from upstream' on doom upgrade Due to git name-rev returning fully qualified refs in some cases. --- core/cli/upgrade.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/cli/upgrade.el b/core/cli/upgrade.el index 7a58402ca..5a60d91ad 100644 --- a/core/cli/upgrade.el +++ b/core/cli/upgrade.el @@ -52,10 +52,13 @@ following shell commands: process-file-side-effects) (print! (start "Preparing to upgrade Doom Emacs and its packages...")) - (let* ((branch - (string-trim-right - (cdr (doom-call-process "git" "name-rev" "--name-only" "HEAD")) - "~[0-9]$")) + (let* (;; git name-rev may return BRANCH~X for detached HEADs and fully + ;; qualified refs in some other cases, so an effort to strip out all + ;; but the branch name is necessary. git symbolic-ref (or + ;; `vc-git--symbolic-ref') won't work; it can't deal with submodules. + (branch (replace-regexp-in-string + "^\\(?:[^/]+/[^/]+/\\)?\\(.+\\)\\(?:~[0-9]+\\)?$" "\\1" + (cdr (doom-call-process "git" "name-rev" "--name-only" "HEAD")))) (target-remote (format "%s/%s" doom-repo-remote branch))) (unless branch (error! (if (file-exists-p! ".git" doom-emacs-dir)