                                ;; attempt to turn arbitrary URLs into
                                ;; repository names.
                                (let ((regexp "^.*/\\(.+\\)\\.git$"))
-                                 (when (string-match regexp url)
+                                 (when (and url (string-match regexp url))
                                    (match-string 1 url)))
                                package)))
           ;; This code is here to deal with complications that can

  (straight--with-plist emacsmirror-recipe
      (local-repo)
    (let ((default-directory (straight--dir "repos" local-repo)))
      (with-temp-buffer
        (when (straight--check-call
               "git" "config" "-f" ".gitmodules"
               "--get" (format "submodule.%s.url"
                               (symbol-name package)))
          (let ((url (string-trim (buffer-string))))
            (if (string-match
                 "^git@github\\.com:\\([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+\\)\\.git$"
                 url)
                `(,package :fetcher github
                           :repo ,(match-string 1 url))
              `(,package :fetcher git
                         :url ,url))))))))

(defvar straight--repo-cache (make-hash-table :test 'equal))


            (if-let ((branch (straight--get-branch)))
                (if-let ((upstream (straight--get-upstream branch)))
                    (if (straight--is-ancestor branch upstream)
                        ;; Local branch is behind upstream, merge.
                        (straight--merge-with-upstream upstream)
                      (unless (straight--is-ancestor upstream branch)
                        ;; Local branch has diverged from upstream,
                        ;; but is not purely ahead. Warn.
                        (straight--warn
                         (concat "In repository %S, cannot merge branch %S with "
                                 "upstream %S without merge or rebase")
                         local-repo branch upstream)))
                  (straight--warn
                   (concat "In repository %S, current branch %S has "
                           "no upstream, cannot update")
