branch: elpa/magit
commit 0e624c6c39f7334c3ac92fa9d6deaa4d4d7c257b
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    Rearrange definitions and documentation of commit commands
    
    Rearrange their definitions and the order in which they are described
    in the manual, to better mirror their new arrangement in the menu.
---
 docs/magit.org       | 32 +++++++++++++++++++++-----------
 docs/magit.texi      | 51 +++++++++++++++++++++++++++++++++++++--------------
 lisp/magit-commit.el | 29 ++++++++++++++++++++++-------
 3 files changed, 80 insertions(+), 32 deletions(-)

diff --git a/docs/magit.org b/docs/magit.org
index a7436be2708..acdfc666a43 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -4618,13 +4618,13 @@ Also see [[man:git-commit]]
   along with the appropriate infix arguments and displays them in a
   temporary buffer until a suffix is invoked.
 
+**** Creating a new commit
+
 - Key: c c (magit-commit-create) ::
 
   Create a new commit.
 
-- Key: c a (magit-commit-amend) ::
-
-  Amend the last commit.
+**** Editing the last commit
 
 - Key: c e (magit-commit-extend) ::
 
@@ -4636,6 +4636,10 @@ Also see [[man:git-commit]]
   Non-interactively respect the optional OVERRIDE-DATE argument and
   ignore the option.
 
+- Key: c a (magit-commit-amend) ::
+
+  Amend the last commit.
+
 - Key: c w (magit-commit-reword) ::
 
   Reword the last commit, ignoring staged changes.  With a prefix
@@ -4646,6 +4650,8 @@ Also see [[man:git-commit]]
   Non-interactively respect the optional OVERRIDE-DATE argument and
   ignore the option.
 
+**** Editing any reachable commit
+
 - Key: c f (magit-commit-fixup) ::
 
   Create a fixup commit.
@@ -4654,10 +4660,6 @@ Also see [[man:git-commit]]
   Otherwise the commit at point may be used without confirmation
   depending on the value of option ~magit-commit-squash-confirm~.
 
-- Key: c F (magit-commit-instant-fixup) ::
-
-  Create a fixup commit and instantly rebase.
-
 - Key: c s (magit-commit-squash) ::
 
   Create a squash commit, without editing the squash message.
@@ -4666,10 +4668,6 @@ Also see [[man:git-commit]]
   Otherwise the commit at point may be used without confirmation
   depending on the value of option ~magit-commit-squash-confirm~.
 
-- Key: c S (magit-commit-instant-squash) ::
-
-  Create a squash commit and instantly rebase.
-
 - Key: c A (magit-commit-alter) ::
 
   Create a squash commit, finalizing the message up front.
@@ -4695,6 +4693,18 @@ Also see [[man:git-commit]]
   Otherwise the commit at point may be used without confirmation
   depending on the value of option ~magit-commit-squash-confirm~.
 
+**** Editing any reachable commit and rebase immediately
+
+- Key: c F (magit-commit-instant-fixup) ::
+
+  Create a fixup commit and instantly rebase.
+
+- Key: c S (magit-commit-instant-squash) ::
+
+  Create a squash commit and instantly rebase.
+
+**** Options for commit commands
+
 - User Option: magit-commit-ask-to-stage ::
 
   Whether to ask to stage all unstaged changes when committing and nothing is
diff --git a/docs/magit.texi b/docs/magit.texi
index f0994ba0e14..21930b688fd 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -5490,17 +5490,22 @@ the git-commit(1) manpage.
 This transient prefix command binds the following suffix commands
 along with the appropriate infix arguments and displays them in a
 temporary buffer until a suffix is invoked.
+@end table
+
+@anchor{Creating a new commit}
+@subsubheading Creating a new commit
 
+@table @asis
 @item @kbd{c c} (@code{magit-commit-create})
 @kindex c c
 @findex magit-commit-create
 Create a new commit.
+@end table
 
-@item @kbd{c a} (@code{magit-commit-amend})
-@kindex c a
-@findex magit-commit-amend
-Amend the last commit.
+@anchor{Editing the last commit}
+@subsubheading Editing the last commit
 
+@table @asis
 @item @kbd{c e} (@code{magit-commit-extend})
 @kindex c e
 @findex magit-commit-extend
@@ -5512,6 +5517,11 @@ of the prefix argument.
 Non-interactively respect the optional OVERRIDE-DATE argument and
 ignore the option.
 
+@item @kbd{c a} (@code{magit-commit-amend})
+@kindex c a
+@findex magit-commit-amend
+Amend the last commit.
+
 @item @kbd{c w} (@code{magit-commit-reword})
 @kindex c w
 @findex magit-commit-reword
@@ -5522,7 +5532,12 @@ of the prefix argument.
 
 Non-interactively respect the optional OVERRIDE-DATE argument and
 ignore the option.
+@end table
+
+@anchor{Editing any reachable commit}
+@subsubheading Editing any reachable commit
 
+@table @asis
 @item @kbd{c f} (@code{magit-commit-fixup})
 @kindex c f
 @findex magit-commit-fixup
@@ -5532,11 +5547,6 @@ With a prefix argument the target commit has to be 
confirmed.
 Otherwise the commit at point may be used without confirmation
 depending on the value of option @code{magit-commit-squash-confirm}.
 
-@item @kbd{c F} (@code{magit-commit-instant-fixup})
-@kindex c F
-@findex magit-commit-instant-fixup
-Create a fixup commit and instantly rebase.
-
 @item @kbd{c s} (@code{magit-commit-squash})
 @kindex c s
 @findex magit-commit-squash
@@ -5546,11 +5556,6 @@ With a prefix argument the target commit has to be 
confirmed.
 Otherwise the commit at point may be used without confirmation
 depending on the value of option @code{magit-commit-squash-confirm}.
 
-@item @kbd{c S} (@code{magit-commit-instant-squash})
-@kindex c S
-@findex magit-commit-instant-squash
-Create a squash commit and instantly rebase.
-
 @item @kbd{c A} (@code{magit-commit-alter})
 @kindex c A
 @findex magit-commit-alter
@@ -5580,6 +5585,24 @@ Otherwise the commit at point may be used without 
confirmation
 depending on the value of option @code{magit-commit-squash-confirm}.
 @end table
 
+@anchor{Editing any reachable commit and rebase immediately}
+@subsubheading Editing any reachable commit and rebase immediately
+
+@table @asis
+@item @kbd{c F} (@code{magit-commit-instant-fixup})
+@kindex c F
+@findex magit-commit-instant-fixup
+Create a fixup commit and instantly rebase.
+
+@item @kbd{c S} (@code{magit-commit-instant-squash})
+@kindex c S
+@findex magit-commit-instant-squash
+Create a squash commit and instantly rebase.
+@end table
+
+@anchor{Options for commit commands}
+@subsubheading Options for commit commands
+
 @defopt magit-commit-ask-to-stage
 Whether to ask to stage all unstaged changes when committing and nothing is
 staged.
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index b804bcab2f1..14efb147db7 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -183,6 +183,7 @@ Also see https://github.com/magit/magit/issues/4132.";
                                   "ORIG_HEAD"))))
 
 ;;; Commands
+;;;; Create
 
 ;;;###autoload
 (defun magit-commit-create (&optional args)
@@ -196,13 +197,7 @@ Also see https://github.com/magit/magit/issues/4132.";
     (let ((default-directory (magit-toplevel)))
       (magit-run-git-with-editor "commit" args))))
 
-;;;###autoload
-(defun magit-commit-amend (&optional args)
-  "Amend the last commit.
-\n(git commit --amend ARGS)"
-  (interactive (list (magit-commit-arguments)))
-  (magit-commit-amend-assert)
-  (magit-run-git-with-editor "commit" "--amend" args))
+;;;; Edit HEAD
 
 ;;;###autoload
 (defun magit-commit-extend (&optional args override-date)
@@ -224,6 +219,14 @@ to inverse the meaning of the prefix argument.
           (("GIT_COMMITTER_DATE" (magit-rev-format "%cD")))
         (magit-run-git-with-editor "commit" "--amend" "--no-edit" args)))))
 
+;;;###autoload
+(defun magit-commit-amend (&optional args)
+  "Amend the last commit.
+\n(git commit --amend ARGS)"
+  (interactive (list (magit-commit-arguments)))
+  (magit-commit-amend-assert)
+  (magit-run-git-with-editor "commit" "--amend" args))
+
 ;;;###autoload
 (defun magit-commit-reword (&optional args override-date)
   "Reword the last commit, ignoring staged changes.
@@ -247,6 +250,8 @@ and ignore the option.
         (("GIT_COMMITTER_DATE" (magit-rev-format "%cD")))
       (magit-run-git-with-editor "commit" "--amend" "--only" args))))
 
+;;;; Edit
+
 ;;;###autoload
 (defun magit-commit-fixup (&optional commit args)
   "Create a fixup commit.
@@ -305,6 +310,8 @@ depending on the value of option 
`magit-commit-squash-confirm'."
                      (magit-commit-arguments)))
   (magit-commit-squash-internal "--fixup=reword:" commit args 'nopatch 'edit))
 
+;;;; Edit and Rebase
+
 ;;;###autoload
 (defun magit-commit-instant-fixup (&optional commit args)
   "Create a fixup commit targeting COMMIT and instantly rebase."
@@ -319,6 +326,8 @@ depending on the value of option 
`magit-commit-squash-confirm'."
                      (magit-commit-arguments)))
   (magit-commit-squash-internal "--squash=" commit args nil nil 'rebase))
 
+;;;; Internal
+
 (defun magit-commit-squash-internal
     (option commit &optional args nopatch edit rebase confirmed)
   (when-let ((args (magit-commit-assert args nopatch (not edit))))
@@ -421,6 +430,8 @@ depending on the value of option 
`magit-commit-squash-confirm'."
    (t
     (user-error "Nothing staged"))))
 
+;;;; Reshelve
+
 (defvar magit--reshelve-history nil)
 
 ;;;###autoload
@@ -455,6 +466,8 @@ is updated:
                    (and update-author (concat "--date=" date))
                    args)))
 
+;;;; Spread
+
 ;;;###autoload
 (defun magit-commit-absorb-modules (phase commit)
   "Spread modified modules across recent commits."
@@ -577,6 +590,8 @@ See `magit-commit-absorb' for an alternative 
implementation."
   :argument "--strict="
   :reader #'transient-read-number-N0)
 
+;;;; Hooks
+
 (defvar magit-post-commit-hook-commands
   (list #'magit-commit-extend
         #'magit-commit-fixup

Reply via email to