(changes)

This commit is contained in:
Marius Vollmer 2008-08-03 22:10:00 +03:00
parent 11e6feef1c
commit 6edd6f3be7

View file

@ -119,38 +119,52 @@
(message "Git is weird."))) (message "Git is weird.")))
(gits-update-status)) (gits-update-status))
;;; Keymap
(defvar gits-keymap nil)
(when (not gits-keymap)
(setq gits-keymap (make-keymap))
(suppress-keymap gits-keymap)
(define-key gits-keymap (kbd "g") 'git-status)
(define-key gits-keymap (kbd "S") 'git-stage-all)
(define-key gits-keymap (kbd "c") 'git-commit))
;;; Status ;;; Status
(defun gits-update-status () (defun gits-update-status ()
(let ((buf (get-buffer "*git-status*"))) (let ((buf (get-buffer "*git-status*")))
(save-excursion (save-excursion
(set-buffer buf) (set-buffer buf)
(erase-buffer) (setq buffer-read-only t)
(insert (format "Repository: %s\n" (use-local-map gits-keymap)
(abbreviate-file-name default-directory))) (let ((inhibit-read-only t))
(let ((branch (gits-get-current-branch))) (erase-buffer)
(insert (format "Branch: %s\n" (insert (format "Repository: %s\n"
(or branch "(detached)"))) (abbreviate-file-name default-directory)))
(if branch (let ((branch (gits-get-current-branch)))
(let ((remote (gits-get "branch" branch "remote"))) (insert (format "Branch: %s\n"
(if remote (or branch "(detached)")))
(let* ((push (gits-get "remote" remote "push")) (if branch
(pull (gits-get "remote" remote "fetch")) (let ((remote (gits-get "branch" branch "remote")))
(desc (if (equal push pull) (if remote
push (let* ((push (gits-get "remote" remote "push"))
(format "%s -> %s" pull push)))) (pull (gits-get "remote" remote "fetch"))
(insert (format "Remote: %s\n %s\n" (desc (if (equal push pull)
desc push
(gits-get "remote" remote "url")))))))) (format "%s -> %s" pull push))))
(insert "\n") (insert (format "Remote: %s\n %s\n"
(insert "Untracked files:\n") desc
(call-process-shell-command "git ls-files --others" nil t) (gits-get "remote" remote "url"))))))))
(insert "\n") (insert "\n")
(insert "Local changes:\n") (insert "Untracked files:\n")
(call-process-shell-command "git diff" nil t) (call-process-shell-command "git ls-files --others" nil t)
(insert "\n") (insert "\n")
(insert "Staged changes:\n") (insert "Local changes:\n")
(call-process-shell-command "git diff --cached" nil t)))) (call-process-shell-command "git diff" nil t)
(insert "\n")
(insert "Staged changes:\n")
(call-process-shell-command "git diff --cached" nil t)))))
;;; Main ;;; Main