TortoiseGit Interface for EMACS

I’ve been releasing stuff to Github these days, basecamp2text, drupal-irssi, simple-volume-osd, etc. So I’ve been using TortoiseGit as a GUI to make git a little easier to swallow.

On the SVN side of things I’ve been using a library I found over on the EmacsWIKI to interface SVN and emacs. Since I’m using Git so much these days I thought I’d adapt that library to work with TortioseGit.

Right now it only supports log, diff, blame, commit, revert and help. It’s been working great for my uses so far.


(defun tortoise-git-command (command filename)
  (start-process "tortoise-git" "foo"
   "c:/Progra~1/TortoiseGit/bin/TortoiseProc" (concat "/command:" command) 
     (concat "/path:" (replace-regexp-in-string "Program Files" 
           (regexp-quote "Progra~1") (expand-file-name filename))

(defun tortoise-git-log ()
  (tortoise-git-log-select (buffer-file-name)))

(defun tortoise-git-log-select (filename &optional wildcards)
  (interactive (find-file-read-args "Find file: " t))
  (tortoise-git-command "log" filename))

(defun tortoise-git-diff ()
  (tortoise-git-command "diff" (buffer-file-name)))

(defun tortoise-git-blame ()
 (tortoise-git-command "blame" (buffer-file-name)))

(defun tortoise-git-commit () 
  (tortoise-git-command "commit" (buffer-file-name)))

(defun tortoise-git-commit-select (filename &optional wildcards)
(interactive (find-file-read-args "Find file: " t))
  (tortoise-git-command "commit" (buffer-file-name)))

(defun tortoise-git-revert ()
  (tortoise-git-revert-select (buffer-file-name)))

(defun tortoise-git-revert-select (filename &optional wildcards)
  (interactive (find-file-read-args "Find file: " t))
  (tortoise-git-command "revert" filename))

(defun tortoise-git-help ()
 (start-process-shell-command "tortoise-git" nil
  (concat "/cygdrive/c/Progra~1/TortoiseGit/bin/TortoiseProc /command:help")))

; add key bind
(global-set-key "\C-xgl" & 'tortoise-git-log)
(global-set-key "\C-xgL" & 'tortoise-git-log-select)
(global-set-key "\C-xg=" & 'tortoise-git-diff)
(global-set-key "\C-xgb" & 'tortoise-git-blame)
(global-set-key "\C-xgc" & 'tortoise-git-commit)
(global-set-key "\C-xgC" & 'tortoise-git-commit-select)
(global-set-key "\C-xgs" & 'tortoise-git-repostatus)
(global-set-key "\C-xgS" & 'tortoise-git-repostatus-select)
(global-set-key "\C-xgr" & 'tortoise-git-revert)
(global-set-key "\C-xgR" & 'tortoise-git-revert-select)
(global-set-key "\C-xgh" & 'tortoise-git-help)

(provide & 'tortoise-git)

Watch the github repository for more features in the future: