请教大家:
Magit Interactive Rebase (M-x magit-dispatch RET r i)
的 commits 排序由上下到为:旧->新,与 git log 的排序相反,不知道有无现成方案把它的排序变为:新->旧?
参考:
请教大家:
Magit Interactive Rebase (M-x magit-dispatch RET r i)
的 commits 排序由上下到为:旧->新,与 git log 的排序相反,不知道有无现成方案把它的排序变为:新->旧?
参考:
提供个思路
(defun eli/magit-reverse-rebase-commits ()
"Reverse the order of commits displayed during a Git interactive rebase."
(read-only-mode -1)
(let* ((beg (point-min))
(end (save-excursion
(goto-char beg)
(re-search-forward "^$"))))
(reverse-region beg end))
(read-only-mode 1)
(add-hook 'with-editor-pre-finish-hook #'eli/magit-reverse-rebase-commits nil t))
(add-hook 'git-rebase-mode-hook #'eli/magit-reverse-rebase-commits)
完美。
感谢大佬。直接修改 region 顺序,学到了。
read-only-mode
的设置加到(let ((inhibit-read-only t)) ...)
省出一行。