-(defun stgit-expand-patch (patchsym)
- "Expand (show modification of) the patch with name PATCHSYM (a
-symbol) at point.
-`stgit-expand-find-copies-harder' controls how hard to try to
-find copied files."
- (save-excursion
- (forward-line)
- (let* ((start (point))
- (result (with-output-to-string
- (stgit-run-git "diff-tree" "-r" "-z"
- (if stgit-expand-find-copies-harder
- "--find-copies-harder"
- "-C")
- (stgit-id patchsym)))))
- (let (mstart)
- (while (string-match "\0:\\([0-7]+\\) \\([0-7]+\\) [0-9A-Fa-f]\\{40\\} [0-9A-Fa-f]\\{40\\} \\(\\([CR]\\)\\([0-9]*\\)\0\\([^\0]*\\)\0\\([^\0]*\\)\\|\\([ABD-QS-Z]\\)\0\\([^\0]*\\)\\)"
- result mstart)
- (let ((copy-or-rename (match-string 4 result))
- (old-perm (read (format "#o%s" (match-string 1 result))))
- (new-perm (read (format "#o%s" (match-string 2 result))))
- (line-start (point))
- status
- change
- (properties '(entry-type file)))
- (insert " ")
- (if copy-or-rename
- (let ((cr-score (match-string 5 result))
- (cr-from-file (match-string 6 result))
- (cr-to-file (match-string 7 result)))
- (setq status (stgit-file-status-code copy-or-rename
- cr-score)
- properties (list* 'stgit-old-file cr-from-file
- 'stgit-new-file cr-to-file
- properties)
- change (concat
- cr-from-file
- (propertize " -> "
- 'face 'stgit-description-face)
- cr-to-file)))
- (setq status (stgit-file-status-code (match-string 8 result))
- properties (list* 'stgit-file (match-string 9 result)
- properties)
- change (match-string 9 result)))
-
- (let ((mode-change (stgit-file-mode-change-string old-perm
- new-perm)))
- (insert (format "%-12s" (stgit-file-status-code-as-string
- status))
- mode-change
- (if (> (length mode-change) 0) " " "")
- change
- (propertize (stgit-file-type-change-string old-perm
- new-perm)
- 'face 'stgit-description-face)
- ?\n))
- (add-text-properties line-start (point) properties))
- (setq mstart (match-end 0))))
- (when (= start (point))
- (insert " <no files>\n"))
- (put-text-property start (point) 'stgit-file-patchsym patchsym))))
-
-(defun stgit-collapse-patch (patchsym)
- "Collapse the patch with name PATCHSYM after the line at point."
- (save-excursion
- (forward-line)
- (let ((start (point)))
- (while (eq (get-text-property (point) 'stgit-file-patchsym) patchsym)
- (forward-line))
- (delete-region start (point)))))
-
-(defun stgit-rescan ()
- "Rescan the status buffer."
- (save-excursion
- (let ((marked ())
- found-any)
- (goto-char (point-min))
- (while (not (eobp))
- (cond ((looking-at "Branch: \\(.*\\)")
- (put-text-property (match-beginning 1) (match-end 1)
- 'face 'bold))
- ((looking-at "\\([0 ]\\)\\([>+-]\\)\\( \\)\\([^ ]+\\) *[|#] \\(.*\\)")
- (setq found-any t)
- (let ((empty (string= (match-string 1) "0"))
- (state (match-string 2))
- (patchsym (intern (match-string 4))))
- (put-text-property
- (match-beginning 4) (match-end 4) 'face
- (cond ((string= state ">") 'stgit-top-patch-face)
- ((string= state "+") 'stgit-applied-patch-face)
- ((string= state "-") 'stgit-unapplied-patch-face)))
- (put-text-property (match-beginning 5) (match-end 5)
- 'face 'stgit-description-face)
- (when (memq patchsym stgit-marked-patches)
- (save-excursion
- (replace-match "*" nil nil nil 3))
- (setq marked (cons patchsym marked)))
- (add-text-properties (match-beginning 0) (match-end 0)
- (list 'stgit-patchsym patchsym
- 'entry-type 'patch
- 'patch-data (make-stgit-patch
- :status state
- :name patchsym
- :desc (match-string 5)
- :empty empty)))
- (when (memq patchsym stgit-expanded-patches)
- (stgit-expand-patch patchsym))
- (when empty
- (save-excursion
- (goto-char (match-beginning 5))
- (insert "(empty) ")))
- (delete-char 1)
- ))
- ((or (looking-at "stg series: Branch \".*\" not initialised")
- (looking-at "stg series: .*: branch not initialized"))
- (setq found-any t)
- (forward-line 1)
- (insert "Run M-x stgit-init to initialise")))
- (forward-line 1))
- (setq stgit-marked-patches (nreverse marked))
- (unless found-any
- (insert "\n "
- (propertize "no patches in series"
- 'face 'stgit-description-face))))))
+(defun stgit-insert-patch-files (patchsym)
+ (let* ((start (point))
+ (result (with-output-to-string
+ (stgit-run-git "diff-tree" "-r" "-z"
+ (if stgit-expand-find-copies-harder
+ "--find-copies-harder"
+ "-C")
+ (stgit-id patchsym)))))
+ (let (mstart)
+ (while (string-match "\0:\\([0-7]+\\) \\([0-7]+\\) [0-9A-Fa-f]\\{40\\} [0-9A-Fa-f]\\{40\\} \\(\\([CR]\\)\\([0-9]*\\)\0\\([^\0]*\\)\0\\([^\0]*\\)\\|\\([ABD-QS-Z]\\)\0\\([^\0]*\\)\\)"
+ result mstart)
+ (let ((copy-or-rename (match-string 4 result))
+ (old-perm (read (format "#o%s" (match-string 1 result))))
+ (new-perm (read (format "#o%s" (match-string 2 result))))
+ (line-start (point))
+ status
+ change
+ (properties '(entry-type file)))
+ (if copy-or-rename
+ (let ((cr-score (match-string 5 result))
+ (cr-from-file (match-string 6 result))
+ (cr-to-file (match-string 7 result)))
+ (setq status (stgit-file-status-code copy-or-rename
+ cr-score)
+ properties (list* 'stgit-old-file cr-from-file
+ 'stgit-new-file cr-to-file
+ properties)
+ change (concat
+ cr-from-file
+ (propertize " -> "
+ 'face 'stgit-description-face)
+ cr-to-file)))
+ (setq status (stgit-file-status-code (match-string 8 result))
+ properties (list* 'stgit-file (match-string 9 result)
+ properties)
+ change (match-string 9 result)))
+
+ (let ((mode-change (stgit-file-mode-change-string old-perm
+ new-perm)))
+ (insert "\n "
+ (format "%-12s" (stgit-file-status-code-as-string
+ status))
+ mode-change
+ (if (> (length mode-change) 0) " " "")
+ change
+ (propertize (stgit-file-type-change-string old-perm
+ new-perm)
+ 'face 'stgit-description-face)))
+ (add-text-properties line-start (point) properties))
+ (setq mstart (match-end 0))))
+ (when (= start (point))
+ (insert " <no files>\n"))
+ (put-text-property start (point) 'stgit-file-patchsym patchsym)))