unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 50340@debbugs.gnu.org
Subject: bug#50340: Fix remote-location in vc-git-log-incoming
Date: Fri, 23 Sep 2022 18:52:50 +0300	[thread overview]
Message-ID: <86o7v6bcd1.fsf@mail.linkov.net> (raw)
In-Reply-To: <0073fec5-a6f7-1108-02ee-ab9d9ba38d33@yandex.ru> (Dmitry Gutov's message of "Sun, 5 Sep 2021 22:28:39 +0300")

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

>>> With your patch, I can pass some alternative upstream to the command, and
>>> it fails at the end with something like:
>>>
>>> fatal: ambiguous argument 'HEAD..upstream': unknown revision or path not in
>>> the working tree.
>>> Use '--' to separate paths from revisions, like this:
>>> 'git <command> [<revision>...] -- [<file>...]'
>> But this means that my fix worked, because in vc-git-log-incoming
>> I fixed the first command `git fetch`, but it fails in your case
>> in the second command `git log HEAD..upstream`.
>
> If it works for you, go ahead. I just couldn't make the command work
> (patched or not) with either of the projects I tried it on.

Sorry for the delay, it took some time to realize that
'remote-location' in vc-log-incoming/outgoing
is not a remote repository, but a remote branch name.

In my tests remote repository and remote branch
had the same name, so tests didn't fail when used
remote repository names as remote branch names.

The problem is that (info "(emacs) VC Change Log")
contains wrong information:

  with a prefix argument, ‘vc-log-incoming’ prompts for a specific repository.
  Similarly, ‘C-x v O’ (‘vc-log-outgoing’) shows the changes that will be
  sent to another repository, the next time you run the push command; with
  a prefix argument, it prompts for a specific destination repository.

A prefix argument reads not a repository, but a branch name.

This patch fixes both problems: in vc-git-log-outgoing
and in the documentation by using the same term 'remote-location'
as the argument name in vc-log-incoming/outgoing:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: remote-location.patch --]
[-- Type: text/x-diff, Size: 3162 bytes --]

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 6ceda6d7a5..6857e67def 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1041,13 +1041,14 @@ VC Change Log
 (@code{vc-log-incoming}) command displays a log buffer showing the
 changes that will be applied, the next time you run the version
 control system's pull command to get new revisions from another
-repository (@pxref{Pulling / Pushing}).  This other repository is the default
+remote location (@pxref{Pulling / Pushing}).  This other remote location is the default
 one from which changes are pulled, as defined by the version control
 system; with a prefix argument, @code{vc-log-incoming} prompts for a
-specific repository.  Similarly, @kbd{C-x v O}
+specific remote location.  Similarly, @kbd{C-x v O}
 (@code{vc-log-outgoing}) shows the changes that will be sent to
-another repository, the next time you run the push command; with a
-prefix argument, it prompts for a specific destination repository.
+another remote location, the next time you run the push command; with a
+prefix argument, it prompts for a specific destination that
+in case of some version control system can be a branch name.
 
 @cindex VC log buffer, commands in
 @cindex vc-log buffer
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index a45e0e0c52..e039095255 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2772,7 +2772,8 @@ vc-print-branch-log
 ;;;###autoload
 (defun vc-log-incoming (&optional remote-location)
   "Show log of changes that will be received with pull from REMOTE-LOCATION.
-When called interactively with a prefix argument, prompt for REMOTE-LOCATION."
+When called interactively with a prefix argument, prompt for REMOTE-LOCATION.
+In some version control systems REMOTE-LOCATION can be a remote branch name."
   (interactive
    (when current-prefix-arg
      (list (read-string "Remote location (empty for default): "))))
@@ -2785,7 +2786,8 @@ vc-log-incoming
 ;;;###autoload
 (defun vc-log-outgoing (&optional remote-location)
   "Show log of changes that will be sent with a push operation to REMOTE-LOCATION.
-When called interactively with a prefix argument, prompt for REMOTE-LOCATION."
+When called interactively with a prefix argument, prompt for REMOTE-LOCATION.
+In some version control systems REMOTE-LOCATION can be a remote branch name."
   (interactive
    (when current-prefix-arg
      (list (read-string "Remote location (empty for default): "))))
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 2228cf8665..70505d0fbf 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1291,7 +1308,12 @@ vc-git-log-outgoing
 
 (defun vc-git-log-incoming (buffer remote-location)
   (vc-setup-buffer buffer)
-  (vc-git-command nil 0 nil "fetch")
+  (vc-git-command nil 0 nil "fetch"
+                  (unless (string= remote-location "")
+                    ;; `remote-location' is in format "repository/branch",
+                    ;; so remove everything except a repository name.
+                    (replace-regexp-in-string
+                     "/.*" "" remote-location)))
   (vc-git-command
    buffer 'async nil
    "log"

  reply	other threads:[~2022-09-23 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02 16:16 bug#50340: Fix remote-location in vc-git-log-incoming Juri Linkov
2021-09-02 23:29 ` Dmitry Gutov
2021-09-03  8:12   ` Juri Linkov
2021-09-04  1:50     ` Dmitry Gutov
2021-09-05 16:36       ` Juri Linkov
2021-09-05 19:28         ` Dmitry Gutov
2022-09-23 15:52           ` Juri Linkov [this message]
2022-10-02 18:35             ` Juri Linkov
2021-10-19 18:56         ` Lars Ingebrigtsen
2021-10-19 19:16           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86o7v6bcd1.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=50340@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).