]> git.eshelyaron.com Git - emacs.git/commitdiff
(vc-git--run-command-string): Accept a nil FILE argument.
authorDan Nicolaescu <dann@ics.uci.edu>
Thu, 23 Jul 2009 06:42:50 +0000 (06:42 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Thu, 23 Jul 2009 06:42:50 +0000 (06:42 +0000)
(vc-git-stash-list): New function.
(vc-git-dir-extra-headers): Use it.

lisp/ChangeLog
lisp/vc-git.el

index accbe7d1eb9336020781addc4bf9085cd1bfc3c1..d76566b7ec45920f49b5200458017d6032f741a3 100644 (file)
@@ -8,6 +8,9 @@
        (vc-git-checkin): Use it.
        (vc-git-toggle-signoff): New function.
        (vc-git-extra-menu-map): Bind it to menu.
+       (vc-git--run-command-string): Accept a nil FILE argument.
+       (vc-git-stash-list): New function.
+       (vc-git-dir-extra-headers): Use it.
 
 2009-07-23  Glenn Morris  <rgm@gnu.org>
 
index d8e9603cb4eb9032b8792c4e9c91f134e1fe25cb..36bc653a451e69e83f582b1250cc5985a0c8afd6 100644 (file)
@@ -400,13 +400,21 @@ If nil, use the value of `vc-diff-switches'.  If t, use no switches."
 (defun vc-git-dir-extra-headers (dir)
   (let ((str (with-output-to-string
                (with-current-buffer standard-output
-                 (vc-git--out-ok "symbolic-ref" "HEAD")))))
+                 (vc-git--out-ok "symbolic-ref" "HEAD"))))
+       (stash (vc-git-stash-list)))
+    ;; FIXME: maybe use a different face when nothing is stashed.
+    (when (string= stash "") (setq stash "Nothing stashed"))
     (concat
      (propertize "Branch     : " 'face 'font-lock-type-face)
      (propertize 
       (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
          (match-string 2 str)
        "not (detached HEAD)")
+       'face 'font-lock-variable-name-face)
+     "\n"
+     (propertize "Stash      : " 'face 'font-lock-type-face)
+     (propertize
+      stash
        'face 'font-lock-variable-name-face))))
 
 ;;; STATE-CHANGING FUNCTIONS
@@ -708,6 +716,13 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
          (compilation-start command 'grep-mode))
        (if (eq next-error-last-buffer (current-buffer))
            (setq default-directory dir))))))
+
+(defun vc-git-stash-list ()
+  (replace-regexp-in-string
+   "\n" "\n             "
+   (replace-regexp-in-string
+    "^stash@" "" (vc-git--run-command-string nil "stash" "list"))))
+
 \f
 ;;; Internal commands
 
@@ -733,13 +748,16 @@ The difference to vc-do-command is that this function always invokes `git'."
   (zerop (apply 'vc-git--call '(t nil) command args)))
 
 (defun vc-git--run-command-string (file &rest args)
-  "Run a git command on FILE and return its output as string."
+  "Run a git command on FILE and return its output as string.
+FILE can be nil."
   (let* ((ok t)
          (str (with-output-to-string
                 (with-current-buffer standard-output
                   (unless (apply 'vc-git--out-ok
-                                 (append args (list (file-relative-name
-                                                     file))))
+                                (if file
+                                    (append args (list (file-relative-name
+                                                        file)))
+                                  args))
                     (setq ok nil))))))
     (and ok str)))