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.
This commit is contained in:
Marius Vollmer 2008-08-31 18:30:37 +03:00
parent d49639463a
commit c0d6281dd8

View file

@ -270,6 +270,9 @@ Many Magit faces inherit from this one by default."
(defun magit-file-uptodate-p (file) (defun magit-file-uptodate-p (file)
(eq (magit-shell-exit-code "git diff --quiet %s" file) 0)) (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 ;;; Items
(defvar *magit-item-context* nil) (defvar *magit-item-context* nil)
@ -779,12 +782,15 @@ Please see the manual for a complete description of Magit.
(magit-insert-section 'untracked (magit-insert-section 'untracked
"Untracked files:" 'magit-wash-untracked-files "Untracked files:" 'magit-wash-untracked-files
"git" "ls-files" "--others" "--exclude-standard") "git" "ls-files" "--others" "--exclude-standard")
(magit-insert-section 'unstaged (let ((staged (magit-anything-staged-p)))
"Unstaged changes:" 'magit-wash-diff (magit-insert-section 'unstaged
"git" "diff") (if staged "Unstaged changes:" "Changes:")
(magit-insert-section 'staged 'magit-wash-diff
"Staged changes:" 'magit-wash-diff "git" "diff")
"git" "diff" "--cached") (if staged
(magit-insert-section 'staged
"Staged changes:" 'magit-wash-diff
"git" "diff" "--cached")))
(if remote (if remote
(magit-insert-section 'unpushed (magit-insert-section 'unpushed
"Unpushed commits:" 'magit-wash-log "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")) (write-region "(Empty description)" nil ".git/magit-log"))
(erase-buffer) (erase-buffer)
(apply #'magit-run "git" "commit" "-F" ".git/magit-log" (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) (bury-buffer)
(when magit-pre-log-edit-window-configuration (when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration) (set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil)))) (setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-toggle-amending () (defun magit-log-edit-toggle-amending ()
(interactive) (interactive)
(let* ((fields (magit-log-edit-get-fields)) (let* ((fields (magit-log-edit-get-fields))