unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode
@ 2021-09-19 23:43 Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-09-20  6:45 ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-09-19 23:43 UTC (permalink / raw)
  To: 50689; +Cc: Tassilo Horn

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

Tags: patch

In a clone of https://github.com/abo-abo/swiper.git, with the following
remotes:

    $ git remote -v
    elpa	savannah:/srv/git/emacs/elpa.git (fetch)
    elpa	savannah:/srv/git/emacs/elpa.git (push)
    origin	git@github.com:basil-conto/swiper.git (fetch)
    origin	git@github.com:basil-conto/swiper.git (push)
    upstream	git@github.com:abo-abo/swiper.git (fetch)
    upstream	git@github.com:abo-abo/swiper.git (push)

0. emacs -Q ivy.el
1. M-: (vc-call-backend 'Git 'repository-url "upstream") RET

This returns: "git@github.com:basil-conto/swiper.git"
instead of:   "git@github.com:abo-abo/swiper.git"

Step 1 is effectively what bug-reference-try-setup-from-vc does, and I
believe the incorrect result is due to vc-git-repository-url expecting a
file name, not a Git remote name, as its first argument.

How's the attached fix?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-VC-repo-URL-detection-in-bug-reference-mode.patch --]
[-- Type: text/x-diff, Size: 2689 bytes --]

From dd1be2b9c277a53078fb20242702ecf2599cbb7b Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 19 Sep 2021 21:13:17 +0100
Subject: [PATCH 1/2] Fix VC repo URL detection in bug-reference-mode

* lisp/progmodes/bug-reference.el (bug-reference-try-setup-from-vc):
Pass file or directory name in question as the first argument to the
backend's repository-url implementation.  Use when-let and seq-some
to flatten nested conditionals.
---
 lisp/progmodes/bug-reference.el | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index b646a47c85..fd014a38d9 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -376,24 +376,19 @@ bug-reference-try-setup-from-vc
 Test each configuration in `bug-reference-setup-from-vc-alist'
 and `bug-reference--setup-from-vc-alist' and apply it if
 applicable."
