From: Jari Aalto <jari.aalto@xxxxxxxxx> Signed-off-by: Jari Aalto <jari.aalto@xxxxxxxxx> --- contrib/emacs/git.el | 75 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 74 insertions(+), 1 deletions(-) ** This fixes the pull message. The only change is last line: ** (message "Pulled from remote: %s" remote))) diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 214930a..1999f0c 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1,6 +1,7 @@ ;;; git.el --- A user interface for git ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@xxxxxxxxxx> +;; Copyright (C) 2010 Jari Aalto <jari.aalto@xxxxxxxxx> ;; Version: 1.0 @@ -33,11 +34,14 @@ ;; ;; To start: `M-x git-status' ;; +;; RUDIMENTARY +;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs +;; to access ssh Git remotes. +;; ;; TODO ;; - diff against other branch ;; - renaming files from the status buffer ;; - creating tags -;; - fetch/pull ;; - revlist browser ;; - git-show-branch browser ;; @@ -1520,6 +1524,7 @@ amended version of it." (unless git-status-mode-map (let ((map (make-keymap)) + (remote-map (make-sparse-keymap)) (commit-map (make-sparse-keymap)) (diff-map (make-sparse-keymap)) (toggle-map (make-sparse-keymap))) @@ -1547,6 +1552,7 @@ amended version of it." (define-key map "P" 'git-prev-unmerged-file) (define-key map "q" 'git-status-quit) (define-key map "r" 'git-remove-file) + (define-key map "R" remote-map) (define-key map "t" toggle-map) (define-key map "T" 'git-toggle-all-marks) (define-key map "u" 'git-unmark-file) @@ -1555,6 +1561,13 @@ amended version of it." (define-key map "x" 'git-remove-handled) (define-key map "\C-?" 'git-unmark-file-up) (define-key map "\M-\C-?" 'git-unmark-all) + ; remotes + (define-key remote-map "\C-a" 'git-push) + (define-key remote-map "R" 'git-pull) ; retrieve "RR" + (define-key remote-map "r" 'git-pull) ; retrieve "Rr" (synonym) + (define-key remote-map "p" 'git-push) + (define-key remote-map "f" 'git-fetch) + (define-key remote-map "\C-a" 'git-fetch) ; the commit submap (define-key commit-map "\C-a" 'git-amend-commit) (define-key commit-map "\C-b" 'git-branch) @@ -1607,6 +1620,10 @@ amended version of it." ["Interactive Diff File" git-diff-file-idiff t] ["Log" git-log-file t] "--------" + ["Push" git-push t] + ["Pull" git-pull t] + ["Fetch" git-fetch t] + "--------" ["Mark" git-mark-file t] ["Mark All" git-mark-all t] ["Unmark" git-unmark-file t] @@ -1689,6 +1706,62 @@ Meant to be used in `after-save-hook'." (git-call-process nil "add" "--refresh" "--" filename) (git-update-status-files (list filename)))))))) +(defun git-ask-remote (message) + "Return remote." + (let ((ret + (completing-read + "Push to remote: " + '(("origin" 1)) ;FIXME read all remotes + (not 'predicate) + (not 'match) + "origin"))) + (if (not (string-match "[^ \t]" ret)) + "origin" + ret))) + +(defun git-push (&optional remote) + "Pull to REMOTE. Use \\[current-prefix-arg] to interactively set REMOTE." + (interactive + (list (or (and current-prefix-arg + (git-ask-remote "Push to remote: ")) + "origin"))) + ;; FIXME: could colled some status data for display + (git-call-process-display-error "push" remote) + (git-update-status-files) + (message "Pushed to remote: %s" remote)) + +(defun git-fetch (&optional remote) + "Fetch from REMOTE. Use \\[current-prefix-arg] to interactively set REMOTE." + (interactive + (list (or (and current-prefix-arg + (git-ask-remote "Fetch from remote: ")) + "origin"))) + ;; FIXME: could colled some status data for display + (git-call-process-display-error "fetch" remote) + (git-update-status-files) + (message "Fetched from remote: %s" remote)) + +(defun git-pull (&optional remote) + "Pull from REMOTE. Use \\[current-prefix-arg] to interactively set REMOTE." + (interactive + (list (or (and current-prefix-arg + (git-ask-remote "Pull from remote: ")) + "origin"))) + (let ((not-clean + (ewoc-collect git-status (lambda (info &optional state) + (setq state (git-fileinfo->state info)) + (or (eq state 'modified) + (eq state 'added) + (eq state 'deleted) + (eq state 'unmerged)))))) + (if not-clean + (error "Error: Can't pull while in unclean state (commit all first).")) + (unless git-status (error "Not in git-status buffer.")) + ;; FIXME: could colled some status data for display + (git-call-process-display-error "pull" remote) + (git-update-status-files) + (message "Pulled from remote: %s" remote))) + (defun git-help () "Display help for Git mode." (interactive) -- 1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html