Subject: bug#25737: 25.1.91; vc-git-log-{incoming,outgoing} fixes

From: Tom Tromey <[email-masked]>
Date: Wed, 15 Feb 2017 05:38:04 -0700

Yesterday I discovered the useful vc-log-outgoing command.  It isn't
conveniently bound in vc-dir mode, so I added a binding.  But then I
discovered a couple of bugs in the git back end; and then later
discovered that the same bugs affect vc-git-log-incoming.

First, vc-git-log-incoming and vc-git-log-outgoing can be called with a
nil value for remote-location.  In this case nothing shows up in the
log.  Changing the code to treat nil the same as the empty string makes
the commands show the data I would expect.

Next, these commands move point to the end of the new buffer.  However,
that is weird, because then the buffer is shrunk to fit; for me this
ends up making it look like I have just a single outgoing patch, even
when I have several.  Changing these functions to pass 'async to
vc-git-command fixes this.

Finally, vc-git-log-view-mode only sets truncate-lines in some
situations; I have changed it to also set it for log-outgoing and
log-incoming, which makes the output of these commands more closely
resemble the output of vc-print-log.

Tom

commit 08468554243b048ce408ff7b4fd8543abecaa4c5
Author: Tom Tromey <[email-masked]>
Date:   Wed Feb 15 05:12:18 2017 -0700

    vc-log-outgoing fixes for git; add binding to vc-dir
    
    * lisp/vc/vc-dir.el (vc-dir-mode-map): Bind "O" to vc-log-outgoing.
    * lisp/vc/vc-git.el (vc-git-log-outgoing, vc-git-log-incoming): Handle
    remote-location being nil.  Use 'async.
    (vc-git-log-view-mode): Also truncate lines for log-outgoing and
    log-incoming.
    
    more

diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 5374f1c..532bad1 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -255,6 +255,7 @@ vc-dir-mode-map
     (define-key map "l" 'vc-print-log)	   ;; C-x v l
     (define-key map "L" 'vc-print-root-log) ;; C-x v L
     (define-key map "I" 'vc-log-incoming)   ;; C-x v I
+    (define-key map "O" 'vc-log-outgoing)   ;; C-x v O
     ;; More confusing than helpful, probably
     ;;(define-key map "R" 'vc-revert) ;; u is taken by vc-dir-unmark.
     ;;(define-key map "A" 'vc-annotate) ;; g is taken by revert-buffer
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 0c11a7f..be471c3 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -972,12 +972,12 @@ vc-git-print-log
 (defun vc-git-log-outgoing (buffer remote-location)
   (interactive)
   (vc-git-command
-   buffer 0 nil
+   buffer 'async nil
    "log"
    "--no-color" "--graph" "--decorate" "--date=short"
    (format "--pretty=tformat:%s" (car vc-git-root-log-format))
    "--abbrev-commit"
-   (concat (if (string= remote-location "")
+   (concat (if (or (not remote-location) (string= remote-location ""))
 	       "@{upstream}"
 	     remote-location)
 	   "..HEAD")))
@@ -986,12 +986,12 @@ vc-git-log-incoming
   (interactive)
   (vc-git-command nil 0 nil "fetch")
   (vc-git-command
-   buffer 0 nil
+   buffer 'async nil
    "log"
    "--no-color" "--graph" "--decorate" "--date=short"
    (format "--pretty=tformat:%s" (car vc-git-root-log-format))
    "--abbrev-commit"
-   (concat "HEAD.." (if (string= remote-location "")
+   (concat "HEAD.." (if (or (not remote-location) (string= remote-location ""))
 			"@{upstream}"
 		      remote-location))))
 
@@ -1011,7 +1011,7 @@ vc-git-log-view-mode
 	   (cadr vc-git-root-log-format)
 	 "^commit *\\([0-9a-z]+\\)"))
   ;; Allow expanding short log entries.
-  (when (eq vc-log-view-type 'short)
+  (when (memq vc-log-view-type '(short log-outgoing log-incoming))
     (setq truncate-lines t)
     (set (make-local-variable 'log-view-expanded-log-entry-function)
 	 'vc-git-expanded-log-entry))

In GNU Emacs 25.1.91.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-02 built on bapiya
Repository revision: 7e02a477bbcabb4e65aeecade79b67357c0b9dae
Windowing system distributor 'Fedora Project', version 11.0.11901000
System Description:	Fedora release 25 (Twenty Five)

Configured using:
 'configure --prefix=/home/tromey/Emacs/install/ --with-modules'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

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

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  flyspell-mode: t
  which-function-mode: t
  erc-services-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-netsplit-mode: t
  erc-hl-nicks-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  transient-mark-mode: t

Recent messages:
Running git --no-pager diff-index --relative -z -M HEAD -- lisp/vc/vc-git.el in background... done
Running git --no-pager ls-files -z -c -s -- lisp/vc/vc-git.el in background... done
Running git --no-pager log --no-color --graph --decorate --date=short --... --abbrev-commit -n 2000 -- ./ in background... done
Finding changes in /home/tromey/Emacs/trunk/...
Running git --no-pager diff-tree --exit-code -p 18... 0846855 -- ./...OK = 1
Running git --no-pager log 0846855 -1 -- . in foreground...
Running git --no-pager log 0846855 -1 -- ....OK = 0
Finding changes in /home/tromey/Emacs/trunk/...
Running git --no-pager diff-tree --exit-code -p 18... 0846855 -- ./...OK = 1
C-x C-g is undefined

Load-path shadows:
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.1.91/lisp/play/bubbles

Features:
(highlight-refontification tabify man shadow emacsbug conf-mode
two-column iso-transl perl-mode sh-script executable cal-move nnregistry
python tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize
make-mode etags cursor-sensor mhtml-mode org-bullets org-element
org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view
image-mode org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote
org-pcomplete org-list org-faces org-entities org-version ob-emacs-lisp
ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs gnus-fun gnus-draft
noutline outline ido skeleton css-mode smie eww url-queue trace
find-dired descr-text gdb-shell lisp-mnt url-handlers url-http url-gw
url-auth lex edebug debug m4-mode bbdb-sc supercite regi xref project
log-edit js json map sgml-mode flow-fill gnus-html xml url-cache mm-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf eieio-opt speedbar sb-image ezimage dframe find-func
whitespace tcl log-view pcvs-util vc-annotate term/xterm xterm
smerge-mode goto-addr shell find-file idutils derived bug-reference
cc-mode cc-fonts cc-guess cc-menus cc-cmds jka-compr mailalias mail-hist
nnir sort gnus-cite smiley shr-color url-util url-parse url-vars shr dom
subr-x browse-url mm-archive gnus-async gnus-bcklg qp gnus-ml disp-table
gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua bbdb-com crm
network-stream nsm starttls gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg nntp gnus-cache gnus-registry registry eieio-compat
eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap
gnus-sum gnus-group gnus-undo smtpmail gnus-start gnus-cloud nnimap
nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec
gnus-int gnus-range gnus-win gnus gnus-ems nnheader bbdb-message
sendmail mail-extr message idna dired rfc822 mml mml-sec epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev mail-utils gmm-utils mailheader gud dwarf-mode copyright
dabbrev misearch multi-isearch vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs add-log rx vc-git diff-mode easy-mmode rust-mode flyspell
ispell diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer
dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
which-func imenu minimap autorevert filenotify cus-start cus-load status
erc-services erc-list erc-menu erc-join erc-ring erc-networks
erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks
color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend
erc-compat format-spec auth-source eieio gnus-util mm-util help-fns
mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc
vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb
bbdb-site timezone ange-ftp comint ansi-color ring server savehist
finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core
lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl
weblogger-autoloads info package epg-config seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame 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 charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 2750314 537335)
 (symbols 48 139907 709)
 (miscs 40 34395 10086)
 (strings 32 583581 192504)
 (string-bytes 1 17328869)
 (vectors 16 139544)
 (vector-slots 8 2879816 108437)
 (floats 8 950 1483)
 (intervals 56 342103 9442)
 (buffers 976 380))