Function: log-edit-insert-changelog-entry

log-edit-insert-changelog-entry is a byte-compiled function defined in log-edit.el.gz.

Signature

(log-edit-insert-changelog-entry BUFFER)

Documentation

Use body of ChangeLog entry in BUFFER as commit message.

Insert the body of the latest entry in the ChangeLog file that BUFFER is visiting into the "*vc-log*" buffer. If the first line of the body does not begin with "* ", move it to the Summary header in the
"*vc-log*" buffer, thus making is the summary line of the commit
message.

If the set of files listed in the ChangeLog entry differs from the set of files with changes to commit according to VC, display a warning urging the user to correct this discrepancy before committing the changes.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/log-edit.el.gz
(defun log-edit-insert-changelog-entry (buffer)
  "Use body of ChangeLog entry in BUFFER as commit message.
Insert the body of the latest entry in the ChangeLog file that BUFFER is
visiting into the \"*vc-log*\" buffer.  If the first line of the body
does not begin with \"* \", move it to the Summary header in the
\"*vc-log*\" buffer, thus making is the summary line of the commit
message.

If the set of files listed in the ChangeLog entry differs from the set
of files with changes to commit according to VC, display a warning
urging the user to correct this discrepancy before committing the
changes."
  (let (summary beg end files-in-changelog)
    (with-current-buffer buffer
      (save-restriction
        (log-edit-narrow-changelog)
        (setq summary (let ((s (buffer-substring-no-properties
                               (pos-bol) (pos-eol))))
                        (and (string-match "^\t\\([^*].+\\)$" s)
                             (match-string 1 s)))
              beg (or (and summary (forward-line)
                           (skip-syntax-forward "\s-")
                           (goto-char (pos-bol)))
                      (point))
              end (point-max))
        ;; List of changed files according to the ChangeLog entry.
        (save-excursion
          (let* ((bfn (buffer-file-name buffer))
                 (bn (buffer-name))
                 (fnd (or (and bfn (file-name-directory bfn))
                          ;; If ChangeLog buffer is not visiting a file,
                          ;; extract the directory from the buffer name.
                          (and
                           (string-match "\\`\\*changes to \\(.+\\)\\*\\'" bn)
                           (match-string 1 bn)))))
            (while (re-search-forward "\t\\* \\([^ :\n]+\\)[ :\n]" nil t)
              (let ((fn (expand-file-name
                         (concat fnd (match-string-no-properties 1)))))
                (when (file-exists-p fn)
                  (push fn files-in-changelog))))))))
    (log-edit-changelog-insert-entries buffer beg end)
    (when summary (log-edit-set-header "Summary" summary))
    (unless (seq-set-equal-p
             (save-current-buffer
               (nth 2 (vc-deduce-fileset nil nil 'state-model-only-files)))
             files-in-changelog)
      (display-warning
       'log-edit
       "Files in ChangeLog entry differ from files with changes to commit!
Remove this discrepancy before committing the changes by adjusting as
appropriate either the ChangeLog entry or the selection of files to commit."))))