GNU bug report logs - #79276
[PATCH] Pass remote name explicitly in bug-reference-try-setup-from-vc

Previous Next

Package: emacs;

Reported by: André A. Gomes <andremegafone <at> gmail.com>

Date: Wed, 20 Aug 2025 09:17:01 UTC

Severity: normal

Tags: patch

Done: Tassilo Horn <tsdh <at> gnu.org>

To reply to this bug, email your comments to 79276 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Wed, 20 Aug 2025 09:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to André A. Gomes <andremegafone <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 20 Aug 2025 09:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: André A. Gomes <andremegafone <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Pass remote name explicitly in bug-reference-try-setup-from-vc
Date: Wed, 20 Aug 2025 12:16:26 +0300
[Message part 1 (text/plain, inline)]
Tags: patch

Hi,

I investigated why bug-reference-mode's automatic setup wasn't doing
what I expected for some git repositories when the mode is enabled on
Magit buffers.  It turned out that, unsurprisingly, the inference
mechanism requires one of the remotes to the called "upstream" or
"origin" (since this condition didn't hold for the aforementioned
repositories, the conclusion follows).

Please find a trivial patch attached that makes this condition clearer.

It would make sense for Tassilo Horn or Basil L. Contovounesios to take
a look at the patch since they have touched on this functionality
recently.

Thank you.


-- 
André A. Gomes
"You cannot even find the ruins..."
[0001-Pass-remote-name-explicitly-in-bug-reference-try-set.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Wed, 20 Aug 2025 10:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: André A. Gomes <andremegafone <at> gmail.com>
Cc: "Basil L. Contovounesios" <basil <at> contovou.net>, 79276 <at> debbugs.gnu.org,
 Tassilo Horn <tsdh <at> gnu.org>
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Wed, 20 Aug 2025 10:52:57 +0000
André A. Gomes <andremegafone <at> gmail.com> writes:

> Tags: patch
>
> Hi,
>
> I investigated why bug-reference-mode's automatic setup wasn't doing
> what I expected for some git repositories when the mode is enabled on
> Magit buffers.  It turned out that, unsurprisingly, the inference
> mechanism requires one of the remotes to the called "upstream" or
> "origin" (since this condition didn't hold for the aforementioned
> repositories, the conclusion follows).
>
> Please find a trivial patch attached that makes this condition clearer.
>
> It would make sense for Tassilo Horn or Basil L. Contovounesios to take
> a look at the patch since they have touched on this functionality
> recently.

I have CC'ed them to bring their attention to the bug.  You can so do
too in the future by adding a "X-Debuggs-CC" header when composing a bug
report :)

