{"thread":{"id":"26829","subject":"[PATCH] git.el: Add new user functions for push, pull, fetch.","startedAt":"2011-03-22T13:30:51Z","lastAt":"2011-04-14T21:07:13Z","messageCount":6,"participants":["jari.aalto@cante.net","Jari Aalto","Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"164049","messageId":"1300800651-12502-1-git-send-email-jari.aalto@cante.net","threadId":"26829","inReplyTo":null,"subject":"[PATCH] git.el: Add new user functions for push, pull, fetch.","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2011-03-22T13:30:51Z","receivedAt":"2011-03-22T13:30:51Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n contrib/emacs/git.el |   75 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 74 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 214930a..20a3b2c 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1,6 +1,7 @@\n ;;; git.el --- A user interface for git\n \n ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@winehq.org>\n+;; Copyright (C) 2010 Jari Aalto <jari.aalto@cante.net>\n \n ;; Version: 1.0\n \n@@ -33,11 +34,14 @@\n ;;\n ;; To start: `M-x git-status'\n ;;\n+;; RUDIMENTARY\n+;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs\n+;;   to access ssh Git remotes.\n+;;\n ;; TODO\n ;;  - diff against other branch\n ;;  - renaming files from the status buffer\n ;;  - creating tags\n-;;  - fetch/pull\n ;;  - revlist browser\n ;;  - git-show-branch browser\n ;;\n@@ -1520,6 +1524,7 @@ amended version of it.\"\n \n (unless git-status-mode-map\n   (let ((map (make-keymap))\n+        (remote-map (make-sparse-keymap))\n         (commit-map (make-sparse-keymap))\n         (diff-map (make-sparse-keymap))\n         (toggle-map (make-sparse-keymap)))\n@@ -1547,6 +1552,7 @@ amended version of it.\"\n     (define-key map \"P\"   'git-prev-unmerged-file)\n     (define-key map \"q\"   'git-status-quit)\n     (define-key map \"r\"   'git-remove-file)\n+    (define-key map \"R\"   remote-map)\n     (define-key map \"t\"    toggle-map)\n     (define-key map \"T\"   'git-toggle-all-marks)\n     (define-key map \"u\"   'git-unmark-file)\n@@ -1555,6 +1561,13 @@ amended version of it.\"\n     (define-key map \"x\"   'git-remove-handled)\n     (define-key map \"\\C-?\" 'git-unmark-file-up)\n     (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n+    ; remotes\n+    (define-key remote-map \"\\C-a\" 'git-push)\n+    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n+    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n+    (define-key remote-map \"p\" 'git-push)\n+    (define-key remote-map \"f\" 'git-fetch)\n+    (define-key remote-map \"\\C-a\" 'git-fetch)\n     ; the commit submap\n     (define-key commit-map \"\\C-a\" 'git-amend-commit)\n     (define-key commit-map \"\\C-b\" 'git-branch)\n@@ -1607,6 +1620,10 @@ amended version of it.\"\n       [\"Interactive Diff File\" git-diff-file-idiff t]\n       [\"Log\" git-log-file t]\n       \"--------\"\n+      [\"Push\" git-push t]\n+      [\"Pull\" git-pull t]\n+      [\"Fetch\" git-fetch t]\n+      \"--------\"\n       [\"Mark\" git-mark-file t]\n       [\"Mark All\" git-mark-all t]\n       [\"Unmark\" git-unmark-file t]\n@@ -1689,6 +1706,62 @@ Meant to be used in `after-save-hook'.\"\n             (git-call-process nil \"add\" \"--refresh\" \"--\" filename)\n             (git-update-status-files (list filename))))))))\n \n+(defun git-ask-remote (message)\n+  \"Return remote.\"\n+  (let ((ret\n+\t (completing-read\n+\t  \"Push to remote: \"\n+\t  '((\"origin\" 1))\t\t;FIXME read all remotes\n+\t  (not 'predicate)\n+\t  (not 'match)\n+\t  \"origin\")))\n+    (if (not (string-match \"[^ \\t]\" ret))\n+\t\"origin\"\n+      ret)))\n+\n+(defun git-push (&optional remote)\n+  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Push to remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"push\" remote)\n+  (git-update-status-files)\n+  (message \"Pushed to remote: %s\" remote))\n+\n+(defun git-fetch (&optional remote)\n+  \"Fetch from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Fetch from remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"fetch\" remote)\n+  (git-update-status-files)\n+  (message \"Fetched from remote: %s\" remote))\n+\n+(defun git-pull (&optional remote)\n+  \"Pull from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Pull from remote: \"))\n+\t     \"origin\")))\n+  (let ((not-clean\n+\t (ewoc-collect git-status (lambda (info &optional state)\n+\t\t\t\t    (setq state (git-fileinfo->state info))\n+\t\t\t\t    (or (eq state 'modified)\n+\t\t\t\t\t(eq state 'added)\n+\t\t\t\t\t(eq state 'deleted)\n+\t\t\t\t\t(eq state 'unmerged))))))\n+    (if not-clean\n+\t(error \"Error: Can't pull while in unclean state (commit all first).\"))\n+    (unless git-status (error \"Not in git-status buffer.\"))\n+    ;; FIXME: could colled some status data for display\n+    (git-call-process-display-error \"pull\" remote)\n+    (git-update-status-files)\n+    (message \"Pushed to remote: %s\" remote)))\n+\n (defun git-help ()\n   \"Display help for Git mode.\"\n   (interactive)\n-- \n1.7.2.3\n"},{"id":"164054","messageId":"d40ef57d7e6d75c41a4d1f8e51bdd892351f3aee.1300804459.git.jari.aalto@cante.net","threadId":"26829","inReplyTo":"1300800651-12502-1-git-send-email-jari.aalto@cante.net","subject":"[PATCH v2] contrib/emacs/git.el: Add user functions for push, pull, fetch","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2011-03-22T14:36:13Z","receivedAt":"2011-03-22T14:36:13Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n contrib/emacs/git.el |   75 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 74 insertions(+), 1 deletions(-)\n\n  ** This fixes the pull message. The only change is last line:\n  ** (message \"Pulled from remote: %s\" remote)))\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 214930a..1999f0c 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1,6 +1,7 @@\n ;;; git.el --- A user interface for git\n \n ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@winehq.org>\n+;; Copyright (C) 2010 Jari Aalto <jari.aalto@cante.net>\n \n ;; Version: 1.0\n \n@@ -33,11 +34,14 @@\n ;;\n ;; To start: `M-x git-status'\n ;;\n+;; RUDIMENTARY\n+;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs\n+;;   to access ssh Git remotes.\n+;;\n ;; TODO\n ;;  - diff against other branch\n ;;  - renaming files from the status buffer\n ;;  - creating tags\n-;;  - fetch/pull\n ;;  - revlist browser\n ;;  - git-show-branch browser\n ;;\n@@ -1520,6 +1524,7 @@ amended version of it.\"\n \n (unless git-status-mode-map\n   (let ((map (make-keymap))\n+        (remote-map (make-sparse-keymap))\n         (commit-map (make-sparse-keymap))\n         (diff-map (make-sparse-keymap))\n         (toggle-map (make-sparse-keymap)))\n@@ -1547,6 +1552,7 @@ amended version of it.\"\n     (define-key map \"P\"   'git-prev-unmerged-file)\n     (define-key map \"q\"   'git-status-quit)\n     (define-key map \"r\"   'git-remove-file)\n+    (define-key map \"R\"   remote-map)\n     (define-key map \"t\"    toggle-map)\n     (define-key map \"T\"   'git-toggle-all-marks)\n     (define-key map \"u\"   'git-unmark-file)\n@@ -1555,6 +1561,13 @@ amended version of it.\"\n     (define-key map \"x\"   'git-remove-handled)\n     (define-key map \"\\C-?\" 'git-unmark-file-up)\n     (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n+    ; remotes\n+    (define-key remote-map \"\\C-a\" 'git-push)\n+    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n+    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n+    (define-key remote-map \"p\" 'git-push)\n+    (define-key remote-map \"f\" 'git-fetch)\n+    (define-key remote-map \"\\C-a\" 'git-fetch)\n     ; the commit submap\n     (define-key commit-map \"\\C-a\" 'git-amend-commit)\n     (define-key commit-map \"\\C-b\" 'git-branch)\n@@ -1607,6 +1620,10 @@ amended version of it.\"\n       [\"Interactive Diff File\" git-diff-file-idiff t]\n       [\"Log\" git-log-file t]\n       \"--------\"\n+      [\"Push\" git-push t]\n+      [\"Pull\" git-pull t]\n+      [\"Fetch\" git-fetch t]\n+      \"--------\"\n       [\"Mark\" git-mark-file t]\n       [\"Mark All\" git-mark-all t]\n       [\"Unmark\" git-unmark-file t]\n@@ -1689,6 +1706,62 @@ Meant to be used in `after-save-hook'.\"\n             (git-call-process nil \"add\" \"--refresh\" \"--\" filename)\n             (git-update-status-files (list filename))))))))\n \n+(defun git-ask-remote (message)\n+  \"Return remote.\"\n+  (let ((ret\n+\t (completing-read\n+\t  \"Push to remote: \"\n+\t  '((\"origin\" 1))\t\t;FIXME read all remotes\n+\t  (not 'predicate)\n+\t  (not 'match)\n+\t  \"origin\")))\n+    (if (not (string-match \"[^ \\t]\" ret))\n+\t\"origin\"\n+      ret)))\n+\n+(defun git-push (&optional remote)\n+  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Push to remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"push\" remote)\n+  (git-update-status-files)\n+  (message \"Pushed to remote: %s\" remote))\n+\n+(defun git-fetch (&optional remote)\n+  \"Fetch from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Fetch from remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"fetch\" remote)\n+  (git-update-status-files)\n+  (message \"Fetched from remote: %s\" remote))\n+\n+(defun git-pull (&optional remote)\n+  \"Pull from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Pull from remote: \"))\n+\t     \"origin\")))\n+  (let ((not-clean\n+\t (ewoc-collect git-status (lambda (info &optional state)\n+\t\t\t\t    (setq state (git-fileinfo->state info))\n+\t\t\t\t    (or (eq state 'modified)\n+\t\t\t\t\t(eq state 'added)\n+\t\t\t\t\t(eq state 'deleted)\n+\t\t\t\t\t(eq state 'unmerged))))))\n+    (if not-clean\n+\t(error \"Error: Can't pull while in unclean state (commit all first).\"))\n+    (unless git-status (error \"Not in git-status buffer.\"))\n+    ;; FIXME: could colled some status data for display\n+    (git-call-process-display-error \"pull\" remote)\n+    (git-update-status-files)\n+    (message \"Pulled from remote: %s\" remote)))\n+\n (defun git-help ()\n   \"Display help for Git mode.\"\n   (interactive)\n-- \n1.7.2.3\n"},{"id":"165001","messageId":"87tyef9uu5.fsf@picasso.cante.net","threadId":"26829","inReplyTo":"d40ef57d7e6d75c41a4d1f8e51bdd892351f3aee.1300804459.git.jari.aalto@cante.net","subject":"Re: [PATCH v2] contrib/emacs/git.el: Add user functions for push, pull, fetch","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2011-04-03T16:13:22Z","receivedAt":"2011-04-03T16:13:22Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n contrib/emacs/git.el |   75 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 74 insertions(+), 1 deletions(-)\n\n  [2011-03-22 original message]\n  [2011-04-03 This is a ping ...]\n\n  ** This fixes the pull message. The only change is last line:\n  ** (message \"Pulled from remote: %s\" remote)))\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 214930a..1999f0c 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1,6 +1,7 @@\n ;;; git.el --- A user interface for git\n \n ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@winehq.org>\n+;; Copyright (C) 2010 Jari Aalto <jari.aalto@cante.net>\n \n ;; Version: 1.0\n \n@@ -33,11 +34,14 @@\n ;;\n ;; To start: `M-x git-status'\n ;;\n+;; RUDIMENTARY\n+;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs\n+;;   to access ssh Git remotes.\n+;;\n ;; TODO\n ;;  - diff against other branch\n ;;  - renaming files from the status buffer\n ;;  - creating tags\n-;;  - fetch/pull\n ;;  - revlist browser\n ;;  - git-show-branch browser\n ;;\n@@ -1520,6 +1524,7 @@ amended version of it.\"\n \n (unless git-status-mode-map\n   (let ((map (make-keymap))\n+        (remote-map (make-sparse-keymap))\n         (commit-map (make-sparse-keymap))\n         (diff-map (make-sparse-keymap))\n         (toggle-map (make-sparse-keymap)))\n@@ -1547,6 +1552,7 @@ amended version of it.\"\n     (define-key map \"P\"   'git-prev-unmerged-file)\n     (define-key map \"q\"   'git-status-quit)\n     (define-key map \"r\"   'git-remove-file)\n+    (define-key map \"R\"   remote-map)\n     (define-key map \"t\"    toggle-map)\n     (define-key map \"T\"   'git-toggle-all-marks)\n     (define-key map \"u\"   'git-unmark-file)\n@@ -1555,6 +1561,13 @@ amended version of it.\"\n     (define-key map \"x\"   'git-remove-handled)\n     (define-key map \"\\C-?\" 'git-unmark-file-up)\n     (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n+    ; remotes\n+    (define-key remote-map \"\\C-a\" 'git-push)\n+    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n+    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n+    (define-key remote-map \"p\" 'git-push)\n+    (define-key remote-map \"f\" 'git-fetch)\n+    (define-key remote-map \"\\C-a\" 'git-fetch)\n     ; the commit submap\n     (define-key commit-map \"\\C-a\" 'git-amend-commit)\n     (define-key commit-map \"\\C-b\" 'git-branch)\n@@ -1607,6 +1620,10 @@ amended version of it.\"\n       [\"Interactive Diff File\" git-diff-file-idiff t]\n       [\"Log\" git-log-file t]\n       \"--------\"\n+      [\"Push\" git-push t]\n+      [\"Pull\" git-pull t]\n+      [\"Fetch\" git-fetch t]\n+      \"--------\"\n       [\"Mark\" git-mark-file t]\n       [\"Mark All\" git-mark-all t]\n       [\"Unmark\" git-unmark-file t]\n@@ -1689,6 +1706,62 @@ Meant to be used in `after-save-hook'.\"\n             (git-call-process nil \"add\" \"--refresh\" \"--\" filename)\n             (git-update-status-files (list filename))))))))\n \n+(defun git-ask-remote (message)\n+  \"Return remote.\"\n+  (let ((ret\n+\t (completing-read\n+\t  \"Push to remote: \"\n+\t  '((\"origin\" 1))\t\t;FIXME read all remotes\n+\t  (not 'predicate)\n+\t  (not 'match)\n+\t  \"origin\")))\n+    (if (not (string-match \"[^ \\t]\" ret))\n+\t\"origin\"\n+      ret)))\n+\n+(defun git-push (&optional remote)\n+  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Push to remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"push\" remote)\n+  (git-update-status-files)\n+  (message \"Pushed to remote: %s\" remote))\n+\n+(defun git-fetch (&optional remote)\n+  \"Fetch from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Fetch from remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could colled some status data for display\n+  (git-call-process-display-error \"fetch\" remote)\n+  (git-update-status-files)\n+  (message \"Fetched from remote: %s\" remote))\n+\n+(defun git-pull (&optional remote)\n+  \"Pull from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Pull from remote: \"))\n+\t     \"origin\")))\n+  (let ((not-clean\n+\t (ewoc-collect git-status (lambda (info &optional state)\n+\t\t\t\t    (setq state (git-fileinfo->state info))\n+\t\t\t\t    (or (eq state 'modified)\n+\t\t\t\t\t(eq state 'added)\n+\t\t\t\t\t(eq state 'deleted)\n+\t\t\t\t\t(eq state 'unmerged))))))\n+    (if not-clean\n+\t(error \"Error: Can't pull while in unclean state (commit all first).\"))\n+    (unless git-status (error \"Not in git-status buffer.\"))\n+    ;; FIXME: could colled some status data for display\n+    (git-call-process-display-error \"pull\" remote)\n+    (git-update-status-files)\n+    (message \"Pulled from remote: %s\" remote)))\n+\n (defun git-help ()\n   \"Display help for Git mode.\"\n   (interactive)\n"},{"id":"165065","messageId":"87mxk7454z.fsf@wine.dyndns.org","threadId":"26829","inReplyTo":"87tyef9uu5.fsf@picasso.cante.net","subject":"Re: [PATCH v2] contrib/emacs/git.el: Add user functions for push, pull, fetch","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2011-04-03T17:27:24Z","receivedAt":"2011-04-03T17:27:24Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Jari Aalto <jari.aalto@cante.net> writes:\n\n> @@ -1555,6 +1561,13 @@ amended version of it.\"\n>      (define-key map \"x\"   'git-remove-handled)\n>      (define-key map \"\\C-?\" 'git-unmark-file-up)\n>      (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n> +    ; remotes\n> +    (define-key remote-map \"\\C-a\" 'git-push)\n> +    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n> +    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n> +    (define-key remote-map \"p\" 'git-push)\n> +    (define-key remote-map \"f\" 'git-fetch)\n> +    (define-key remote-map \"\\C-a\" 'git-fetch)\n\nThe \\C-a things look strange.\n\n> +(defun git-push (&optional remote)\n> +  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n> +  (interactive\n> +   (list (or (and current-prefix-arg\n> +\t\t  (git-ask-remote \"Push to remote: \"))\n> +\t     \"origin\")))\n> +  ;; FIXME: could colled some status data for display\n> +  (git-call-process-display-error \"push\" remote)\n> +  (git-update-status-files)\n> +  (message \"Pushed to remote: %s\" remote))\n\nYou shouldn't display a success message if the call failed. Also there's\nno need to refresh the status files on push or fetch.\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"165066","messageId":"ae4f9adf62502f58a870a322cd30a62e23aba747.1301852577.git.jari.aalto@cante.net","threadId":"26829","inReplyTo":"87mxk7454z.fsf@wine.dyndns.org","subject":"[PATCH v3] contrib/emacs/git.el: Add user functions for push, pull, fetch","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2011-04-03T17:48:00Z","receivedAt":"2011-04-03T17:48:00Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n contrib/emacs/git.el |   70 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 69 insertions(+), 1 deletions(-)\n\n  [v2]\n  ** This fixes the pull message. The only change is last line:\n  ** (message \"Pulled from remote: %s\" remote)))\n\n  [v3] Fixes commented by <julliard@winehq.org>\n  ** Extra C-a keymap binding removed\n  ** Check success status before displaying message\n  ** no need to refresh the status files on push or fetch\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 214930a..26510d2 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1,6 +1,7 @@\n ;;; git.el --- A user interface for git\n \n ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@winehq.org>\n+;; Copyright (C) 2010 Jari Aalto <jari.aalto@cante.net>\n \n ;; Version: 1.0\n \n@@ -33,11 +34,14 @@\n ;;\n ;; To start: `M-x git-status'\n ;;\n+;; RUDIMENTARY\n+;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs\n+;;   to access ssh Git remotes.\n+;;\n ;; TODO\n ;;  - diff against other branch\n ;;  - renaming files from the status buffer\n ;;  - creating tags\n-;;  - fetch/pull\n ;;  - revlist browser\n ;;  - git-show-branch browser\n ;;\n@@ -1520,6 +1524,7 @@ amended version of it.\"\n \n (unless git-status-mode-map\n   (let ((map (make-keymap))\n+        (remote-map (make-sparse-keymap))\n         (commit-map (make-sparse-keymap))\n         (diff-map (make-sparse-keymap))\n         (toggle-map (make-sparse-keymap)))\n@@ -1547,6 +1552,7 @@ amended version of it.\"\n     (define-key map \"P\"   'git-prev-unmerged-file)\n     (define-key map \"q\"   'git-status-quit)\n     (define-key map \"r\"   'git-remove-file)\n+    (define-key map \"R\"   remote-map)\n     (define-key map \"t\"    toggle-map)\n     (define-key map \"T\"   'git-toggle-all-marks)\n     (define-key map \"u\"   'git-unmark-file)\n@@ -1555,6 +1561,11 @@ amended version of it.\"\n     (define-key map \"x\"   'git-remove-handled)\n     (define-key map \"\\C-?\" 'git-unmark-file-up)\n     (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n+    ; remotes\n+    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n+    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n+    (define-key remote-map \"p\" 'git-push)\n+    (define-key remote-map \"f\" 'git-fetch)\n     ; the commit submap\n     (define-key commit-map \"\\C-a\" 'git-amend-commit)\n     (define-key commit-map \"\\C-b\" 'git-branch)\n@@ -1607,6 +1618,10 @@ amended version of it.\"\n       [\"Interactive Diff File\" git-diff-file-idiff t]\n       [\"Log\" git-log-file t]\n       \"--------\"\n+      [\"Push\" git-push t]\n+      [\"Pull\" git-pull t]\n+      [\"Fetch\" git-fetch t]\n+      \"--------\"\n       [\"Mark\" git-mark-file t]\n       [\"Mark All\" git-mark-all t]\n       [\"Unmark\" git-unmark-file t]\n@@ -1689,6 +1704,59 @@ Meant to be used in `after-save-hook'.\"\n             (git-call-process nil \"add\" \"--refresh\" \"--\" filename)\n             (git-update-status-files (list filename))))))))\n \n+(defun git-ask-remote (message)\n+  \"Return remote.\"\n+  (let ((ret\n+\t (completing-read\n+\t  \"Push to remote: \"\n+\t  '((\"origin\" 1))\t\t;FIXME read all remotes\n+\t  (not 'predicate)\n+\t  (not 'match)\n+\t  \"origin\")))\n+    (if (not (string-match \"[^ \\t]\" ret))\n+\t\"origin\"\n+      ret)))\n+\n+(defun git-push (&optional remote)\n+  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Push to remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could collect some status data for display\n+  (when (git-call-process-display-error \"push\" remote)\n+    (message \"Pushed to remote: %s\" remote)))\n+\n+(defun git-fetch (&optional remote)\n+  \"Fetch from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Fetch from remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could collect some status data for display\n+  (when (git-call-process-display-error \"fetch\" remote)\n+    (message \"Fetched from remote: %s\" remote)))\n+\n+(defun git-pull (&optional remote)\n+  \"Pull from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Pull from remote: \"))\n+\t     \"origin\")))\n+  (let ((not-clean\n+\t (ewoc-collect git-status (lambda (info &optional state)\n+\t\t\t\t    (setq state (git-fileinfo->state info))\n+\t\t\t\t    (or (eq state 'modified)\n+\t\t\t\t\t(eq state 'added)\n+\t\t\t\t\t(eq state 'deleted)\n+\t\t\t\t\t(eq state 'unmerged))))))\n+    (if not-clean\n+\t(error \"Error: Can't pull while in unclean state (commit all first).\"))\n+    (unless git-status (error \"Not in git-status buffer.\"))\n+    ;; FIXME: could collect some status data for display\n+    (when (git-call-process-display-error \"pull\" remote)\n+      (message \"Pulled from remote: %s\" remote))))\n+\n (defun git-help ()\n   \"Display help for Git mode.\"\n   (interactive)\n-- \n1.7.4.1\n"},{"id":"165846","messageId":"bff33bffb02487b123d280a0f3fe9ac0cdd9cda6.1302815124.git.jari.aalto@cante.net","threadId":"26829","inReplyTo":"ae4f9adf62502f58a870a322cd30a62e23aba747.1301852577.git.jari.aalto@cante.net","subject":"[PATCH v4] contrib/emacs/git.el: Add user functions for push, pull, fetch","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2011-04-14T21:07:13Z","receivedAt":"2011-04-14T21:07:13Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n contrib/emacs/git.el |  110 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 109 insertions(+), 1 deletions(-)\n\n  [v2]\n  ** This fixes the pull message. The only change is last line:\n  ** (message \"Pulled from remote: %s\" remote)))\n\n  [v3] Fixes commented by <julliard@winehq.org>\n  ** Extra C-a keymap binding removed\n  ** Check success status before displaying message\n  ** no need to refresh the status files on push or fetch\n\n  [v4]\n  ** Parse remotes from .git/config and offer them as completions (push/pull)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 65c95d9..97d2484 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1,6 +1,7 @@\n ;;; git.el --- A user interface for git\n \n ;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Alexandre Julliard <julliard@winehq.org>\n+;; Copyright (C) 2010 Jari Aalto <jari.aalto@cante.net>\n \n ;; Version: 1.0\n \n@@ -33,11 +34,14 @@\n ;;\n ;; To start: `M-x git-status'\n ;;\n+;; RUDIMENTARY\n+;; - fetch/pull. Be sure to start gpg-agent, ssh-agent prior emacs\n+;;   to access ssh Git remotes.\n+;;\n ;; TODO\n ;;  - diff against other branch\n ;;  - renaming files from the status buffer\n ;;  - creating tags\n-;;  - fetch/pull\n ;;  - revlist browser\n ;;  - git-show-branch browser\n ;;\n@@ -384,6 +388,25 @@ the process output as a string, or nil if the git command failed.\"\n   (git-get-string-sha1\n    (git-call-process-string \"rev-parse\" rev)))\n \n+(defun git-root ()\n+  \"Return root of git directory. Start from current dir way up.\"\n+  (let* ((dir (file-name-as-directory default-directory))\n+\t (try (format \"%s%s\" dir \".git\")))\n+    (while (and dir\n+\t\t(not (file-directory-p try)))\n+      (if (string-match \"^\\\\(.*/\\\\).+$\" dir)\n+\t  (setq dir (match-string 1 dir)\n+\t\ttry (format \"%s%s\" dir \".git\"))\n+\t(setq dir nil\n+\t      try nil)))\n+    try))\n+\n+(defsubst git-config-file ()\n+  \"Return 'config' file location.\"\n+  (let ((dir (git-root)))\n+    (if dir\n+\t(format \"%s/config\" dir))))\n+\n (defun git-config (key)\n   \"Retrieve the value associated to KEY in the git repository config file.\"\n   (let ((str (git-call-process-string \"config\" key)))\n@@ -1527,6 +1550,7 @@ amended version of it.\"\n \n (unless git-status-mode-map\n   (let ((map (make-keymap))\n+        (remote-map (make-sparse-keymap))\n         (commit-map (make-sparse-keymap))\n         (diff-map (make-sparse-keymap))\n         (toggle-map (make-sparse-keymap)))\n@@ -1554,6 +1578,7 @@ amended version of it.\"\n     (define-key map \"P\"   'git-prev-unmerged-file)\n     (define-key map \"q\"   'git-status-quit)\n     (define-key map \"r\"   'git-remove-file)\n+    (define-key map \"R\"   remote-map)\n     (define-key map \"t\"    toggle-map)\n     (define-key map \"T\"   'git-toggle-all-marks)\n     (define-key map \"u\"   'git-unmark-file)\n@@ -1562,6 +1587,11 @@ amended version of it.\"\n     (define-key map \"x\"   'git-remove-handled)\n     (define-key map \"\\C-?\" 'git-unmark-file-up)\n     (define-key map \"\\M-\\C-?\" 'git-unmark-all)\n+    ; remotes\n+    (define-key remote-map \"R\" 'git-pull)  ; retrieve \"RR\"\n+    (define-key remote-map \"r\" 'git-pull)  ; retrieve \"Rr\" (synonym)\n+    (define-key remote-map \"p\" 'git-push)\n+    (define-key remote-map \"f\" 'git-fetch)\n     ; the commit submap\n     (define-key commit-map \"\\C-a\" 'git-amend-commit)\n     (define-key commit-map \"\\C-b\" 'git-branch)\n@@ -1614,6 +1644,10 @@ amended version of it.\"\n       [\"Interactive Diff File\" git-diff-file-idiff t]\n       [\"Log\" git-log-file t]\n       \"--------\"\n+      [\"Push\" git-push t]\n+      [\"Pull\" git-pull t]\n+      [\"Fetch\" git-fetch t]\n+      \"--------\"\n       [\"Mark\" git-mark-file t]\n       [\"Mark All\" git-mark-all t]\n       [\"Unmark\" git-unmark-file t]\n@@ -1696,6 +1730,80 @@ Meant to be used in `after-save-hook'.\"\n             (git-call-process nil \"add\" \"--refresh\" \"--\" filename)\n             (git-update-status-files (list filename))))))))\n \n+(defun git-remote-parse ()\n+  \"Parse remotes from current point forward. Return list.\"\n+  (let (list)\n+    ;; [remote \"origin\"]\n+    (while (re-search-forward \"^\\\\[remote[[:space:]]+\\\"\\\\([^\\\"]+\\\\)\" nil t)\n+      (push (match-string-no-properties 1) list))\n+    list))\n+\n+(defun git-remote-list ()\n+  \"Return list of remotes from Git configuration.\"\n+  (with-temp-buffer\n+    (insert-file-contents-literally (git-config-file))\n+    (goto-char (point-min))\n+    (git-remote-parse)))\n+\n+(defun git-ask-remote (prompt)\n+  \"Read remote with PROMPT.\"\n+  (let ((list (git-remote-list))\n+\t(default \"origin\")\n+\tret)\n+    (unless (member default list)\n+      (setq default (car list)))\n+    (setq ret\n+\t  (completing-read prompt\n+\t\t\t   list\n+\t\t\t   (not 'predicate)\n+\t\t\t   'require-match\n+\t\t\t   (not 'default)\n+\t\t\t   (not 'history)\n+\t\t\t   default))\n+    (if (string-match \"^[ \\t\\r\\n]*$\" ret)\n+\t(setq ret default))\n+    ret))\n+\n+(defun git-push (&optional remote)\n+  \"Pull to REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Push to remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could collect some status data for display\n+  (when (git-call-process-display-error \"push\" remote)\n+    (message \"Pushed to remote: %s\" remote)))\n+\n+(defun git-fetch (&optional remote)\n+  \"Fetch from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Fetch from remote: \"))\n+\t     \"origin\")))\n+  ;; FIXME: could collect some status data for display\n+  (when (git-call-process-display-error \"fetch\" remote)\n+    (message \"Fetched from remote: %s\" remote)))\n+\n+(defun git-pull (&optional remote)\n+  \"Pull from REMOTE. Use \\\\[current-prefix-arg] to interactively set REMOTE.\"\n+  (interactive\n+   (list (or (and current-prefix-arg\n+\t\t  (git-ask-remote \"Pull from remote: \"))\n+\t     \"origin\")))\n+  (let ((not-clean\n+\t (ewoc-collect git-status (lambda (info &optional state)\n+\t\t\t\t    (setq state (git-fileinfo->state info))\n+\t\t\t\t    (or (memq state '(added\n+\t\t\t\t\t\t      deleted\n+\t\t\t\t\t\t      modified\n+\t\t\t\t\t\t      unmerged)))))))\n+    (if not-clean\n+\t(error \"Error: Can't pull while in unclean state (commit all first).\"))\n+    (unless git-status (error \"Not in git-status buffer.\"))\n+    ;; FIXME: could collect some status data for display\n+    (when (git-call-process-display-error \"pull\" remote)\n+      (message \"Pulled from remote: %s\" remote))))\n+\n (defun git-help ()\n   \"Display help for Git mode.\"\n   (interactive)\n-- \n1.7.4.1\n"}]}