-  (let ((file-or-dir (or buffer-file-name
-                         ;; Catches modes such as vc-dir and Magit.
-                         default-directory)))
-    (when file-or-dir
-      (let* ((backend (vc-responsible-backend file-or-dir t))
-             (url
-              (or (ignore-errors
-                    (vc-call-backend backend 'repository-url "upstream"))
-                  (ignore-errors
-                    (vc-call-backend backend 'repository-url)))))
-        (when url
-          (catch 'found
-            (dolist (config (append
-                             bug-reference-setup-from-vc-alist
-                             (bug-reference--setup-from-vc-alist)))
-              (when (apply #'bug-reference-maybe-setup-from-vc
-                           url config)
-                (throw 'found t)))))))))
+  (when-let ((file-or-dir (or buffer-file-name
+                              ;; Catches modes such as vc-dir and Magit.
+                              default-directory))
+             (backend (vc-responsible-backend file-or-dir t))
+             (url (seq-some (lambda (remote)
+                              (ignore-errors
+                                (vc-call-backend backend 'repository-url
+                                                 file-or-dir remote)))
+                            '("upstream" nil))))
+    (seq-some (lambda (config)
+                (apply #'bug-reference-maybe-setup-from-vc url config))
+              (append bug-reference-setup-from-vc-alist
+                      (bug-reference--setup-from-vc-alist)))))
 
 (defvar bug-reference-setup-from-mail-alist
   `((,(regexp-opt '("emacs" "auctex" "gnus" "tramp" "orgmode") 'words)
-- 
2.33.0


[-- Attachment #3: Type: text/plain, Size: 3196 bytes --]


Thanks,

-- 
Basil

In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2021-09-20 built on tia
Repository revision: 3c513435369826e44a53dcb12ecc14657e03c73d
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure 'CC=ccache gcc' 'CFLAGS=-Og -ggdb' --config-cache
 --prefix=/home/blc/.local --enable-checking=structs
 --with-x-toolkit=lucid --with-file-notification=yes --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(vc-git diff-mode easy-mmode vc-dispatcher help-mode pp shadow sort
mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml
mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 57729 7685)
 (symbols 48 7242 5)
 (strings 32 21156 1629)
 (string-bytes 1 675261)
 (vectors 16 14813)
 (vector-slots 8 196771 13743)
 (floats 8 31 55)
 (intervals 56 350 15)
 (buffers 992 12))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode
  2021-09-19 23:43 bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-09-20  6:45 ` Tassilo Horn
  2021-09-20 13:53   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2021-09-20  6:45 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 50689

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

Hey Basil,

> Tags: patch
>
> In a clone of https://github.com/abo-abo/swiper.git, with the following
> remotes:
>
>     $ git remote -v
>     elpa	savannah:/srv/git/emacs/elpa.git (fetch)
>     elpa	savannah:/srv/git/emacs/elpa.git (push)
>     origin	git@github.com:basil-conto/swiper.git (fetch)
>     origin	git@github.com:basil-conto/swiper.git (push)
>     upstream	git@github.com:abo-abo/swiper.git (fetch)
>     upstream	git@github.com:abo-abo/swiper.git (push)
>
> 0. emacs -Q ivy.el
> 1. M-: (vc-call-backend 'Git 'repository-url "upstream") RET
>
> This returns: "git@github.com:basil-conto/swiper.git"
> instead of:   "git@github.com:abo-abo/swiper.git"
>
> Step 1 is effectively what bug-reference-try-setup-from-vc does, and I
> believe the incorrect result is due to vc-git-repository-url expecting
> a file name, not a Git remote name, as its first argument.

Oh, good catch!

BTW, I've thought I've checked that previously <fork>/issues/X
redirected you to <originalrepo>/issues/X but that doesn't seem to be
the case right anymore...

> How's the attached fix?

LGTM.  Not sure about when-let/seq-fns.  I refrained from using them in
bug-reference.el so that it doesn't require subr-x.el and seq.el.  But
OTHO, I very much like them and would happily use them once they are
loaded anyway.

Bye,
Tassilo





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode
  2021-09-20  6:45 ` Tassilo Horn
@ 2021-09-20 13:53   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-09-20 13:57     ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-09-20 13:53 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: 50689

close 50689 28.1
quit

Tassilo Horn [2021-09-20 08:45 +0200] wrote:

> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>> How's the attached fix?
>
> LGTM.

Thanks, pushed:

Fix VC repo URL detection in bug-reference-mode
7d5930a6f0 2021-09-20 14:41:13 +0100
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=7d5930a6f0c7b44c00df403d5fe8a3f40e51902f

> Not sure about when-let/seq-fns.  I refrained from using them in
> bug-reference.el so that it doesn't require subr-x.el and seq.el.

when-let is an autoloaded macro, so subr-x.el won't be loaded at all at
runtime (assuming everything is byte-compiled).

seq-some is an autoloaded function, so seq.el won't be loaded until
bug-reference-try-setup-from-vc is invoked (and anyway in practice it is
hard to do anything in Emacs any more without seq.el being loaded at
some point).

> But OTHO, I very much like them and would happily use them once they
> are loaded anyway.

I'm therefore closing this report.

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode
  2021-09-20 13:53   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-09-20 13:57     ` Tassilo Horn
  0 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2021-09-20 13:57 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 50689

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

>> Not sure about when-let/seq-fns.  I refrained from using them in
>> bug-reference.el so that it doesn't require subr-x.el and seq.el.
>
> when-let is an autoloaded macro, so subr-x.el won't be loaded at all
> at runtime (assuming everything is byte-compiled).

Ah, right.

> seq-some is an autoloaded function, so seq.el won't be loaded until
> bug-reference-try-setup-from-vc is invoked (and anyway in practice it
> is hard to do anything in Emacs any more without seq.el being loaded
> at some point).

Allright with me.

Thanks a lot!
Tassilo





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-20 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-19 23:43 bug#50689: 28.0.50; Wrong VC repo URL detection in bug-reference-mode Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-20  6:45 ` Tassilo Horn
2021-09-20 13:53   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-20 13:57     ` Tassilo Horn

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).