> Thank you.
>
>
> -- 
> André A. Gomes
> "You cannot even find the ruins..."
>
> From aff9e615689ec4b277deedfb4c6de8a60ef2f82e Mon Sep 17 00:00:00 2001
> From: "Andre A. Gomes" <andremegafone <at> gmail.com>
> Date: Wed, 20 Aug 2025 11:48:40 +0300
> Subject: [PATCH] Pass remote name explicitly in
>  bug-reference-try-setup-from-vc.
>
> * lisp/progmodes/bug-reference.el (bug-reference-setup-from-vc-alist):
> The call to vc-call-backend resolves to vc-git-repository-url, which
> takes REMOTE-NAME as an optional argument.  Its default value is
> "origin" so let's pass it explicitly for clarity.
> ---
>  lisp/progmodes/bug-reference.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
> index 5c03c949049..02acac154ee 100644
> --- a/lisp/progmodes/bug-reference.el
> +++ b/lisp/progmodes/bug-reference.el
> @@ -393,7 +393,7 @@ bug-reference-try-setup-from-vc
>                                 (ignore-errors
>                                   (vc-call-backend backend 'repository-url
>                                                    file-or-dir remote)))
> -                             '("upstream" nil))))
> +                             '("upstream" "origin"))))
>      (seq-some (lambda (config)
>                  (apply #'bug-reference-maybe-setup-from-vc url config))
>                (append bug-reference-setup-from-vc-alist




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Wed, 20 Aug 2025 11:19:02 GMT) Full text and rfc822 format available.

Message #11 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: André A. Gomes <andremegafone <at> gmail.com>, Tassilo Horn
 <tsdh <at> gnu.org>, Basil L. Contovounesios <basil <at> contovou.net>
Cc: 79276 <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Wed, 20 Aug 2025 14:18:18 +0300
> From: André A. Gomes <andremegafone <at> gmail.com>
> Date: Wed, 20 Aug 2025 12:16:26 +0300
> 
> Tags: patch
> 
> Hi,
> 
> I investigated why bug-reference-mode's automatic setup wasn't doing
> what I expected for some git repositories when the mode is enabled on
> Magit buffers.  It turned out that, unsurprisingly, the inference
> mechanism requires one of the remotes to the called "upstream" or
> "origin" (since this condition didn't hold for the aforementioned
> repositories, the conclusion follows).
> 
> Please find a trivial patch attached that makes this condition clearer.
> 
> It would make sense for Tassilo Horn or Basil L. Contovounesios to take
> a look at the patch since they have touched on this functionality
> recently.

Adding Tassilo and Basil to the discussion.

> >From aff9e615689ec4b277deedfb4c6de8a60ef2f82e Mon Sep 17 00:00:00 2001
> From: "Andre A. Gomes" <andremegafone <at> gmail.com>
> Date: Wed, 20 Aug 2025 11:48:40 +0300
> 
> * lisp/progmodes/bug-reference.el (bug-reference-setup-from-vc-alist):
> The call to vc-call-backend resolves to vc-git-repository-url, which
> takes REMOTE-NAME as an optional argument.  Its default value is
> "origin" so let's pass it explicitly for clarity.
> ---
>  lisp/progmodes/bug-reference.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
> index 5c03c949049..02acac154ee 100644
> --- a/lisp/progmodes/bug-reference.el
> +++ b/lisp/progmodes/bug-reference.el
> @@ -393,7 +393,7 @@ bug-reference-try-setup-from-vc
>                                 (ignore-errors
>                                   (vc-call-backend backend 'repository-url
>                                                    file-or-dir remote)))
> -                             '("upstream" nil))))
> +                             '("upstream" "origin"))))
>      (seq-some (lambda (config)
>                  (apply #'bug-reference-maybe-setup-from-vc url config))
>                (append bug-reference-setup-from-vc-alist
> -- 
> 2.48.1
> 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Wed, 20 Aug 2025 12:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "André A. Gomes" <andremegafone <at> gmail.com>,
 Philip Kaludercic <philipk <at> posteo.net>,
 "Basil L. Contovounesios" <basil <at> contovou.net>, 79276 <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Wed, 20 Aug 2025 14:20:48 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi André,

>> I investigated why bug-reference-mode's automatic setup wasn't doing
>> what I expected for some git repositories when the mode is enabled on
>> Magit buffers.  It turned out that, unsurprisingly, the inference
>> mechanism requires one of the remotes to the called "upstream" or
>> "origin" (since this condition didn't hold for the aforementioned
>> repositories, the conclusion follows).
>> 
>> Please find a trivial patch attached that makes this condition
>> clearer.
>> 
>> It would make sense for Tassilo Horn or Basil L. Contovounesios to
>> take a look at the patch since they have touched on this
>> functionality recently.
>
> Adding Tassilo and Basil to the discussion.

I don't think that's appropriate because bug-reference calls the generic
`vc-call-backend' function but "origin" is a Git-specific name.  Other
version control systems might name it differently.  For example, in
mercurial the default remote is called "default", see vc-hg.el, so you'd
change semantics here.

But I get the point that "origin" is good name for "the remote which is
probably the central one that also hosts the bug-tracker".  Why not make
the patch

> diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
> index 5c03c949049..02acac154ee 100644
> --- a/lisp/progmodes/bug-reference.el
> +++ b/lisp/progmodes/bug-reference.el
> @@ -393,7 +393,7 @@ bug-reference-try-setup-from-vc
>                                 (ignore-errors
>                                   (vc-call-backend backend 'repository-url
>                                                    file-or-dir remote)))
> -                             '("upstream" nil))))
> +                             '("upstream" "origin" nil))))
>      (seq-some (lambda (config)
>                  (apply #'bug-reference-maybe-setup-from-vc url config))
>                (append bug-reference-setup-from-vc-alist

so that we ask for likely remote names first and then the default remote
name as defined by the VCS?

That would make things work fine also for hg where the "default" remote
is my own clone and the upstream is either called "upstream" or
"origin".

The downside is that in the Git case, we basically ask for "origin"
twice, once explicitly, once as default value for the optional argument.
But a "git config ..." call is not expensive so why bother.

Bye,
Tassilo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Thu, 21 Aug 2025 07:07:02 GMT) Full text and rfc822 format available.

Message #17 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: André A. Gomes <andremegafone <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: Philip Kaludercic <philipk <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>,
 "Basil L. Contovounesios" <basil <at> contovou.net>, 79276 <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Thu, 21 Aug 2025 10:06:04 +0300
Tassilo Horn <tsdh <at> gnu.org> writes:

> I don't think that's appropriate because bug-reference calls the generic
> `vc-call-backend' function but "origin" is a Git-specific name.  Other
> version control systems might name it differently.  For example, in
> mercurial the default remote is called "default", see vc-hg.el, so you'd
> change semantics here.

Good observation, I didn't take that into account.

> But I get the point that "origin" is good name for "the remote which is
> probably the central one that also hosts the bug-tracker".  Why not make
> the patch
>
>> diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
>> index 5c03c949049..02acac154ee 100644
>> --- a/lisp/progmodes/bug-reference.el
>> +++ b/lisp/progmodes/bug-reference.el
>> @@ -393,7 +393,7 @@ bug-reference-try-setup-from-vc
>>                                 (ignore-errors
>>                                   (vc-call-backend backend 'repository-url
>>                                                    file-or-dir remote)))
>> -                             '("upstream" nil))))
>> +                             '("upstream" "origin" nil))))
>>      (seq-some (lambda (config)
>>                  (apply #'bug-reference-maybe-setup-from-vc url config))
>>                (append bug-reference-setup-from-vc-alist
>
> so that we ask for likely remote names first and then the default remote
> name as defined by the VCS?

That sounds reasonable to me.  Perhaps a comment above that line
explaining the meaning of nil would be sensible.

I'll just wait for some feedback from Basil as well and refactor the
patch.

> The downside is that in the Git case, we basically ask for "origin"
> twice, once explicitly, once as default value for the optional argument.
> But a "git config ..." call is not expensive so why bother.

seq-some stops once a predicate returns non-nil, so I don't think that
would be an issue.  Regardless, the call is inexpensive indeed.

Thanks.


-- 
André A. Gomes
"You cannot even find the ruins..."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Thu, 21 Aug 2025 18:53:02 GMT) Full text and rfc822 format available.

Message #20 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: André A. Gomes <andremegafone <at> gmail.com>
Cc: Philip Kaludercic <philipk <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>,
 "Basil L. Contovounesios" <basil <at> contovou.net>, 79276 <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Thu, 21 Aug 2025 20:51:25 +0200
André A. Gomes <andremegafone <at> gmail.com> writes:

Hi André,

>> I don't think that's appropriate because bug-reference calls the
>> generic `vc-call-backend' function but "origin" is a Git-specific
>> name.  Other version control systems might name it differently.  For
>> example, in mercurial the default remote is called "default", see
>> vc-hg.el, so you'd change semantics here.
>
> Good observation, I didn't take that into account.

I have my bright moments. ;-)

>> But I get the point that "origin" is good name for "the remote which is
>> probably the central one that also hosts the bug-tracker".  Why not make
>> the patch
>>
>>> diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
>>> index 5c03c949049..02acac154ee 100644
>>> --- a/lisp/progmodes/bug-reference.el
>>> +++ b/lisp/progmodes/bug-reference.el
>>> @@ -393,7 +393,7 @@ bug-reference-try-setup-from-vc
>>>                                 (ignore-errors
>>>                                   (vc-call-backend backend 'repository-url
>>>                                                    file-or-dir remote)))
>>> -                             '("upstream" nil))))
>>> +                             '("upstream" "origin" nil))))
>>>      (seq-some (lambda (config)
>>>                  (apply #'bug-reference-maybe-setup-from-vc url config))
>>>                (append bug-reference-setup-from-vc-alist
>>
>> so that we ask for likely remote names first and then the default remote
>> name as defined by the VCS?
>
> That sounds reasonable to me.  Perhaps a comment above that line
> explaining the meaning of nil would be sensible.

Yes, a comment would be utmost welcome.

> I'll just wait for some feedback from Basil as well and refactor the
> patch.

I don't think you need to wait.  He basically just changed two or-ed
vc-call-backend calls to the current seq-some version, so more a
technical refactoring.

>> The downside is that in the Git case, we basically ask for "origin"
>> twice, once explicitly, once as default value for the optional
>> argument.  But a "git config ..." call is not expensive so why
>> bother.
>
> seq-some stops once a predicate returns non-nil, so I don't think that
> would be an issue.

Ah, right.  So just twice the cost in the case where there's neither
upstream nor origin.

> Regardless, the call is inexpensive indeed.

Right.

Thanks,
Tassilo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79276; Package emacs. (Mon, 25 Aug 2025 12:26:02 GMT) Full text and rfc822 format available.

Message #23 received at 79276 <at> debbugs.gnu.org (full text, mbox):

From: André A. Gomes <andremegafone <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: Philip Kaludercic <philipk <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>,
 "Basil L. Contovounesios" <basil <at> contovou.net>, 79276 <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Mon, 25 Aug 2025 15:25:13 +0300
[Message part 1 (text/plain, inline)]
Tassilo Horn <tsdh <at> gnu.org> writes:

>> That sounds reasonable to me.  Perhaps a comment above that line
>> explaining the meaning of nil would be sensible.
>
> Yes, a comment would be utmost welcome.

Tassilo, I'm attaching a new version of the patch.  It should be ready
to be pushed.  Thank you.


-- 
André A. Gomes
"You cannot even find the ruins..."
[0001-Pass-remote-name-explicitly-in-bug-reference-try-set.patch (text/x-diff, attachment)]

Reply sent to Tassilo Horn <tsdh <at> gnu.org>:
You have taken responsibility. (Mon, 25 Aug 2025 14:14:02 GMT) Full text and rfc822 format available.

Notification sent to André A. Gomes <andremegafone <at> gmail.com>:
bug acknowledged by developer. (Mon, 25 Aug 2025 14:14:02 GMT) Full text and rfc822 format available.

Message #28 received at 79276-done <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: André A. Gomes <andremegafone <at> gmail.com>
Cc: Philip Kaludercic <philipk <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>,
 "Basil L. Contovounesios" <basil <at> contovou.net>, 79276-done <at> debbugs.gnu.org
Subject: Re: bug#79276: [PATCH] Pass remote name explicitly in
 bug-reference-try-setup-from-vc
Date: Mon, 25 Aug 2025 16:13:22 +0200
André A. Gomes <andremegafone <at> gmail.com> writes:

Hi André,

>>> That sounds reasonable to me.  Perhaps a comment above that line
>>> explaining the meaning of nil would be sensible.
>>
>> Yes, a comment would be utmost welcome.
>
> Tassilo, I'm attaching a new version of the patch.  It should be ready
> to be pushed.  Thank you.

Yes, it's fine.  I took your commit but amended it slightly so that your
commit message also references this bug report and I extended the new
comment in bug-reference.el a bit.  Pushed to master.  I'm closing this
issue.

Thanks a lot!
  Tassilo




This bug report was last modified 18 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.