]> code.delx.au - gnu-emacs/commitdiff
Integrate RĂ¼diger Sonderfeld's code for detecting conflicted files under git.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 13 Aug 2014 08:05:45 +0000 (04:05 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 13 Aug 2014 08:05:45 +0000 (04:05 -0400)
lisp/ChangeLog
lisp/vc/vc-git.el

index 7bb7415bc9c1d2bb7d56275581eaeff9ab640a2a..764d6d12c8aa3d1e3fd9f0c15e96ec42708e1266 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-13  Eric S. Raymond  <esr@thyrsus.com>
+
+       * vc/vc-git.el (vc-git-conflicted-files): Integrate RĂ¼diger
+       Sonderfeld's code for detecting conflicted files using a status
+       listing.  Useful in itself and a step towards better smerge
+       support.
+
 2014-08-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * mpc.el (mpc-reorder): Don't bother splitting the "active"s elements
index 9c8ab3ba3934d23293de3ae87f6aaf61f85a07d0..3e9228601d840b15d85e58e3a8d154dc90e77037 100644 (file)
 ;; - delete-file (file)                            OK
 ;; - rename-file (old new)                         OK
 ;; - find-file-hook ()                             NOT NEEDED
+;; - conflicted-files                              OK
 
 ;;; Code:
 
@@ -769,6 +770,23 @@ This prompts for a branch to merge from."
     (with-current-buffer buffer (vc-run-delayed (vc-compilation-mode 'git)))
     (vc-set-async-update buffer)))
 
+(defun vc-git-conflicted-files (directory)
+  "Return the list of files with conflicts in DIRECTORY."
+  (let* ((status
+          (vc-git--run-command-string directory "status" "--porcelain" "--"))
+         (lines (split-string status "\n" 'omit-nulls))
+         files)
+    (dolist (line lines files)
+      (when (string-match "\\([ MADRCU?!][ MADRCU?!]\\) \\(.+\\)\\(?: -> \\(.+\\)\\)?"
+                          line)
+        (let ((state (match-string 1 line))
+              (file (match-string 2 line)))
+          ;; See git-status(1).
+          (when (member state '("AU" "UD" "UA" ;; "DD"
+                                "DU" "AA" "UU"))
+            (push file files)))))))
+
+
 ;;; HISTORY FUNCTIONS
 
 (autoload 'vc-setup-buffer "vc-dispatcher")