 ;;
 ;; TODO
 ;;  - portability to XEmacs
-;;  - better handling of subprocess errors
 ;;  - diff against other branch
 ;;  - renaming files from the status buffer
 ;;  - creating tags

                      (if (or (not (string-equal tree head-tree))
                              (yes-or-no-p "The tree was not modified, do you really want to perform an empty commit? "))
                          (let ((commit (git-commit-tree buffer tree head)))
                            (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
                            (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
                            (with-current-buffer buffer (erase-buffer))
			    (git-update-status-files (git-get-filenames files) 'uptodate)
                            (git-call-process-env nil nil "rerere")
                            (git-call-process-env nil nil "gc" "--auto")
                            (git-refresh-files)
                            (git-refresh-ewoc-hf git-status)
                            (message "Committed %s." commit)
                            (git-run-hook "post-commit" nil))
                        (message "Commit aborted."))))
                (message "No files to commit.")))
          (delete-file index-file))))))

  (when (git-empty-db-p) (error "No commit to amend."))
  (let* ((commit (git-rev-parse "HEAD"))
         (files (git-get-commit-files commit)))
    (when (git-call-process-display-error "reset" "--soft" "HEAD^")
      (git-update-status-files (copy-sequence files) 'uptodate)
      (git-mark-files git-status files)
      (git-refresh-files)
      (git-setup-commit-buffer commit)
      (git-commit-file))))

(defun git-find-file ()
  "Visit the current file in its own buffer."
