bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50340: Fix remote-location in vc-git-log-incoming


From: Juri Linkov
Subject: bug#50340: Fix remote-location in vc-git-log-incoming
Date: Fri, 23 Sep 2022 18:52:50 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>>> 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:

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 via email to

[Prev in Thread] Current Thread [Next in Thread]