From: Fabian Ezequiel Gallina <galli.87@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: git push/pull
Date: Wed, 9 Dec 2009 14:19:36 -0300 [thread overview]
Message-ID: <9de1a5ef0912090919w33c9e55dob9d29c04d85ab407@mail.gmail.com> (raw)
In-Reply-To: <jwvein6gk0k.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
2009/12/8 Stefan Monnier <monnier@iro.umontreal.ca>:
>> Stefan, two diffs are attached in this reply.
>
> Thanks. See comments below.
>
Hi Stefan, thanks for your feedback.
Attached is the diff with the corrections you proposed. I also removed
the hacky call to `message' in favor of the standard vc behavior to
display command status only on errors.
Regards,
--
Fabián E. Gallina
http://www.from-the-cloud.com
[-- Attachment #2: vc.el.diff --]
[-- Type: text/plain, Size: 830 bytes --]
diff --git a/lisp/vc.el b/lisp/vc.el
index 9a71286..c940d1d 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -1188,6 +1188,22 @@ merge in the changes into your working copy."
(declare-function vc-dir-move-to-goal-column "vc-dir" ())
;;;###autoload
+(defun vc-pull ()
+ "Merges changes between branches."
+ (interactive)
+ (vc-ensure-vc-buffer)
+ (let ((backend (vc-backend buffer-file-name)))
+ (vc-call-backend backend 'pull)))
+
+;;;###autoload
+(defun vc-push ()
+ "Pushes commits to some branch."
+ (interactive)
+ (vc-ensure-vc-buffer)
+ (let ((backend (vc-backend buffer-file-name)))
+ (vc-call-backend backend 'push)))
+
+;;;###autoload
(defun vc-register (&optional set-revision vc-fileset comment)
"Register into a version control system.
If VC-FILESET is given, register the files in that fileset.
[-- Attachment #3: vc-git.el.diff --]
[-- Type: text/plain, Size: 2496 bytes --]
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 69e8614..6f60cb2 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -490,6 +490,51 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
;;; STATE-CHANGING FUNCTIONS
+(defun vc-git--do-push-pull (operation)
+ "Calls the command git OPERATION. OPERATION could be 'push or 'pull."
+ (let* ((default-refspec (vc-git-working-revision buffer-file-name))
+ (available-repos
+ (let ((table (list ".")))
+ (with-temp-buffer
+ (vc-git-command t nil nil "for-each-ref" "--format=%(refname)")
+ (goto-char (point-min))
+ (while (re-search-forward "^refs/remotes/\\(.*\\)/.*$" nil t)
+ (push (match-string 1) table)))
+ table))
+ (default-repo (nth 0 available-repos))
+ (current-repo
+ (completing-read (format "Repository (default %s): " default-repo)
+ available-repos nil 'confirm nil nil default-repo))
+ (available-refspecs
+ (let ((table (list "HEAD"))
+ (ref-regexp))
+ (with-temp-buffer
+ (vc-git-command t nil nil "for-each-ref" "--format=%(refname)")
+ (setq ref-regexp
+ (format (if (and (not (equal "." current-repo))
+ (equal vc-git-push-pull-perform 'pull))
+ "^refs/\\(remotes/%s\\|tags\\)/\\([^\n]+\\).*$"
+ "^refs/\\(remotes\\|heads\\|tags\\)/\\(%s/[^\n]+\\|[^\n]+\\).*$")
+ (regexp-quote current-repo)))
+ (goto-char (point-min))
+ (while (re-search-forward ref-regexp nil t)
+ (push (match-string 2) table)))
+ table))
+ (current-refspec
+ (completing-read (format "Branch (default %s): " default-refspec)
+ available-refspecs nil 'confirm nil nil
+ default-refspec))
+ (command (prin1-to-string operation)))
+ (vc-git-command nil 0 nil command current-repo current-refspec)))
+
+(defun vc-git-push ()
+ "Update remote refs along with associated objects."
+ (vc-git--do-push-pull 'push))
+
+(defun vc-git-pull ()
+ "Fetch from and merge with another repository or a local branch."
+ (vc-git--do-push-pull 'pull))
+
(defun vc-git-create-repo ()
"Create a new Git repository."
(vc-git-command nil 0 nil "init"))
prev parent reply other threads:[~2009-12-09 17:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-05 8:09 git push/pull [was: support for bzr shelve/unshelve in vc-dir] Fabian Ezequiel Gallina
2009-12-05 9:07 ` Andreas Schwab
2009-12-05 16:15 ` git push/pull Stefan Monnier
2009-12-06 3:12 ` Fabian Ezequiel Gallina
2009-12-06 19:21 ` Fabian Ezequiel Gallina
2009-12-06 20:33 ` Andreas Schwab
2009-12-06 21:13 ` Fabian Ezequiel Gallina
2009-12-06 22:45 ` Andreas Schwab
2009-12-08 4:50 ` Stefan Monnier
2009-12-09 17:19 ` Fabian Ezequiel Gallina [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9de1a5ef0912090919w33c9e55dob9d29c04d85ab407@mail.gmail.com \
--to=galli.87@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.