magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.33k stars 117 forks source link

No such file or directory setting default-directory for repository whose clone was deleted #653

Closed bcc32 closed 8 months ago

bcc32 commented 8 months ago

When trying to visit a topic for a repo that I used to have a clone for, but have since deleted, I get an error. Backtrace is below.

I don't see a relevant command to inform forge that the repository no longer has a clone. If I run M-x forge-list-repositories, the old path is listed but it no longer exists on my disk:

NixOS                nixpkgs              *   /Users/aaron/src/nixpkgs/

Backtrace:

Debugger entered--Lisp error: (file-missing "Setting current directory" "No such file or directory" "/Users/aaron/src/nixpkgs/")
  apply(debug (error (file-missing "Setting current directory" "No such file or directory" "/Users/aaron/src/nixpkgs/")))
  transient--exit-and-debug(error (file-missing "Setting current directory" "No such file or directory" "/Users/aaron/src/nixpkgs/"))
  call-process("/usr/bin/git" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel")
  apply(call-process "/usr/bin/git" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel"))
  process-file("/usr/bin/git" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel")
  apply(process-file "/usr/bin/git" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel"))
  magit-process-file("/usr/bin/git" nil (t nil) nil "--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel")
  apply(magit-process-file "/usr/bin/git" nil (t nil) nil ("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "color.ui=false" "-c" "color.diff=false" "rev-parse" "--show-toplevel"))
  magit-process-git((t nil) ("rev-parse" "--show-toplevel"))
  magit-git-str("rev-parse" "--show-toplevel")
  apply(magit-git-str "rev-parse" "--show-toplevel")
  magit-rev-parse-safe("--show-toplevel")
  magit-save-repository-buffers(nil)
  magit-maybe-save-repository-buffers()
  run-hooks(magit-setup-buffer-hook)
  magit-setup-buffer-internal(forge-pullreq-mode t ((forge-buffer-topic #<forge-pullreq forge-pullreq-55431406>)) "*forge: NixOS/nixpkgs #298664*")
  forge-topic-setup-buffer(#<forge-pullreq forge-pullreq-55431406>)
  #f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>)()
  apply(#f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>) nil)
  #f(compiled-function (fn &rest args) #<bytecode 0x6badafc8dde6e37>)(#f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>))
  apply(#f(compiled-function (fn &rest args) #<bytecode 0x6badafc8dde6e37>) #f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>) nil)
  (lambda (fn &rest args) (interactive #f(compiled-function (spec) #<bytecode 0x1136e63e6f8aa038>)) (apply '#f(compiled-function (fn &rest args) #<bytecode 0x6badafc8dde6e37>) fn args))(#f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>))
  apply((lambda (fn &rest args) (interactive #f(compiled-function (spec) #<bytecode 0x1136e63e6f8aa038>)) (apply '#f(compiled-function (fn &rest args) #<bytecode 0x6badafc8dde6e37>) fn args)) #f(compiled-function () (interactive nil) #<bytecode 0x581f34999d63dce>) nil)
  forge-topic-menu()
  #<subr funcall-interactively>(forge-topic-menu)
  apply(#<subr funcall-interactively> forge-topic-menu)
  funcall-interactively(forge-topic-menu)
  #<subr call-interactively>(forge-topic-menu nil nil)
  apply(#<subr call-interactively> (forge-topic-menu nil nil))
  explain-pause--wrap-call-interactively(#<subr call-interactively> forge-topic-menu nil nil)
  apply(explain-pause--wrap-call-interactively #<subr call-interactively> (forge-topic-menu nil nil))
  call-interactively(forge-topic-menu nil nil)
  command-execute(forge-topic-menu)
tarsius commented 8 months ago

I already suspected there were a few more places where the recorded worktree would have to be validated. I've now added forge-get-worktree for that purpose and found a few places, that didn't already use equivalent code.

bcc32 commented 8 months ago

Thanks for the very quick fix!