chiark / gitweb /
stgit.el: Add "R" for stgit-resolve-file
authorGustav Hållberg <gustav@virtutech.com>
Thu, 30 Jul 2009 22:57:57 +0000 (00:57 +0200)
committerGustav Hållberg <gustav@virtutech.com>
Thu, 6 Aug 2009 20:49:07 +0000 (22:49 +0200)
Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
contrib/stgit.el

index a2c8837cb07b03ce06fa3fe10ffb138e37423925..9ee353ca3d16ec2e37e189331b964e8f12c6c589 100644 (file)
@@ -616,6 +616,7 @@ (unless stgit-mode-map
             ("\C-c\C-c" . stgit-commit)
             ("\C-c\C-u" . stgit-uncommit)
             ("U" .        stgit-revert-file)
+            ("R" .        stgit-resolve-file)
             ("\r" .       stgit-select)
             ("o" .        stgit-find-file-other-window)
             ("i" .        stgit-file-toggle-index)
@@ -833,6 +834,25 @@ (defun stgit-revert-file ()
             (stgit-run-git "checkout" "HEAD" co-file)))
         (stgit-reload)))))
 
+(defun stgit-resolve-file ()
+  "Resolve conflict in the file at point."
+  (interactive)
+  (let* ((patched-file (stgit-patched-file-at-point))
+         (patch        (stgit-patch-at-point))
+         (patch-name   (and patch (stgit-patch-name patch)))
+         (status       (and patched-file (stgit-file-status patched-file))))
+
+    (unless (memq patch-name '(:work :index))
+      (error "No index or working tree file on this line"))
+
+    (unless (eq status 'unmerged)
+      (error "No conflict to resolve at the current line"))
+
+    (stgit-capture-output nil
+      (stgit-move-change-to-index (stgit-file-file patched-file)))
+
+    (stgit-reload)))
+
 (defun stgit-uncommit (count)
   "Run stg uncommit on COUNT commits.
 Interactively, the prefix argument is used as COUNT."
@@ -942,6 +962,8 @@ (defun stgit-file-toggle-index ()
   (let ((patched-file (stgit-patched-file-at-point)))
     (unless patched-file
       (error "No file on the current line"))
+    (when (eq (stgit-file-status patched-file) 'unmerged)
+      (error (substitute-command-keys "Use \\[stgit-resolve-file] to move an unmerged file to the index")))
     (let ((patch-name (stgit-patch-name-at-point)))
       (cond ((eq patch-name :work)
              (stgit-move-change-to-index (stgit-file-file patched-file)))