Use Git cherry-pick also for 'a' and Git revert for 'v'.

* magit.el (magit-cherry-pick-commit): Removed, replaced with
magit-apply-item.
(magit-revert-commit): Likewise.
(magit-apply-commit): Use git cherry pick and optionally do everything
magit-cherry-pick-commit and magit-revert-commit could do.
This commit is contained in:
Marius Vollmer 2009-02-15 23:49:01 +02:00
parent 1e3f94437e
commit bded317bc8

View file

@ -2055,7 +2055,7 @@ in log buffer."
(commit (car first-unused))) (commit (car first-unused)))
(cond ((not first-unused) (cond ((not first-unused)
(magit-rewrite-stop t)) (magit-rewrite-stop t))
((magit-cherry-pick-commit commit (not first-p)) ((magit-apply-commit commit t (not first-p))
(magit-rewrite-set-commit-property commit 'used t) (magit-rewrite-set-commit-property commit 'used t)
(magit-rewrite-finish-step nil)))))) (magit-rewrite-finish-step nil))))))
@ -2396,26 +2396,27 @@ Prefix arg means justify as well."
(or commit (or commit
(error "No commit at point."))))) (error "No commit at point.")))))
(defun magit-apply-commit (commit) (defun magit-apply-commit (commit &optional docommit noerase revert)
(let ((parent (magit-choose-parent commit "apply"))) (let* ((parent-id (magit-choose-parent-id commit "cherry-pick"))
(magit-log-edit-append (success (magit-run* `(,magit-git-executable
(magit-format-commit commit "%s%n%n%b")) ,@magit-git-standard-options
(magit-log-edit-set-field ,(if revert "revert" "cherry-pick")
'author ,@(if parent-id
(magit-format-commit commit "%an <%ae>, %ai")) (list "-m" (number-to-string parent-id)))
(magit-run-shell "%s diff %s %s | %s apply -" ,@(if (not docommit) (list "--no-commit"))
magit-git-executable parent commit ,commit)
magit-git-executable))) nil noerase)))
(when (or (not docommit) success)
(defun magit-cherry-pick-commit (commit &optional noerase) (cond (revert
(let ((parent-id (magit-choose-parent-id commit "cherry-pick"))) (magit-log-edit-append
(magit-run* `(,magit-git-executable (magit-format-commit commit "Reverting \"%s\"")))
,@magit-git-standard-options (t
"cherry-pick" (magit-log-edit-append
,@(if parent-id (magit-format-commit commit "%s%n%n%b"))
(list "-m" (number-to-string parent-id))) (magit-log-edit-set-field
,commit) 'author
nil noerase))) (magit-format-commit commit "%an <%ae>, %ai")))))
success))
(defun magit-apply-item () (defun magit-apply-item ()
(interactive) (interactive)
@ -2440,29 +2441,21 @@ Prefix arg means justify as well."
(interactive) (interactive)
(magit-section-action (item info "cherry-pick") (magit-section-action (item info "cherry-pick")
((pending commit) ((pending commit)
(magit-cherry-pick-commit info) (magit-apply-commit info t)
(magit-rewrite-set-commit-property info 'used t)) (magit-rewrite-set-commit-property info 'used t))
((commit) ((commit)
(magit-cherry-pick-commit info)) (magit-apply-commit info t))
((stash) ((stash)
(magit-run-git "stash" "pop" info)))) (magit-run-git "stash" "pop" info))))
(defun magit-revert-commit (commit)
(let ((parent (magit-choose-parent commit "revert")))
(magit-log-edit-append
(magit-format-commit commit "Reverting \"%s\""))
(magit-run-shell "%s diff %s %s | %s apply --reverse -"
magit-git-executable parent commit
magit-git-executable)))
(defun magit-revert-item () (defun magit-revert-item ()
(interactive) (interactive)
(magit-section-action (item info "revert") (magit-section-action (item info "revert")
((pending commit) ((pending commit)
(magit-revert-commit info) (magit-apply-commit info nil nil t)
(magit-rewrite-set-commit-property info 'used nil)) (magit-rewrite-set-commit-property info 'used nil))
((commit) ((commit)
(magit-revert-commit info)) (magit-apply-commit info nil nil t))
((hunk) ((hunk)
(magit-apply-hunk-item-reverse item)) (magit-apply-hunk-item-reverse item))
((diff) ((diff)