--- contrib/emacs/git.el | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index a8bf0ef..16d9771 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1138,6 +1138,43 @@ Return the list of files that haven't been handled." (when (eq (window-buffer) (current-buffer)) (shrink-window-if-larger-than-buffer))) +(defun git-list-branches (&optional all) + "Return an alist of available branches +if all is non-nil, return all branch, otherwise only local one +cdr of assoc is non-nil for the current branch +nil otherwise" + (let ((branches ())) + (with-temp-buffer + (if all + (git-run-command-buffer (current-buffer) "branch" "-a") + (git-run-command-buffer (current-buffer) "branch")) + (goto-char (point-min)) + (while (re-search-forward "^\\([ *]\\) \\([^\n]*\\)$" () t) + (push (cons (match-string 2) + (string= (match-string 1) "*")) + branches))) + (nreverse branches))) + +(defun git-list-tags () + "Return an list of available tags" + (let ((tags ())) + (with-temp-buffer + (git-run-command-buffer (current-buffer) "tag") + (goto-char (point-min)) + (while (re-search-forward "^\\([^\n]+\\)$" () t) + (push (match-string 1) + tags))) + (nreverse tags))) + +(defun git-read-commitish (prompt &optional default) + "ask user, with commpletion for a commit, branch, tag or any commitish" + (completing-read prompt (list* "HEAD" + "ORIG_HEAD" + "FETCH_HEAD" + (append (git-list-branches t) + (git-list-tags))) + () () () () default)) + (defun git-diff-file () "Diff the marked file(s) against HEAD." (interactive) -- 1.5.4.1.123.gcb68-dirty - 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