aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Hållberg <gustav@gmail.com>2012-04-06 21:32:20 +0200
committerGustav Hållberg <gustav@gmail.com>2012-04-07 21:50:41 +0200
commit2147794afc289c7176c8f83be371a8d56a84104e (patch)
tree8365c75d0417ea90cb3d0463d7c6dd7285029aba
parent2c1769c44894906450a3c0724931ef25bab16eb9 (diff)
downloadstgit-2147794afc289c7176c8f83be371a8d56a84104e.tar.gz
stgit.el: Show human-friendly message when pressing =
Signed-off-by: Gustav Hållberg <gustav@gmail.com>
-rw-r--r--contrib/stgit.el103
1 files changed, 54 insertions, 49 deletions
diff --git a/contrib/stgit.el b/contrib/stgit.el
index 56cb26f..6d56f0c 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -2142,55 +2142,60 @@ If PATCHSYM is a keyword, returns PATCHSYM unmodified."
UNMERGED-STAGE is the argument to `git-diff' that that selects
which stage to diff against in the case of unmerged files."
- (let ((space-arg (stgit-whitespace-diff-arg ignore-whitespace))
- (patch-name (stgit-patch-name-at-point t)))
- (stgit-capture-output "*StGit patch*"
- (case (get-text-property (point) 'entry-type)
- ('file
- (let* ((patched-file (stgit-patched-file-at-point))
- (patch-id (let ((id (stgit-id patch-name)))
- (if (and (eq id :index)
- (eq (stgit-file->status patched-file)
- 'unmerged))
- :work
- id)))
- (args (append (and space-arg (list space-arg))
- (and (stgit-file->cr-from patched-file)
- (list (stgit-find-copies-harder-diff-arg)))
- (cond ((eq patch-id :index)
- '("--cached"))
- ((eq patch-id :work)
- (list unmerged-stage))
- (t
- (list (concat patch-id "^") patch-id)))
- (and (eq (stgit-file->status patched-file) 'copy)
- '("--diff-filter=C"))
- '("--")
- (if (stgit-file->copy-or-rename patched-file)
- (list (stgit-file->cr-from patched-file)
- (stgit-file->cr-to patched-file))
- (list (stgit-file->file patched-file))))))
- (apply 'stgit-run-git "diff" args)))
- ('patch
- (let* ((patch-id (stgit-id patch-name)))
- (if (or (eq patch-id :index) (eq patch-id :work))
- (apply 'stgit-run-git "diff"
- (stgit-find-copies-harder-diff-arg)
- (append (and space-arg (list space-arg))
- (if (eq patch-id :index)
- '("--cached")
- (list unmerged-stage))))
- (let ((args (append '("show" "-O" "--patch-with-stat")
- `("-O" ,(stgit-find-copies-harder-diff-arg))
- (and space-arg (list "-O" space-arg))
- '("--")
- (list (stgit-patch-name-at-point)))))
- (apply 'stgit-run args)))))
- (t
- (error "No patch or file at point")))
- (with-current-buffer standard-output
- (goto-char (point-min))
- (diff-mode)))))
+ (let* ((space-arg (stgit-whitespace-diff-arg ignore-whitespace))
+ (patch-name (stgit-patch-name-at-point t))
+ (entry-type (get-text-property (point) 'entry-type))
+ (diff-desc (case entry-type
+ ('file "diff")
+ ('patch "patch")
+ (t (error "No patch or file at point")))))
+ (stgit-show-task-message (concat "Showing " diff-desc)
+ (stgit-capture-output (concat "*StGit " diff-desc "*")
+ (case entry-type
+ ('file
+ (let* ((patched-file (stgit-patched-file-at-point))
+ (patch-id (let ((id (stgit-id patch-name)))
+ (if (and (eq id :index)
+ (eq (stgit-file->status patched-file)
+ 'unmerged))
+ :work
+ id)))
+ (args (append (and space-arg (list space-arg))
+ (and (stgit-file->cr-from patched-file)
+ (list (stgit-find-copies-harder-diff-arg)))
+ (cond ((eq patch-id :index)
+ '("--cached"))
+ ((eq patch-id :work)
+ (list unmerged-stage))
+ (t
+ (list (concat patch-id "^") patch-id)))
+ (and (eq (stgit-file->status patched-file)
+ 'copy)
+ '("--diff-filter=C"))
+ '("--")
+ (if (stgit-file->copy-or-rename patched-file)
+ (list (stgit-file->cr-from patched-file)
+ (stgit-file->cr-to patched-file))
+ (list (stgit-file->file patched-file))))))
+ (apply 'stgit-run-git "diff" args)))
+ ('patch
+ (let* ((patch-id (stgit-id patch-name)))
+ (if (or (eq patch-id :index) (eq patch-id :work))
+ (apply 'stgit-run-git "diff"
+ (stgit-find-copies-harder-diff-arg)
+ (append (and space-arg (list space-arg))
+ (if (eq patch-id :index)
+ '("--cached")
+ (list unmerged-stage))))
+ (let ((args (append '("show" "-O" "--patch-with-stat")
+ `("-O" ,(stgit-find-copies-harder-diff-arg))
+ (and space-arg (list "-O" space-arg))
+ '("--")
+ (list (stgit-patch-name-at-point)))))
+ (apply 'stgit-run args))))))
+ (with-current-buffer standard-output
+ (goto-char (point-min))
+ (diff-mode))))))
(defmacro stgit-define-diff (name diff-arg &optional unmerged-action)
`(defun ,name (&optional ignore-whitespace)