aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Wiberg <kha@treskal.com>2010-01-22 14:57:06 +0100
committerKarl Wiberg <kha@treskal.com>2010-01-22 14:58:08 +0100
commit2b03ee282071042cb251b5004eda2e8bc8ee20f9 (patch)
tree33d273231110858b06b1ce28a86c545a1fbd590d
parentddfdced94e9921382e8b2e90cb17df4bdb2273dc (diff)
parentd47ee133cccaf4c3a188dd3601c2a68747a9231d (diff)
downloadstgit-2b03ee282071042cb251b5004eda2e8bc8ee20f9.tar.gz
Merge gustav/proposed
stgit.el: Make "G" work before/after the tree stgit.el: Repair how patches with empty descriptions are shown
-rw-r--r--contrib/stgit.el60
1 files changed, 44 insertions, 16 deletions
diff --git a/contrib/stgit.el b/contrib/stgit.el
index 3ebeb72..f617e6d 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -291,8 +291,10 @@ A newline is appended."
?e (if (stgit-patch->empty patch) "(empty) " "")
?d (propertize (or (stgit-patch->desc patch) "")
'face 'stgit-description-face)
- ?D (propertize (or (stgit-patch->desc patch)
- (stgit-patch-display-name patch))
+ ?D (propertize (let ((desc (stgit-patch->desc patch)))
+ (if (zerop (length desc))
+ (stgit-patch-display-name patch)
+ desc))
'face face)))
(text (format-spec fmt spec)))
@@ -1617,23 +1619,32 @@ tree, or a single change in either."
(stgit-reload)))
+(defun stgit-push-or-pop-patches (do-push npatches)
+ "Push (if DO-PUSH is not nil) or pop (if DO-PUSH is nil)
+NPATCHES patches, or all patches if NPATCHES is t."
+ (stgit-assert-mode)
+ (stgit-capture-output nil
+ (apply 'stgit-run
+ (if do-push "push" "pop")
+ (if (eq npatches t)
+ '("--all")
+ (list "-n" npatches))))
+ (stgit-reload)
+ (stgit-refresh-git-status))
+
(defun stgit-push-next (npatches)
"Push the first unapplied patch.
With numeric prefix argument, push that many patches."
(interactive "p")
- (stgit-assert-mode)
- (stgit-capture-output nil (stgit-run "push" "-n" npatches))
- (stgit-reload)
- (stgit-refresh-git-status))
+ (stgit-push-or-pop-patches t npatches))
(defun stgit-pop-next (npatches)
"Pop the topmost applied patch.
-With numeric prefix argument, pop that many patches."
+With numeric prefix argument, pop that many patches.
+
+If NPATCHES is t, pop all patches."
(interactive "p")
- (stgit-assert-mode)
- (stgit-capture-output nil (stgit-run "pop" "-n" npatches))
- (stgit-reload)
- (stgit-refresh-git-status))
+ (stgit-push-or-pop-patches nil npatches))
(defun stgit-applied-patches (&optional only-patches)
"Return a list of the applied patches.
@@ -1668,16 +1679,33 @@ If ONLY-PATCHES is not nil, exclude index and work tree."
(stgit-sort-patches (if unapplied unapplied patchsyms)))))
(stgit-reload))
+(defun stgit-goto-target ()
+ "Return the goto target a point; either a patchsym, :top,
+or :bottom."
+ (let ((patchsym (stgit-patch-name-at-point)))
+ (cond ((memq patchsym '(:work :index)) nil)
+ (patchsym)
+ ((not (next-single-property-change (point) 'patch-data))
+ :top)
+ ((not (previous-single-property-change (point) 'patch-data))
+ :bottom))))
+
(defun stgit-goto ()
"Go to the patch on the current line.
-Pops or pushes patches to make this patch topmost."
+Push or pop patches to make this patch topmost. Push or pop all
+patches if used on a line after or before all patches."
(interactive)
(stgit-assert-mode)
- (let ((patchsym (stgit-patch-name-at-point t)))
- (stgit-capture-output nil
- (stgit-run "goto" patchsym))
- (stgit-reload)))
+ (let ((patchsym (stgit-goto-target)))
+ (unless patchsym
+ (error "No patch to go to on this line"))
+ (case patchsym
+ (:top (stgit-push-or-pop-patches t t))
+ (:bottom (stgit-push-or-pop-patches nil t))
+ (t (stgit-capture-output nil
+ (stgit-run "goto" patchsym))
+ (stgit-reload)))))
(defun stgit-id (patchsym)
"Return the git commit id for PATCHSYM.