Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

magit-diff-visit-avoid-head-blob breaks visit a file from a diff #4149

Closed
aspiers opened this issue Jun 17, 2020 · 2 comments
Closed

magit-diff-visit-avoid-head-blob breaks visit a file from a diff #4149

aspiers opened this issue Jun 17, 2020 · 2 comments
Labels
bug minor A small thing is broken

Comments

@aspiers
Copy link
Contributor

aspiers commented Jun 17, 2020

With the latest magit, I customized magit-diff-visit-avoid-head-blob to t because I prefer the old behaviour. However, I think this revealed a bug in magit-diff-visit--range-to:

magit/lisp/magit-diff.el

Lines 1695 to 1702 in d24f749

(defun magit-diff-visit--range-to (spec)
(if (symbolp spec)
spec
(let ((rev (if (consp spec)
(cdr spec)
(cdr (magit-split-range spec)))))
(if (and magit-diff-visit-avoid-head-blob
(magit-rev-head-p spec))

It calls magit-rev-head-p with a spec, but it's expecting a string:

magit/lisp/magit-git.el

Lines 1094 to 1097 in d24f749

(defun magit-rev-head-p (rev)
(or (equal rev "HEAD")
(and rev
(not (string-match-p "\\.\\." rev))

Here is the stack trace:

Debugger entered--Lisp error: (wrong-type-argument stringp (commit . "6e6913c0"))
  string-match("\\.\\." (commit . "6e6913c0") nil)
  string-match-p("\\.\\." (commit . "6e6913c0"))
  (not (string-match-p "\\.\\." rev))
  (and rev (not (string-match-p "\\.\\." rev)) (equal (magit-rev-parse rev) (magit-rev-parse "HEAD")))
  (or (equal rev "HEAD") (and rev (not (string-match-p "\\.\\." rev)) (equal (magit-rev-parse rev) (magit-rev-parse "HEAD"))))
  magit-rev-head-p((commit . "6e6913c0"))
  (and magit-diff-visit-avoid-head-blob (magit-rev-head-p spec))
  (if (and magit-diff-visit-avoid-head-blob (magit-rev-head-p spec)) (quote unstaged) rev)
  (let ((rev (if (consp spec) (cdr spec) (cdr (magit-split-range spec))))) (if (and magit-diff-visit-avoid-head-blob (magit-rev-head-p spec)) (quote unstaged) rev))
  (if (symbolp spec) spec (let ((rev (if (consp spec) (cdr spec) (cdr (magit-split-range spec))))) (if (and magit-diff-visit-avoid-head-blob (magit-rev-head-p spec)) (quote unstaged) rev)))
  magit-diff-visit--range-to((commit . "6e6913c0"))
  magit-diff-visit-file--noselect("/home/adam/.GIT/adamspiers.org/emacs/.emacs.d/init.d/as-ui.el" nil)
  magit-diff-visit-file--internal("/home/adam/.GIT/adamspiers.org/emacs/.emacs.d/init.d/as-ui.el" nil pop-to-buffer-same-window)
  magit-diff-visit-file("/home/adam/.GIT/adamspiers.org/emacs/.emacs.d/init.d/as-ui.el" nil)
  funcall-interactively(magit-diff-visit-file "/home/adam/.GIT/adamspiers.org/emacs/.emacs.d/init.d/as-ui.el" nil)
  #<subr call-interactively>(magit-diff-visit-file nil nil)
  apply(#<subr call-interactively> magit-diff-visit-file (nil nil))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> magit-diff-visit-file nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (magit-diff-visit-file nil nil))
  call-interactively(magit-diff-visit-file nil nil)
  command-execute(magit-diff-visit-file)

Version used to reproduce: Magit 20200614.1018, Git 2.27.0, Emacs 26.3, gnu/linux

I've said this many times before, but it's worth repeating: magit is unbelievably awesome - thanks for your continued work! I've donated in the past, but just set up a sponsorship subscription.

@aspiers
Copy link
Contributor Author

aspiers commented Jun 17, 2020

BTW, changing the call to (magit-rev-head-p rev) fixes the error, although I'm not 100% sure that's the correct fix.

@tarsius
Copy link
Member

tarsius commented Jun 17, 2020

Thanks for the report!

@tarsius tarsius added the bug minor A small thing is broken label Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug minor A small thing is broken
Development

No branches or pull requests

2 participants