("D" . stgit-delete)
([(control ?/)] . stgit-undo)
("\C-_" . stgit-undo)
- ("q" . stgit-quit))))
+ ("B" . stgit-branch)
+ ("q" . stgit-quit))))
(defun stgit-mode ()
"Major mode for interacting with StGit.
(stgit-run "repair"))
(stgit-reload))
+(defun stgit-available-branches ()
+ "Returns a list of the available stg branches"
+ (let ((output (with-output-to-string
+ (stgit-run "branch" "--list")))
+ (start 0)
+ result)
+ (while (string-match "^>?\\s-+s\\s-+\\(\\S-+\\)" output start)
+ (setq result (cons (match-string 1 output) result))
+ (setq start (match-end 0)))
+ result))
+
+(defun stgit-branch (branch)
+ "Switch to branch BRANCH."
+ (interactive (list (completing-read "Switch to branch: "
+ (stgit-available-branches))))
+ (stgit-capture-output nil (stgit-run "branch" "--" branch))
+ (stgit-reload))
+
(defun stgit-commit (count)
"Run stg commit on COUNT commits.
Interactively, the prefix argument is used as COUNT."