+ (add-text-properties start (point)
+ `(entry-type file file ,(stgit-file-file file)))))
+
+(defun stgit-insert-patch-files (patch)
+ "Expand (show modification of) the patch with name PATCHSYM (a
+symbol) after the line at point.
+`stgit-expand-find-copies-harder' controls how hard to try to
+find copied files."
+ (let* ((start (point))
+ (patchsym (stgit-patch-name patch))
+ (args (list "-r" "-z" (if stgit-expand-find-copies-harder
+ "--find-copies-harder"
+ "-C")))
+ (stgbuf (current-buffer)))
+ (with-temp-buffer
+ (apply 'stgit-run-git "diff-tree"
+ (append args (list (stgit-id patchsym))))
+ (goto-char (point-min))
+ (forward-char 41)
+ (while (looking-at ":\\([0-7]+\\) \\([0-7]+\\) [0-9A-Fa-f]\\{40\\} [0-9A-Fa-f]\\{40\\} ")
+ (let ((old-perm (string-to-number (match-string 1) 8))
+ (new-perm (string-to-number (match-string 2) 8)))
+ (goto-char (match-end 0))
+ (let ((file
+ (cond ((looking-at
+ "\\([CR]\\)\\([0-9]*\\)\0\\([^\0]*\\)\0\\([^\0]*\\)\0")
+ (make-stgit-file
+ :old-perm old-perm
+ :new-perm new-perm
+ :copy-or-rename t
+ :cr-score (string-to-number (match-string 2))
+ :cr-from (match-string 3)
+ :cr-to (match-string 4)
+ :status (stgit-file-status-code (match-string 1))
+ :file (match-string 3)))
+ ((looking-at "\\([ABD-QS-Z]\\)\0\\([^\0]*\\)\0")
+ (make-stgit-file
+ :old-perm old-perm
+ :new-perm new-perm
+ :copy-or-rename nil
+ :cr-score nil
+ :cr-from nil
+ :cr-to nil
+ :status (stgit-file-status-code (match-string 1))
+ :file (match-string 2))))))
+ (with-current-buffer stgbuf
+ (stgit-insert-file file)))
+ (goto-char (match-end 0)))))