--- magit.el.orig 2013-10-18 01:31:47.656242000 +0900 +++ magit.el 2013-10-26 22:27:35.005126200 +0900 @@ -394,7 +394,9 @@ magit-insert-unstaged-changes magit-insert-staged-changes magit-insert-unpulled-commits - magit-insert-unpushed-commits) + magit-insert-unpushed-commits + magit-insert-cached-files + ) "Hook run to insert sections into the status buffer. This option allows reordering the sections and adding sections @@ -436,6 +438,12 @@ :type '(choice (const :tag "show only directory" nil) (const :tag "show directory contents" t))) +(defcustom magit-status-verbose-cached t + "Whether to show the contents of or just the cached directory." + :group 'magit + :type '(choice (const :tag "show only directory" nil) + (const :tag "show directory contents" t))) + (defcustom magit-process-popup-time -1 "Popup the process buffer if a command takes longer than this many seconds." :group 'magit @@ -2368,6 +2376,7 @@ (magit-define-section-jumper stashes "Stashes") (magit-define-section-jumper untracked "Untracked files") +(magit-define-section-jumper cached "Cached files") (magit-define-section-jumper unstaged "Unstaged changes") (magit-define-section-jumper staged "Staged changes") (magit-define-section-jumper unpulled "Unpulled commits") @@ -4343,6 +4352,34 @@ (insert "\t" file "\n"))) t))))) +(magit-define-inserter cached-files () + (unless (string= (magit-get "status" "showCachedFiles") "no") + (apply 'magit-git-section + `(cached + "Cached files:" + magit-wash-cached-files + "ls-files" "-t" "--exclude-standard" + ,@(unless magit-status-verbose-cached + '("--directory")))))) + +(defun magit-wash-cached-files () + (magit-wash-sequence + (lambda () + (let ((magit-old-top-section nil)) + (if (looking-at "^H \\(.*\\)$") + (progn + (let ((file (magit-decode-git-path + (match-string-no-properties 1)))) + (delete-region (point) (+ (line-end-position) 1)) + (magit-with-section file 'file + (magit-set-section-info file) + (insert "\t" file "\n"))) + t) + (progn + (delete-region (point) (+ (line-end-position) 1)) + t)) + )))) + (magit-define-inserter pending-commits () (let* ((info (magit-read-rewrite-info)) (pending (cdr (assq 'pending info)))) @@ -6323,6 +6360,7 @@ (file (magit-section-action (item info "visit-file") ((untracked file) info) + ((cached file) info) ((diff) (magit-diff-item-file item)) ((diffstat) (magit-section-info item)) ((hunk) @@ -6365,6 +6403,8 @@ (magit-section-action (item info "visit") ((untracked file) (call-interactively 'magit-visit-file-item)) + ((cached file) + (call-interactively 'magit-visit-file-item)) ((diff) (call-interactively 'magit-visit-file-item)) ((diffstat)