{"thread":{"id":"10069","subject":"[PATCH 2/4] git.el: Do not print a status message on every git command.","startedAt":"2007-09-29T09:58:39Z","lastAt":"2007-09-29T09:58:39Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"54323","messageId":"877im9pzcg.fsf@wine.dyndns.org","threadId":"10069","inReplyTo":null,"subject":"[PATCH 2/4] git.el: Do not print a status message on every git command.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-09-29T09:58:39Z","receivedAt":"2007-09-29T09:58:39Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Instead print a single message around sequences of commands that can\npotentially take some time.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/git.el |   70 +++++++++++++++++++++++++++++--------------------\n 1 files changed, 41 insertions(+), 29 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex 7b4a0d3..ec2e699 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -220,22 +220,15 @@ and returns the process output as a string.\"\n     (message \"Running git %s...done\" (car args))\n     buffer))\n \n-(defun git-run-command (buffer env &rest args)\n-  (message \"Running git %s...\" (car args))\n-  (apply #'git-call-process-env buffer env args)\n-  (message \"Running git %s...done\" (car args)))\n-\n (defun git-run-command-region (buffer start end env &rest args)\n   \"Run a git command with specified buffer region as input.\"\n-  (message \"Running git %s...\" (car args))\n   (unless (eq 0 (if env\n                     (git-run-process-region\n                      buffer start end \"env\"\n                      (append (git-get-env-strings env) (list \"git\") args))\n                   (git-run-process-region\n                    buffer start end \"git\" args)))\n-    (error \"Failed to run \\\"git %s\\\":\\n%s\" (mapconcat (lambda (x) x) args \" \") (buffer-string)))\n-  (message \"Running git %s...done\" (car args)))\n+    (error \"Failed to run \\\"git %s\\\":\\n%s\" (mapconcat (lambda (x) x) args \" \") (buffer-string))))\n \n (defun git-run-hook (hook env &rest args)\n   \"Run a git hook and display its output if any.\"\n@@ -312,6 +305,13 @@ and returns the process output as a string.\"\n               \"\\\"\")\n     name))\n \n+(defun git-success-message (text files)\n+  \"Print a success message after having handled FILES.\"\n+  (let ((n (length files)))\n+    (if (equal n 1)\n+        (message \"%s %s\" text (car files))\n+      (message \"%s %d files\" text n))))\n+\n (defun git-get-top-dir (dir)\n   \"Retrieve the top-level directory of a git tree.\"\n   (let ((cdup (with-output-to-string\n@@ -338,7 +338,7 @@ and returns the process output as a string.\"\n     (sort-lines nil (point-min) (point-max))\n     (save-buffer))\n   (when created\n-    (git-run-command nil nil \"update-index\" \"--add\" \"--\" (file-relative-name ignore-name)))\n+    (git-call-process-env nil nil \"update-index\" \"--add\" \"--\" (file-relative-name ignore-name)))\n   (git-update-status-files (list (file-relative-name ignore-name)) 'unknown)))\n \n ; propertize definition for XEmacs, stolen from erc-compat\n@@ -606,7 +606,7 @@ and returns the process output as a string.\"\n Return the list of files that haven't been handled.\"\n   (let (infolist)\n     (with-temp-buffer\n-      (apply #'git-run-command t nil \"diff-index\" \"-z\" \"-M\" \"HEAD\" \"--\" files)\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@@ -639,7 +639,7 @@ Return the list of files that haven't been handled.\"\n Return the list of files that haven't been handled.\"\n   (let (infolist)\n     (with-temp-buffer\n-      (apply #'git-run-command t nil \"ls-files\" \"-z\" (append options (list \"--\") files))\n+      (apply #'git-call-process-env t nil \"ls-files\" \"-z\" (append options (list \"--\") files))\n       (goto-char (point-min))\n       (while (re-search-forward \"\\\\([^\\0]*\\\\)\\0\" nil t 1)\n         (let ((name (match-string 1)))\n@@ -651,7 +651,7 @@ Return the list of files that haven't been handled.\"\n (defun git-run-ls-unmerged (status files)\n   \"Run git-ls-files -u on FILES and parse the results into STATUS.\"\n   (with-temp-buffer\n-    (apply #'git-run-command t nil \"ls-files\" \"-z\" \"-u\" \"--\" files)\n+    (apply #'git-call-process-env t nil \"ls-files\" \"-z\" \"-u\" \"--\" files)\n     (goto-char (point-min))\n     (let (unmerged-files)\n       (while (re-search-forward \"[0-7]\\\\{6\\\\} [0-9a-f]\\\\{40\\\\} [123]\\t\\\\([^\\0]+\\\\)\\0\" nil t)\n@@ -754,11 +754,11 @@ Return the list of files that haven't been handled.\"\n         ('deleted (push info deleted))\n         ('modified (push info modified))))\n     (when added\n-      (apply #'git-run-command nil env \"update-index\" \"--add\" \"--\" (git-get-filenames added)))\n+      (apply #'git-call-process-env nil env \"update-index\" \"--add\" \"--\" (git-get-filenames added)))\n     (when deleted\n-      (apply #'git-run-command nil env \"update-index\" \"--remove\" \"--\" (git-get-filenames deleted)))\n+      (apply #'git-call-process-env nil env \"update-index\" \"--remove\" \"--\" (git-get-filenames deleted)))\n     (when modified\n-      (apply #'git-run-command nil env \"update-index\" \"--\" (git-get-filenames modified)))))\n+      (apply #'git-call-process-env nil env \"update-index\" \"--\" (git-get-filenames modified)))))\n \n (defun git-run-pre-commit-hook ()\n   \"Run the pre-commit hook if any.\"\n@@ -790,6 +790,7 @@ Return the list of files that haven't been handled.\"\n                       head-tree (git-rev-parse \"HEAD^{tree}\")))\n               (if files\n                   (progn\n+                    (message \"Running git commit...\")\n                     (git-read-tree head-tree index-file)\n                     (git-update-index nil files)         ;update both the default index\n                     (git-update-index index-file files)  ;and the temporary one\n@@ -801,7 +802,7 @@ Return the list of files that haven't been handled.\"\n                             (condition-case nil (delete-file \".git/MERGE_MSG\") (error nil))\n                             (with-current-buffer buffer (erase-buffer))\n                             (git-set-files-state files 'uptodate)\n-                            (git-run-command nil nil \"rerere\")\n+                            (git-call-process-env nil nil \"rerere\")\n                             (git-refresh-files)\n                             (git-refresh-ewoc-hf git-status)\n                             (message \"Committed %s.\" commit)\n@@ -912,8 +913,9 @@ Return the list of files that haven't been handled.\"\n   (let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored))))\n     (unless files\n       (push (file-relative-name (read-file-name \"File to add: \" nil nil t)) files))\n-    (apply #'git-run-command nil nil \"update-index\" \"--add\" \"--\" files)\n-    (git-update-status-files files 'uptodate)))\n+    (apply #'git-call-process-env nil nil \"update-index\" \"--add\" \"--\" files)\n+    (git-update-status-files files 'uptodate)\n+    (git-success-message \"Added\" files)))\n \n (defun git-ignore-file ()\n   \"Add marked file(s) to the ignore list.\"\n@@ -922,7 +924,8 @@ Return the list of files that haven't been handled.\"\n     (unless files\n       (push (file-relative-name (read-file-name \"File to ignore: \" nil nil t)) files))\n     (dolist (f files) (git-append-to-ignore f))\n-    (git-update-status-files files 'ignored)))\n+    (git-update-status-files files 'ignored)\n+    (git-success-message \"Ignored\" files)))\n \n (defun git-remove-file ()\n   \"Remove the marked file(s).\"\n@@ -935,8 +938,9 @@ Return the list of files that haven't been handled.\"\n         (progn\n           (dolist (name files)\n             (when (file-exists-p name) (delete-file name)))\n-          (apply #'git-run-command nil nil \"update-index\" \"--remove\" \"--\" files)\n-          (git-update-status-files files nil))\n+          (apply #'git-call-process-env nil nil \"update-index\" \"--remove\" \"--\" files)\n+          (git-update-status-files files nil)\n+          (git-success-message \"Removed\" files))\n       (message \"Aborting\"))))\n \n (defun git-revert-file ()\n@@ -954,18 +958,20 @@ Return the list of files that haven't been handled.\"\n           ('unmerged (push (git-fileinfo->name info) modified))\n           ('modified (push (git-fileinfo->name info) modified))))\n       (when added\n-        (apply #'git-run-command nil nil \"update-index\" \"--force-remove\" \"--\" added))\n+        (apply #'git-call-process-env nil nil \"update-index\" \"--force-remove\" \"--\" added))\n       (when modified\n-        (apply #'git-run-command nil nil \"checkout\" \"HEAD\" modified))\n-      (git-update-status-files (append added modified) 'uptodate))))\n+        (apply #'git-call-process-env nil nil \"checkout\" \"HEAD\" modified))\n+      (git-update-status-files (append added modified) 'uptodate)\n+      (git-success-message \"Reverted\" files))))\n \n (defun git-resolve-file ()\n   \"Resolve conflicts in marked file(s).\"\n   (interactive)\n   (let ((files (git-get-filenames (git-marked-files-state 'unmerged))))\n     (when files\n-      (apply #'git-run-command nil nil \"update-index\" \"--\" files)\n-      (git-update-status-files files 'uptodate))))\n+      (apply #'git-call-process-env nil nil \"update-index\" \"--\" files)\n+      (git-update-status-files files 'uptodate)\n+      (git-success-message \"Resolved\" files))))\n \n (defun git-remove-handled ()\n   \"Remove handled files from the status list.\"\n@@ -992,9 +998,11 @@ Return the list of files that haven't been handled.\"\n   (interactive)\n   (if (setq git-show-ignored (not git-show-ignored))\n       (progn\n+        (message \"Inserting ignored files...\")\n         (git-run-ls-files-with-excludes git-status nil 'ignored \"-o\" \"-i\")\n         (git-refresh-files)\n-        (git-refresh-ewoc-hf git-status))\n+        (git-refresh-ewoc-hf git-status)\n+        (message \"Inserting ignored files...done\"))\n     (git-remove-handled)))\n \n (defun git-toggle-show-unknown ()\n@@ -1002,9 +1010,11 @@ Return the list of files that haven't been handled.\"\n   (interactive)\n   (if (setq git-show-unknown (not git-show-unknown))\n       (progn\n+        (message \"Inserting unknown files...\")\n         (git-run-ls-files-with-excludes git-status nil 'unknown \"-o\")\n         (git-refresh-files)\n-        (git-refresh-ewoc-hf git-status))\n+        (git-refresh-ewoc-hf git-status)\n+        (message \"Inserting unknown files...done\"))\n     (git-remove-handled)))\n \n (defun git-setup-diff-buffer (buffer)\n@@ -1207,7 +1217,8 @@ Return the list of files that haven't been handled.\"\n          (marked-files (git-get-filenames (ewoc-collect status (lambda (info) (git-fileinfo->marked info)))))\n          (cur-name (and pos (git-fileinfo->name (ewoc-data pos)))))\n     (unless status (error \"Not in git-status buffer.\"))\n-    (git-run-command nil nil \"update-index\" \"--refresh\")\n+    (message \"Refreshing git status...\")\n+    (git-call-process-env nil nil \"update-index\" \"--refresh\")\n     (git-clear-status status)\n     (git-update-status-files nil)\n     ; restore file marks\n@@ -1219,6 +1230,7 @@ Return the list of files that haven't been handled.\"\n                                 marked-files)\n       (git-refresh-files))\n     ; move point to the current file name if any\n+    (message \"Refreshing git status...done\")\n     (let ((node (and cur-name (git-find-status-file status cur-name))))\n       (when node (ewoc-goto-node status node)))))\n \n-- \n1.5.3.2.121.gf7223\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}