{"thread":{"id":"11495","subject":"[PATCH 3/3] git.el: Display file types and type changes.","startedAt":"2008-01-06T11:13:36Z","lastAt":"2008-01-06T11:13:36Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"64588","messageId":"87y7b36wbj.fsf@wine.dyndns.org","threadId":"11495","inReplyTo":null,"subject":"[PATCH 3/3] git.el: Display file types and type changes.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2008-01-06T11:13:36Z","receivedAt":"2008-01-06T11:13:36Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Handle the T status from git-diff-index to display type changes\nbetween file/symlink/subproject. Also always show the file type for\nsymlink and subprojects to indicate that they are not normal files.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   34 +++++++++++++++++++++++++++++++---\n 1 files changed, 31 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 820df11..5f0d461 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -489,8 +489,7 @@ and returns the process output as a string.\"\n   \"Set the state of a file info.\"\n   (unless (eq (git-fileinfo->state info) state)\n     (setf (git-fileinfo->state info) state\n-          (git-fileinfo->old-perm info) 0\n-          (git-fileinfo->new-perm info) 0\n+          (git-fileinfo->new-perm info) (git-fileinfo->old-perm info)\n           (git-fileinfo->rename-state info) nil\n           (git-fileinfo->orig-name info) nil\n           (git-fileinfo->needs-refresh info) t)))\n@@ -524,6 +523,7 @@ and returns the process output as a string.\"\n     (?A 'added)\n     (?D 'deleted)\n     (?U 'unmerged)\n+    (?T 'modified)\n     (t nil)))\n \n (defun git-status-code-as-string (code)\n@@ -538,6 +538,33 @@ and returns the process output as a string.\"\n     ('ignored  (propertize \"Ignored \" 'face 'git-ignored-face))\n     (t \"?       \")))\n \n+(defun git-file-type-as-string (info)\n+  \"Return a string describing the file type of INFO.\"\n+  (let* ((old-type (lsh (or (git-fileinfo->old-perm info) 0) -9))\n+         (new-type (lsh (or (git-fileinfo->new-perm info) 0) -9))\n+         (str (case new-type\n+                (?\\100  ;; file\n+                 (case old-type\n+                   (?\\100 nil)\n+                   (?\\120 \"   (type change symlink -> file)\")\n+                   (?\\160 \"   (type change subproject -> file)\")))\n+                 (?\\120  ;; symlink\n+                  (case old-type\n+                    (?\\100 \"   (type change file -> symlink)\")\n+                    (?\\160 \"   (type change subproject -> symlink)\")\n+                    (t \"   (symlink)\")))\n+                  (?\\160  ;; subproject\n+                   (case old-type\n+                     (?\\100 \"   (type change file -> subproject)\")\n+                     (?\\120 \"   (type change symlink -> subproject)\")\n+                     (t \"   (subproject)\")))\n+                  (?\\000  ;; deleted or unknown\n+                   (case old-type\n+                     (?\\120 \"   (symlink)\")\n+                     (?\\160 \"   (subproject)\")))\n+                  (t (format \"   (unknown type %o)\" new-type)))))\n+    (if str (propertize str 'face 'git-status-face) \"\")))\n+\n (defun git-rename-as-string (info)\n   \"Return a string describing the copy or rename associated with INFO, or an empty string if none.\"\n   (let ((state (git-fileinfo->rename-state info)))\n@@ -567,6 +594,7 @@ and returns the process output as a string.\"\n                   \" \" (git-status-code-as-string (git-fileinfo->state info))\n                   \" \" (git-permissions-as-string (git-fileinfo->old-perm info) (git-fileinfo->new-perm info))\n                   \"  \" (git-escape-file-name (git-fileinfo->name info))\n+                  (git-file-type-as-string info)\n                   (git-rename-as-string info))))\n \n (defun git-insert-info-list (status infolist)\n@@ -603,7 +631,7 @@ Return the list of files that haven't been handled.\"\n       (apply #'git-call-process-env t nil \"diff-index\" \"-z\" \"-M\" \"HEAD\" \"--\" files)\n       (goto-char (point-min))\n       (while (re-search-forward\n-              \":\\\\([0-7]\\\\{6\\\\}\\\\) \\\\([0-7]\\\\{6\\\\}\\\\) [0-9a-f]\\\\{40\\\\} [0-9a-f]\\\\{40\\\\} \\\\(\\\\([ADMU]\\\\)\\0\\\\([^\\0]+\\\\)\\\\|\\\\([CR]\\\\)[0-9]*\\0\\\\([^\\0]+\\\\)\\0\\\\([^\\0]+\\\\)\\\\)\\0\"\n+              \":\\\\([0-7]\\\\{6\\\\}\\\\) \\\\([0-7]\\\\{6\\\\}\\\\) [0-9a-f]\\\\{40\\\\} [0-9a-f]\\\\{40\\\\} \\\\(\\\\([ADMUT]\\\\)\\0\\\\([^\\0]+\\\\)\\\\|\\\\([CR]\\\\)[0-9]*\\0\\\\([^\\0]+\\\\)\\0\\\\([^\\0]+\\\\)\\\\)\\0\"\n               nil t 1)\n         (let ((old-perm (string-to-number (match-string 1) 8))\n               (new-perm (string-to-number (match-string 2) 8))\n-- \n1.5.4.rc2.53.gb6f8\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}