]> git.eshelyaron.com Git - emacs.git/commitdiff
; (cherry-pick-new-commits): Improve error handling.
authorEshel Yaron <me@eshelyaron.com>
Tue, 2 Jan 2024 11:02:02 +0000 (12:02 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 2 Jan 2024 11:02:02 +0000 (12:02 +0100)
admin/cherry.el

index c6dfb75a85b3cca75198baf71351789df1386f58..d0ee48d723757683238a47e3e27a23a03c069124 100644 (file)
@@ -70,8 +70,8 @@
   "Pick or skip new commits in the upstream branch."
   (interactive)
   (message "Ensuring working directory is clean...")
-  (or (eq 0 (cherry--call-git "diff-index" "--quiet" "HEAD" "--"))
-      (user-error "Working directory is dirty, cannot start cherry picking"))
+  (unless (= 0 (cherry--call-git "diff-index" "--quiet" "HEAD" "--"))
+    (user-error "Working directory is dirty, cannot start cherry picking"))
   (message "Fetching from upstream...")
   (cherry--call-git "fetch" cherry-upstream-remote)
   (message "Checking for new commits...")
             (pcase (car choice)
               (?s
                (message "Skipping...")
-               (shell-command (concat "echo " commit
-                                      (read-string "Reason: " "")
-                                      ">>" cherry-skip-list-file))
-               (cherry--call-git "commit" "-m"
-                                 (concat "; Skip commit " commit)
-                                 (file-relative-name
-                                  cherry-skip-list-file source-directory))
+               (unless (= 0 (shell-command
+                             (concat "echo " commit
+                                     (shell-quote-argument
+                                      (read-string "Reason: " ""))
+                                     ">>" cherry-skip-list-file)))
+                 (user-error "Failed to write commit to skip list"))
+               (unless (= 0 (cherry--call-git
+                             "commit" "-m"
+                             (concat "; Skip commit " commit)
+                             (file-relative-name
+                              cherry-skip-list-file source-directory)))
+                 (user-error "Failed to commit updated skip list"))
                (message "Added to skip list and committed."))
               (?p
                (message "Picking...")
-               (if (= 0 (cherry--call-git "cherry-pick" "-x" commit))
-                   (message "Picked.")
-                 (user-error "Cherry picking failed")))
+               (unless (= 0 (cherry--call-git "cherry-pick" "-x" commit))
+                 (user-error "Cherry picking failed"))
+               (message "Picked."))
               (?q (bury-buffer "*cherry*")
                   (user-error "Quit cherry picking"))))))
       (message "Done."))))