" HEAD"))
t)))
-(defun cherry-picked-p (commit merge-base)
- (car
- (string-lines
- (shell-command-to-string
- (concat "git -C " source-directory
- " log -1 --pretty=%H --grep='(cherry picked from commit "
- commit
- ")' "
- merge-base "..HEAD"))
- t)))
-
-(defun cherry-skipped-p (commit)
- (= 0 (call-process "grep" cherry-skip-list-file nil nil
- "-q" "-E" (concat "^" commit))))
-
(defun cherry-upstream-commits ()
(string-lines
(shell-command-to-string
(concat "git -C " source-directory
- " cherry HEAD upstream/master | grep -vE '^-' | cut -f 2 -d ' '"))
+ " cherry HEAD "
+ cherry-upstream-remote "/" cherry-upstream-branch
+ " | grep -vE '^-' | cut -f 2 -d ' '"))
t))
(defun cherry-pick-new-commits ()
(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...")
- (let* ((merge-base (cherry-merge-base))
- (new-commits
- (seq-remove
- (lambda (commit)
- (or (cherry-picked-p commit merge-base)
- (cherry-skipped-p commit)))
- (cherry-upstream-commits))))
+ (message "Listing upstream commits...")
+ (let ((upstream-commits (cherry-upstream-commits))
+ (new-commits nil)
+ (old-commits (make-hash-table :test 'equal)))
+ (message "Reading skip list...")
+ (dolist (line (with-temp-buffer
+ (insert-file-contents cherry-skip-list-file)
+ (split-string (buffer-string) "\n" t)))
+ (puthash (substring line 0 40) t old-commits))
+ (message "Finding picked commits...")
+ (dolist (commit
+ (string-lines
+ (shell-command-to-string
+ (concat "git -C " source-directory
+ " log --grep '(cherry picked from commit' "
+ (cherry-merge-base) "..HEAD"
+ " | grep '(cherry picked from commit' | sed -e 's/^.*commit \\(.*\\)).*$/\\1/g'"))
+ t))
+ (puthash commit t old-commits))
+ (dolist-with-progress-reporter (commit upstream-commits)
+ "Checking for new commits"
+ (or (gethash commit old-commits) (push commit new-commits)))
+ (setq new-commits (nreverse new-commits))
(if (null new-commits)
(message "No new commits.")
(let ((num-new (length new-commits))