From 3c631ee3315344d77e4f64c13c32d5b43f381c38 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 18 Nov 2020 00:16:12 -0500 Subject: km/magit-patch-create-series: Move an error closer to its origin --- lisp/km-magit.el | 72 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/lisp/km-magit.el b/lisp/km-magit.el index 0943fe8..3828812 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -879,42 +879,42 @@ appending [M/N] to each entry." (setq args (seq-remove (lambda (a) (string-match-p "\\`--base=" a)) args)) - (if-let ((current (magit-get-current-branch)) - (upstream (magit-get-upstream-branch current))) - (let ((patch-branch (concat "patches/" current))) - (if (not (magit-local-branch-p patch-branch)) - (magit-branch-and-checkout patch-branch current) - (magit-update-ref (concat "refs/heads/" patch-branch) - (concat "reset: moving back to " current) - current) - (magit-branch-checkout patch-branch)) - (apply #'magit-run-git "format-patch" - upstream (concat "--base=" upstream) args) - (let* ((patches (or (seq-filter - (lambda (f) (string-match-p "\\.patch\\'" f)) - (magit-untracked-files)) - (error "There should be patches"))) - (cover (seq-find - (lambda (f) - (string-match-p - (rx string-start - (zero-or-one "v" (one-or-more digit) "-") - (one-or-more "0")) - f)) - patches))) - (magit-call-git "add" patches) - (magit-run-git "commit" "-mpatches") - (when cover - (with-temp-buffer - (insert-file-contents cover) - (km/magit-tweak-patch-series-summary) - (write-region nil nil cover)) - (magit-call-git "commit" "-mtweak cover" "--" cover)) - (when cover - (find-file-other-window cover) - (re-search-forward (rx "Subject: [PATCH" (zero-or-more not-newline) "] ")) - (setq buffer-read-only nil)))) - (user-error "No upstream branch"))) + (let* ((current (magit-get-current-branch)) + (upstream (or (magit-get-upstream-branch current) + (user-error "No upstream branch"))) + (patch-branch (concat "patches/" current))) + (if (not (magit-local-branch-p patch-branch)) + (magit-branch-and-checkout patch-branch current) + (magit-update-ref (concat "refs/heads/" patch-branch) + (concat "reset: moving back to " current) + current) + (magit-branch-checkout patch-branch)) + (apply #'magit-run-git "format-patch" + upstream (concat "--base=" upstream) args) + (let* ((patches (or (seq-filter + (lambda (f) (string-match-p "\\.patch\\'" f)) + (magit-untracked-files)) + (error "There should be patches"))) + (cover (seq-find + (lambda (f) + (string-match-p + (rx string-start + (zero-or-one "v" (one-or-more digit) "-") + (one-or-more "0")) + f)) + patches))) + (magit-call-git "add" patches) + (magit-run-git "commit" "-mpatches") + (when cover + (with-temp-buffer + (insert-file-contents cover) + (km/magit-tweak-patch-series-summary) + (write-region nil nil cover)) + (magit-call-git "commit" "-mtweak cover" "--" cover)) + (when cover + (find-file-other-window cover) + (re-search-forward (rx "Subject: [PATCH" (zero-or-more not-newline) "] ")) + (setq buffer-read-only nil))))) ;;; Copy functions -- cgit v1.2.3