Function: vc-git-print-log

vc-git-print-log is a byte-compiled function defined in vc-git.el.gz.

Signature

(vc-git-print-log FILES BUFFER &optional SHORTLOG START-REVISION LIMIT)

Documentation

Print commit log associated with FILES into specified BUFFER.

If SHORTLOG is non-nil, use a short format based on vc-git-root-log-format.
(This requires at least Git version 1.5.6, for the --graph option.)
If START-REVISION is non-nil, it is the newest revision to show. If LIMIT is a number, show no more than this many entries. If LIMIT is a non-empty string, use it as a base revision.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-git.el.gz
(defun vc-git-print-log (files buffer &optional shortlog start-revision limit)
  "Print commit log associated with FILES into specified BUFFER.
If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'.
\(This requires at least Git version 1.5.6, for the --graph option.)
If START-REVISION is non-nil, it is the newest revision to show.
If LIMIT is a number, show no more than this many entries.
If LIMIT is a non-empty string, use it as a base revision."
  (let ((coding-system-for-read
         (or coding-system-for-read vc-git-log-output-coding-system)))
    ;; `vc-do-command' creates the buffer, but we need it before running
    ;; the command.
    (vc-setup-buffer buffer)
    ;; If the buffer exists from a previous invocation it might be
    ;; read-only.
    (let ((inhibit-read-only t)
          ;; In some parts of Git's revision and revision range
          ;; notation, an empty string is equivalent to "HEAD", but not
          ;; everywhere.  For simplicity we'll always be explicit.
          (start-revision (if (member start-revision '(nil ""))
                              "HEAD"
                            start-revision))
          ;; An empty string LIMIT doesn't make sense given the
          ;; specification of this VC backend function, and is tricky to
          ;; deal with in combination with Git's double-dot notation for
          ;; specifying revision ranges.  So discard it right away.
          (limit (and (not (equal limit ""))
                      limit)))
      (with-current-buffer buffer
	(apply #'vc-git-command buffer
	       'async files
	       (append
		'("log" "--no-color")
                (when (and vc-git-print-log-follow
                           (null (cdr files))
                           (car files)
                           (not (file-directory-p (car files))))
                  ;; "--follow" on directories or multiple files is broken
                  ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=8756
                  ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=16422
                  (list "--follow"))
		(when shortlog
		  `("--graph" "--decorate" "--date=short"
                    ,(format "--pretty=tformat:%s"
                             (car vc-git-root-log-format))
                    "--abbrev-commit"))
                (ensure-list
                 (if shortlog vc-git-shortlog-switches vc-git-log-switches))
                (when (numberp limit)
                  (list "-n" (format "%s" limit)))
                (when (eq vc-log-view-type 'with-diff)
                  (list "-p"))
                (list (concat (and (stringp limit)
                                   (concat limit ".."))
                              start-revision))
		'("--")))))))