   (interactive)
   (git-status default-directory))
 
+(defun gitsum-switch-from-git-status ()
+  "Switch to gitsum, resticting diff to marked files if any."
+  (interactive)
+  (let ((marked (git-get-filenames
+                 (ewoc-collect git-status
+                               (lambda (info) (git-fileinfo->marked info))))))
+    (gitsum)
+    (when marked
+      (gitsum-refresh (mapconcat 'identity marked " ")))))
+
 (defun gitsum ()
   "Entry point into gitsum-diff-mode."
   (interactive)

  (let ((inhibit-read-only t))
    (undo)))

(defun gitsum-refresh ()
  "Regenerate the patch based on the current state of the index."
  (interactive)
  (let ((inhibit-read-only t))

    (insert "# Directory:  " default-directory "\n")
    (insert "# Use n and p to navigate and k to kill a hunk.  u is undo, g will refresh.\n")
    (insert "# Edit the patch as you please and press 'c' to commit.\n\n")
    (let ((diff (shell-command-to-string (concat "git diff " arguments))))
      (if (zerop (length diff))
          (insert "## No changes. ##")
        (insert diff)
