sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
399 stars 74 forks source link

mapconcat: Wrong type argument: arrayp, (47 97 98 99 100 101 102 103 104 105 ...) #93

Closed aureliar8 closed 2 years ago

aureliar8 commented 2 years ago

I just installed git-link from melpa (version 20220206.1802).

When doing M-x git-link in a git repo I get mapconcat: Wrong type argument: arrayp, (47 97 98 99 100 101 102 103 104 105 ...)` in the minibuffer.

Here is the stack trace:

Debugger entered--Lisp error: (wrong-type-argument arrayp (47 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 ...))
  #f(compiled-function (byte) #<bytecode 0x3142aa9>)(98)
  mapconcat(#f(compiled-function (byte) #<bytecode 0x3142aa9>) "blobd/topology/zookeeper_topology.go" "")
  url-hexify-string("blobd/topology/zookeeper_topology.go" (47 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 ...))
  git-link("origin" 103 nil)
  funcall-interactively(git-link "origin" 103 nil)
  call-interactively(git-link)
  (lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-completions "" obarray (quote commandp))))))()
  funcall-interactively((lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-completions "" obarray (quote commandp)))))))
  call-interactively((lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-completions "" obarray (quote commandp)))))) nil nil)
  command-execute((lambda nil (interactive) (call-interactively (intern (ido-completing-read "M-x " (all-completions "" obarray (quote commandp)))))))

Do you have an idea to solve it ? Thanks

EDIT:

Changing this line https://github.com/sshaw/git-link/blob/a715c116341162ff1a49fff684a45dec8ac0b0af/git-link.el#L762

to (url-hexify-string filename) works for me (it doesn't crash anymore and I get a valid github link)

sshaw commented 2 years ago

What version of emacs are you using?

v0.8.4 does not have this problem.

aureliar8 commented 2 years ago

emacs-version gives GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian

I'm on ubuntu 20.04.3, emacs installed via apt install emacs

bitti commented 2 years ago

I'm sorry, I didn't realize that. Maybe we need to add an explicit (require 'url-util). If you do that manually does the error go away?

bitti commented 2 years ago

Oops, (require 'url-util) is already included as it should be, otherwise it should have failed previously already for you, since url-hexify-string is already used for the branchname and the error message would be different anyway. So I suppose it's related to the Emacs Version. Let me see if I can find out.

sshaw commented 2 years ago

Hi @bitti, it's because on 26 url-hexify-string requires a vector and the position of elements in the vector must correspond to the character code (if I recall, read this this morning) to be escaped.

For 26 support we could rebuild this structure that, I assume, will also work with 27+

bitti commented 2 years ago

(url-hexify-string filename) works for me (it doesn't crash anymore and I get a valid github link)

Yes at least for github not escaping / is merely a cosmetic thing. I'm not sure how other git repo hosting providers would handle it though, therefore I think it's safer to not escape it.

bitti commented 2 years ago

For 26 support we could rebuild this structure that, I assume, will also work with 27+

I see, seems there was a bug which got fixed in Emacs 27.0.90: https://github.com/emacs-mirror/emacs/commit/9aa13cd4beccfe41e8f4930cb029bd60e7788e93. So we'd have to wrap the second argument explicitly with url--allowed-chars to avoid a regression for earlier versions. Do you want me to do the PR or do you handle it?

sshaw commented 2 years ago

If you could do a PR that would be —as the kids say: amaaaazing!

bitti commented 2 years ago

Ok, I opened https://github.com/sshaw/git-link/pull/94 now. It's more or less a trivial fix.

sshaw commented 2 years ago

Fixed in v0.8.6. Thanks again @bitti 💪:octocat: