@@ -205,8 +205,8 @@ REQUIRE-MATCH."
205
205
(or (and use-marks intersection)
206
206
region
207
207
(and use-marks (magit-stgit-patches-sorted magit-stgit--marked-patches))
208
- (list ( or ( and use-point (magit-section-value-if 'stgit-patch ))
209
- (and prompt (magit-stgit-read-patch prompt require-match) ))))))
208
+ (and use-point (-list ( magit-section-value-if 'stgit-patch ) ))
209
+ (and prompt (-list ( magit-stgit-read-patch prompt require-match))))))
210
210
211
211
(defun magit-stgit-mark-contains (patch )
212
212
" Return whether the given PATCH is marked."
@@ -259,7 +259,7 @@ one from the minibuffer, and move to the next line."
259
259
(" f" " Float" magit-stgit-float)
260
260
(" s" " Sink" magit-stgit-sink)
261
261
(" a" " Goto" magit-stgit-goto-popup)]
262
- [(" c" " Commit" magit-stgit-commit-popup )
262
+ [(" c" " Commit" magit-stgit-commit)
263
263
(" C" " Uncommit" magit-stgit-uncommit-popup)
264
264
(" r" " Repair" magit-stgit-repair)
265
265
(" R" " Rebase" magit-stgit-rebase-popup)]
@@ -388,23 +388,39 @@ minibuffer as well."
388
388
(magit-run-stgit-and-mark-remove
389
389
patches (and target (list " -t" target)) " sink" args patches)))
390
390
391
- (magit-define-popup magit-stgit-commit-popup
392
- " Popup console for StGit commit."
393
- 'magit-stgit-commands
394
- :switches '((?a " Commit all applied patches" " --all" ))
395
- :options '((?n " Commit the specified number of patches" " --number=" read-number))
396
- :actions '((?c " Commit" magit-stgit-commit))
397
- :default-action #'magit-stgit-commit )
391
+ (transient-define-prefix magit-stgit-commit ()
392
+ " Commit a set of patches."
393
+ :man-page " stg-commit"
394
+ [" Arguments"
395
+ (" -a" " Commit all applied patches" " --all" )
396
+ (" -n" " Commit the first N patches from the bottom up" " --number="
397
+ :reader (lambda (prompt _initial-input history )
398
+ (number-to-string (read-number prompt nil history))))]
399
+ [" Actions"
400
+ (" c" " Commit" magit-stgit--commit)])
401
+
402
+ (defun magit-stgit--commit-need-patches-p (args )
403
+ (and (not (member " --all" args))
404
+ (not (member " --number" args))
405
+ (not (transient-arg-value " --number=" args))))
398
406
399
407
;;;### autoload
400
- (defun magit-stgit-commit (patches &rest args )
401
- " Permanently store patches into the stack base."
402
- (interactive (list (magit-stgit-read-patches t t t t nil )
403
- (magit-stgit-commit-arguments)))
404
- (when (and (member " --all" (car args))
405
- (= 1 (length patches)))
406
- (setq patches (list nil )))
407
- (magit-run-stgit-and-mark-remove patches " commit" args " --" patches))
408
+ (defun magit-stgit--commit (patches &rest args )
409
+ " Invoke `stg commit ARGS... PATCHES...'.
410
+
411
+ If PATCHES is nil, commit the bottommost patch.
412
+
413
+ PATCHES is ignored if ARGS contains `--all' or `--number' .
414
+
415
+ If called interactively, commit the patches around point or read
416
+ one from the minibuffer."
417
+ (interactive (let ((args (transient-args 'magit-stgit-commit )))
418
+ (cons (and (magit-stgit--commit-need-patches-p args)
419
+ (magit-stgit-read-patches t t t t " Commit patch" ))
420
+ args)))
421
+ (let ((patches (and (magit-stgit--commit-need-patches-p args)
422
+ (or patches (error " No patches provided " )))))
423
+ (magit-run-stgit-and-mark-remove patches " commit" args patches)))
408
424
409
425
(magit-define-popup magit-stgit-uncommit-popup
410
426
" Popup console for StGit uncommit."
@@ -663,7 +679,7 @@ the To, Cc, and Bcc fields for all patches."
663
679
:help " Rename a patch" ]
664
680
[" Edit patch" magit-stgit-edit
665
681
:help " Edit a patch" ]
666
- [" Commit patch" magit-stgit-commit-popup
682
+ [" Commit patch" magit-stgit-commit
667
683
:help " Permanently store the base patch into the stack base" ]
668
684
[" Uncommit patch" magit-stgit-uncommit-popup
669
685
:help " Turn a regular commit into an StGit patch" ]
0 commit comments