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

133
magit.el
View file

@ -1957,7 +1957,12 @@ in log buffer."
;;; Rebasing ;;; Rebasing
(defun magit-rebase-info () (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"))) (list (magit-name-rev (car (magit-file-lines ".dotest/onto")))
(car (magit-file-lines ".dotest/next")) (car (magit-file-lines ".dotest/next"))
(car (magit-file-lines ".dotest/last")))) (car (magit-file-lines ".dotest/last"))))
@ -2362,67 +2367,77 @@ Prefix arg means justify as well."
(defun magit-log-edit () (defun magit-log-edit ()
(interactive) (interactive)
(magit-log-edit-set-field 'tag nil) (cond ((magit-rebase-info)
(when (and magit-commit-all-when-nothing-staged (if (y-or-n-p "Rebase in progress. Continue it? ")
(not (magit-anything-staged-p))) (magit-run-git "rebase" "--continue")))
(cond ((eq magit-commit-all-when-nothing-staged 'ask-stage) (t
(if (and (not (magit-everything-clean-p)) (magit-log-edit-set-field 'tag nil)
(y-or-n-p "Nothing staged. Stage everything now? ")) (when (and magit-commit-all-when-nothing-staged
(magit-stage-all))) (not (magit-anything-staged-p)))
((not (magit-log-edit-get-field 'commit-all)) (cond ((eq magit-commit-all-when-nothing-staged 'ask-stage)
(magit-log-edit-set-field (if (and (not (magit-everything-clean-p))
'commit-all (y-or-n-p "Nothing staged. Stage everything now? "))
(if (or (eq magit-commit-all-when-nothing-staged t) (magit-stage-all)))
(y-or-n-p "Nothing staged. Commit all unstaged changes? ")) ((not (magit-log-edit-get-field 'commit-all))
"yes" "no"))))) (magit-log-edit-set-field
(magit-pop-to-log-edit "commit")) 'commit-all
(if (or (eq magit-commit-all-when-nothing-staged t)
(y-or-n-p
"Nothing staged. Commit all unstaged changes? "))
"yes" "no")))))
(magit-pop-to-log-edit "commit"))))
(defun magit-add-log () (defun magit-add-log ()
(interactive) (interactive)
(let ((section (magit-current-section))) (cond ((magit-rebase-info)
(let ((fun (if (eq (magit-section-type section) 'hunk) (if (y-or-n-p "Rebase in progress. Continue it? ")
(save-window-excursion (magit-run-git "rebase" "--continue")))
(save-excursion (t
(magit-visit-item) (let ((section (magit-current-section)))
(add-log-current-defun))) (let ((fun (if (eq (magit-section-type section) 'hunk)
nil)) (save-window-excursion
(file (magit-diff-item-file (save-excursion
(cond ((eq (magit-section-type section) 'hunk) (magit-visit-item)
(magit-hunk-item-diff section)) (add-log-current-defun)))
((eq (magit-section-type section) 'diff) nil))
section) (file (magit-diff-item-file
(t (cond ((eq (magit-section-type section) 'hunk)
(error "No change at point")))))) (magit-hunk-item-diff section))
(magit-log-edit) ((eq (magit-section-type section) 'diff)
(goto-char (point-min)) section)
(cond ((not (search-forward-regexp (format "^\\* %s" (regexp-quote file)) (t
nil t)) (error "No change at point"))))))
;; No entry for file, create it. (magit-log-edit)
(goto-char (point-max)) (goto-char (point-min))
(insert (format "\n* %s" file)) (cond ((not (search-forward-regexp
(if fun (format "^\\* %s" (regexp-quote file)) nil t))
(insert (format " (%s)" fun))) ;; No entry for file, create it.
(insert ": ")) (goto-char (point-max))
(fun (insert (format "\n* %s" file))
;; found entry for file, look for fun (if fun
(let ((limit (or (save-excursion (insert (format " (%s)" fun)))
(and (search-forward-regexp "^\\* " nil t) (insert ": "))
(match-beginning 0))) (fun
(point-max)))) ;; found entry for file, look for fun
(cond ((search-forward-regexp (format "(.*\\<%s\\>.*):" (let ((limit (or (save-excursion
(regexp-quote fun)) (and (search-forward-regexp "^\\* "
limit t) nil t)
;; found it, goto end of current entry (match-beginning 0)))
(if (search-forward-regexp "^(" limit t) (point-max))))
(backward-char 2) (cond ((search-forward-regexp (format "(.*\\<%s\\>.*):"
(goto-char limit))) (regexp-quote fun))
(t limit t)
;; not found, insert new entry ;; found it, goto end of current entry
(goto-char limit) (if (search-forward-regexp "^(" limit t)
(if (bolp) (backward-char 2)
(open-line 1) (goto-char limit)))
(newline)) (t
(insert (format "(%s): " fun)))))))))) ;; not found, insert new entry
(goto-char limit)
(if (bolp)
(open-line 1)
(newline))
(insert (format "(%s): " fun))))))))))))
;;; Tags ;;; Tags