From c0d6281dd81cdcda00d9f036c3eddebe64c730bd Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 31 Aug 2008 18:30:37 +0300 Subject: [PATCH] Support for committing without staging. * magit.el (magit-anything-staged-p): New. (magit-update-status): Use it to determine name of the 'unstaged' section. (magit-log-edit-commit): Pass "--all" to git commit when nothing is staged. --- magit.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/magit.el b/magit.el index 85763851..efed7b90 100644 --- a/magit.el +++ b/magit.el @@ -270,6 +270,9 @@ Many Magit faces inherit from this one by default." (defun magit-file-uptodate-p (file) (eq (magit-shell-exit-code "git diff --quiet %s" file) 0)) +(defun magit-anything-staged-p () + (not (eq (magit-shell-exit-code "git diff --quiet --cached") 0))) + ;;; Items (defvar *magit-item-context* nil) @@ -779,12 +782,15 @@ Please see the manual for a complete description of Magit. (magit-insert-section 'untracked "Untracked files:" 'magit-wash-untracked-files "git" "ls-files" "--others" "--exclude-standard") - (magit-insert-section 'unstaged - "Unstaged changes:" 'magit-wash-diff - "git" "diff") - (magit-insert-section 'staged - "Staged changes:" 'magit-wash-diff - "git" "diff" "--cached") + (let ((staged (magit-anything-staged-p))) + (magit-insert-section 'unstaged + (if staged "Unstaged changes:" "Changes:") + 'magit-wash-diff + "git" "diff") + (if staged + (magit-insert-section 'staged + "Staged changes:" 'magit-wash-diff + "git" "diff" "--cached"))) (if remote (magit-insert-section 'unpushed "Unpushed commits:" 'magit-wash-log @@ -1100,12 +1106,13 @@ Please see the manual for a complete description of Magit. (write-region "(Empty description)" nil ".git/magit-log")) (erase-buffer) (apply #'magit-run "git" "commit" "-F" ".git/magit-log" - (if amend '("--amend") '())) + (append (if (not (magit-anything-staged-p)) '("--all") '()) + (if amend '("--amend") '()))) (bury-buffer) (when magit-pre-log-edit-window-configuration (set-window-configuration magit-pre-log-edit-window-configuration) (setq magit-pre-log-edit-window-configuration nil)))) - + (defun magit-log-edit-toggle-amending () (interactive) (let* ((fields (magit-log-edit-get-fields))