stgit.el: Refresh from work tree when index is empty
authorGustav Hållberg <gustav@virtutech.com>
Thu, 30 Jul 2009 22:57:57 +0000 (00:57 +0200)
committerGustav Hållberg <gustav@virtutech.com>
Thu, 6 Aug 2009 20:49:07 +0000 (22:49 +0200)
Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
contrib/stgit.el

index 9ee353c..c624ecc 100644 (file)
@@ -1190,6 +1190,8 @@ With prefix argument, run it with the --hard flag."
 
 (defun stgit-refresh (&optional arg)
   "Run stg refresh.
+If the index contains any changes, only refresh from index.
+
 With prefix argument, refresh the marked patch or the patch under point."
   (interactive "P")
   (let ((patchargs (if arg
@@ -1201,6 +1203,8 @@ With prefix argument, refresh the marked patch or the patch under point."
                                (t
                                 (cons "-p" patches))))
                      nil)))
+    (unless (stgit-index-empty-p)
+      (setq patchargs (cons "--index" patchargs)))
     (stgit-capture-output nil
       (apply 'stgit-run "refresh" patchargs))
     (stgit-refresh-git-status))