emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r115355: Support the new log-edit behavior in vc-git


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r115355: Support the new log-edit behavior in vc-git-log-edit-toggle-amend
Date: Mon, 02 Dec 2013 22:13:59 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115355
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Tue 2013-12-03 00:13:51 +0200
message:
  Support the new log-edit behavior in vc-git-log-edit-toggle-amend
  
  * lisp/vc/log-edit.el (log-edit-set-header): Extract from
  `log-edit-toggle-header'.
  (log-edit-extract-headers): Separate the summary, when extracted
  from header, from the rest of the message with an empty line.
  
  * lisp/vc/vc-git.el (vc-git-log-edit-toggle-amend): Move the summary
  line, if present, to the Summary header.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/vc/log-edit.el            logedit.el-20091113204419-o5vbwnq5f7feedwu-1776
  lisp/vc/vc-git.el              vcgit.el-20091113204419-o5vbwnq5f7feedwu-5070
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-02 19:05:47 +0000
+++ b/lisp/ChangeLog    2013-12-02 22:13:51 +0000
@@ -1,3 +1,13 @@
+2013-12-02  Dmitry Gutov  <address@hidden>
+
+       * vc/log-edit.el (log-edit-set-header): Extract from
+       `log-edit-toggle-header'.
+       (log-edit-extract-headers): Separate the summary, when extracted
+       from header, from the rest of the message with an empty line.
+
+       * vc/vc-git.el (vc-git-log-edit-toggle-amend): Move the summary
+       line, if present, to the Summary header.
+
 2013-12-02  Stefan Monnier  <address@hidden>
 
        * epa-file.el (epa-file-insert-file-contents): Ensure we insert text

=== modified file 'lisp/vc/log-edit.el'
--- a/lisp/vc/log-edit.el       2013-12-02 03:03:40 +0000
+++ b/lisp/vc/log-edit.el       2013-12-02 22:13:51 +0000
@@ -944,10 +944,14 @@
 
 (defun log-edit-toggle-header (header value)
   "Toggle a boolean-type header in the current buffer.
-If the value of HEADER is VALUE, clear it.  Otherwise, add the
-header if it's not present and set it to VALUE.  Then make sure
-there is an empty line after the headers.  Return t if toggled
-on, otherwise nil."
+See `log-edit-set-header' for details."
+  (log-edit-set-header header value t))
+
+(defun log-edit-set-header (header value &optional toggle)
+  "Set the value of HEADER to VALUE in the current buffer.
+If TOGGLE is non-nil, and the value of HEADER already is VALUE,
+clear it.  Make sure there is an empty line after the headers.
+Return t if toggled on (or TOGGLE is nil), otherwise nil."
   (let ((val t)
         (line (concat header ": " value "\n")))
     (save-excursion
@@ -958,7 +962,7 @@
         (if (re-search-forward (concat "^" header ":"
                                        log-edit-header-contents-regexp)
                                nil t)
-            (if (setq val (not (string= (match-string 1) value)))
+            (if (setq val (not (and toggle (string= (match-string 1) value))))
                 (replace-match line t t)
               (replace-match "" t t nil 1))
           (insert line)))
@@ -1006,7 +1010,7 @@
       (goto-char (point-min))
       (when (looking-at "\\([ \t]*\n\\)+")
         (delete-region (match-beginning 0) (match-end 0)))
-      (if summary (insert summary "\n"))
+      (if summary (insert summary "\n\n"))
       (cons (buffer-string) res))))
 
 (provide 'log-edit)

=== modified file 'lisp/vc/vc-git.el'
--- a/lisp/vc/vc-git.el 2013-11-25 02:28:02 +0000
+++ b/lisp/vc/vc-git.el 2013-12-02 22:13:51 +0000
@@ -641,7 +641,17 @@
     (insert (with-output-to-string
               (vc-git-command
                standard-output 1 nil
-               "log" "--max-count=1" "--pretty=format:%B" "HEAD")))))
+               "log" "--max-count=1" "--pretty=format:%B" "HEAD")))
+    (save-excursion
+      (rfc822-goto-eoh)
+      (forward-line 1)
+      (let ((pt (point)))
+        (and (zerop (forward-line 1))
+             (looking-at "\n\\|\\'")
+             (let ((summary (buffer-substring-no-properties pt (1- (point)))))
+               (skip-chars-forward " \n")
+               (delete-region pt (point))
+               (log-edit-set-header "Summary" summary)))))))
 
 (defvar vc-git-log-edit-mode-map
   (let ((map (make-sparse-keymap "Git-Log-Edit")))


reply via email to

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