Make rebasing work again, and improve it a bit.

* magit.el (magit-rebase-info): Also look for .git/rebase-apply.
(magit-log-edit): Don't commit in the middle of a rebase, offer to
continue it instead.
(magit-add-log): Likewise.
This commit is contained in:
Marius Vollmer 2009-03-22 00:55:19 +02:00
parent 417dd46093
commit 27389b9e5e

View file

@ -1957,7 +1957,12 @@ in log buffer."
;;; Rebasing
(defun magit-rebase-info ()
(cond ((file-exists-p ".dotest")
(cond ((file-exists-p ".git/rebase-apply")
(list (magit-name-rev
(car (magit-file-lines ".git/rebase-apply/onto")))
(car (magit-file-lines ".git/rebase-apply/next"))
(car (magit-file-lines ".git/rebase-apply/last"))))
((file-exists-p ".dotest")
(list (magit-name-rev (car (magit-file-lines ".dotest/onto")))
(car (magit-file-lines ".dotest/next"))
(car (magit-file-lines ".dotest/last"))))
@ -2362,6 +2367,10 @@ Prefix arg means justify as well."
(defun magit-log-edit ()
(interactive)
(cond ((magit-rebase-info)
(if (y-or-n-p "Rebase in progress. Continue it? ")
(magit-run-git "rebase" "--continue")))
(t
(magit-log-edit-set-field 'tag nil)
(when (and magit-commit-all-when-nothing-staged
(not (magit-anything-staged-p)))
@ -2373,12 +2382,17 @@ Prefix arg means justify as well."
(magit-log-edit-set-field
'commit-all
(if (or (eq magit-commit-all-when-nothing-staged t)
(y-or-n-p "Nothing staged. Commit all unstaged changes? "))
(y-or-n-p
"Nothing staged. Commit all unstaged changes? "))
"yes" "no")))))
(magit-pop-to-log-edit "commit"))
(magit-pop-to-log-edit "commit"))))
(defun magit-add-log ()
(interactive)
(cond ((magit-rebase-info)
(if (y-or-n-p "Rebase in progress. Continue it? ")
(magit-run-git "rebase" "--continue")))
(t
(let ((section (magit-current-section)))
(let ((fun (if (eq (magit-section-type section) 'hunk)
(save-window-excursion
@ -2395,8 +2409,8 @@ Prefix arg means justify as well."
(error "No change at point"))))))
(magit-log-edit)
(goto-char (point-min))
(cond ((not (search-forward-regexp (format "^\\* %s" (regexp-quote file))
nil t))
(cond ((not (search-forward-regexp
(format "^\\* %s" (regexp-quote file)) nil t))
;; No entry for file, create it.
(goto-char (point-max))
(insert (format "\n* %s" file))
@ -2406,7 +2420,8 @@ Prefix arg means justify as well."
(fun
;; found entry for file, look for fun
(let ((limit (or (save-excursion
(and (search-forward-regexp "^\\* " nil t)
(and (search-forward-regexp "^\\* "
nil t)
(match-beginning 0)))
(point-max))))
(cond ((search-forward-regexp (format "(.*\\<%s\\>.*):"
@ -2422,7 +2437,7 @@ Prefix arg means justify as well."
(if (bolp)
(open-line 1)
(newline))
(insert (format "(%s): " fun))))))))))
(insert (format "(%s): " fun))))))))))))
;;; Tags