"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."))))