@matheusbsbs / matheus-bagliano / commits / 9f5599b982
Fork 0

git.el: Do not print a status message on every git command.

Instead print a single message around sequences of commands that can potentially take some time. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alexandre Julliard committed Sep 29, 2007 at 11:58 UTC 9f5599b9829615379353f676369018c47296e1a1
1 file changed +41 -29
contrib/emacs/git.el
+41 -29
@@ -220,22 +220,15 @@ and returns the process output as a string."
220 (message "Running git %s...done" (car args))
221 buffer))
222
223 -(defun git-run-command (buffer env &rest args)
224 - (message "Running git %s..." (car args))
225 - (apply #'git-call-process-env buffer env args)
226 - (message "Running git %s...done" (car args)))
227 -
223 (defun git-run-command-region (buffer start end env &rest args)
224 "Run a git command with specified buffer region as input."
230 - (message "Running git %s..." (car args))
225 (unless (eq 0 (if env
226 (git-run-process-region
227 buffer start end "env"
228 (append (git-get-env-strings env) (list "git") args))
229 (git-run-process-region
230 buffer start end "git" args)))
237 - (error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string)))
238 - (message "Running git %s...done" (car args)))
231 + (error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
232
233 (defun git-run-hook (hook env &rest args)
234 "Run a git hook and display its output if any."
@@ -312,6 +305,13 @@ and returns the process output as a string."
305 "\"")
306 name))
307
308 +(defun git-success-message (text files)
309 + "Print a success message after having handled FILES."
310 + (let ((n (length files)))
311 + (if (equal n 1)
312 + (message "%s %s" text (car files))
313 + (message "%s %d files" text n))))
314 +
315 (defun git-get-top-dir (dir)
316 "Retrieve the top-level directory of a git tree."
317 (let ((cdup (with-output-to-string
@@ -338,7 +338,7 @@ and returns the process output as a string."
338 (sort-lines nil (point-min) (point-max))
339 (save-buffer))
340 (when created
341 - (git-run-command nil nil "update-index" "--add" "--" (file-relative-name ignore-name)))
341 + (git-call-process-env nil nil "update-index" "--add" "--" (file-relative-name ignore-name)))
342 (git-update-status-files (list (file-relative-name ignore-name)) 'unknown)))
343
344 ; propertize definition for XEmacs, stolen from erc-compat
@@ -606,7 +606,7 @@ and returns the process output as a string."
606 Return the list of files that haven't been handled."
607 (let (infolist)
608 (with-temp-buffer
609 - (apply #'git-run-command t nil "diff-index" "-z" "-M" "HEAD" "--" files)
609 + (apply #'git-call-process-env t nil "diff-index" "-z" "-M" "HEAD" "--" files)
610 (goto-char (point-min))
611 (while (re-search-forward
612 ":\\([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"
@@ -639,7 +639,7 @@ Return the list of files that haven't been handled."
639 Return the list of files that haven't been handled."
640 (let (infolist)
641 (with-temp-buffer
642 - (apply #'git-run-command t nil "ls-files" "-z" (append options (list "--") files))
642 + (apply #'git-call-process-env t nil "ls-files" "-z" (append options (list "--") files))
643 (goto-char (point-min))
644 (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
645 (let ((name (match-string 1)))
@@ -651,7 +651,7 @@ Return the list of files that haven't been handled."
651 (defun git-run-ls-unmerged (status files)
652 "Run git-ls-files -u on FILES and parse the results into STATUS."
653 (with-temp-buffer
654 - (apply #'git-run-command t nil "ls-files" "-z" "-u" "--" files)
654 + (apply #'git-call-process-env t nil "ls-files" "-z" "-u" "--" files)
655 (goto-char (point-min))
656 (let (unmerged-files)
657 (while (re-search-forward "[0-7]\\{6\\} [0-9a-f]\\{40\\} [123]\t\\([^\0]+\\)\0" nil t)
@@ -754,11 +754,11 @@ Return the list of files that haven't been handled."
754 ('deleted (push info deleted))
755 ('modified (push info modified))))
756 (when added
757 - (apply #'git-run-command nil env "update-index" "--add" "--" (git-get-filenames added)))
757 + (apply #'git-call-process-env nil env "update-index" "--add" "--" (git-get-filenames added)))
758 (when deleted
759 - (apply #'git-run-command nil env "update-index" "--remove" "--" (git-get-filenames deleted)))
759 + (apply #'git-call-process-env nil env "update-index" "--remove" "--" (git-get-filenames deleted)))
760 (when modified
761 - (apply #'git-run-command nil env "update-index" "--" (git-get-filenames modified)))))
761 + (apply #'git-call-process-env nil env "update-index" "--" (git-get-filenames modified)))))
762
763 (defun git-run-pre-commit-hook ()
764 "Run the pre-commit hook if any."
@@ -790,6 +790,7 @@ Return the list of files that haven't been handled."
790 head-tree (git-rev-parse "HEAD^{tree}")))
791 (if files
792 (progn
793 + (message "Running git commit...")
794 (git-read-tree head-tree index-file)
795 (git-update-index nil files) ;update both the default index
796 (git-update-index index-file files) ;and the temporary one
@@ -801,7 +802,7 @@ Return the list of files that haven't been handled."
802 (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
803 (with-current-buffer buffer (erase-buffer))
804 (git-set-files-state files 'uptodate)
804 - (git-run-command nil nil "rerere")
805 + (git-call-process-env nil nil "rerere")
806 (git-refresh-files)
807 (git-refresh-ewoc-hf git-status)
808 (message "Committed %s." commit)
@@ -912,8 +913,9 @@ Return the list of files that haven't been handled."
913 (let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored))))
914 (unless files
915 (push (file-relative-name (read-file-name "File to add: " nil nil t)) files))
915 - (apply #'git-run-command nil nil "update-index" "--add" "--" files)
916 - (git-update-status-files files 'uptodate)))
916 + (apply #'git-call-process-env nil nil "update-index" "--add" "--" files)
917 + (git-update-status-files files 'uptodate)
918 + (git-success-message "Added" files)))
919
920 (defun git-ignore-file ()
921 "Add marked file(s) to the ignore list."
@@ -922,7 +924,8 @@ Return the list of files that haven't been handled."
924 (unless files
925 (push (file-relative-name (read-file-name "File to ignore: " nil nil t)) files))
926 (dolist (f files) (git-append-to-ignore f))
925 - (git-update-status-files files 'ignored)))
927 + (git-update-status-files files 'ignored)
928 + (git-success-message "Ignored" files)))
929
930 (defun git-remove-file ()
931 "Remove the marked file(s)."
@@ -935,8 +938,9 @@ Return the list of files that haven't been handled."
938 (progn
939 (dolist (name files)
940 (when (file-exists-p name) (delete-file name)))
938 - (apply #'git-run-command nil nil "update-index" "--remove" "--" files)
939 - (git-update-status-files files nil))
941 + (apply #'git-call-process-env nil nil "update-index" "--remove" "--" files)
942 + (git-update-status-files files nil)
943 + (git-success-message "Removed" files))
944 (message "Aborting"))))
945
946 (defun git-revert-file ()
@@ -954,18 +958,20 @@ Return the list of files that haven't been handled."
958 ('unmerged (push (git-fileinfo->name info) modified))
959 ('modified (push (git-fileinfo->name info) modified))))
960 (when added
957 - (apply #'git-run-command nil nil "update-index" "--force-remove" "--" added))
961 + (apply #'git-call-process-env nil nil "update-index" "--force-remove" "--" added))
962 (when modified
959 - (apply #'git-run-command nil nil "checkout" "HEAD" modified))
960 - (git-update-status-files (append added modified) 'uptodate))))
963 + (apply #'git-call-process-env nil nil "checkout" "HEAD" modified))
964 + (git-update-status-files (append added modified) 'uptodate)
965 + (git-success-message "Reverted" files))))
966
967 (defun git-resolve-file ()
968 "Resolve conflicts in marked file(s)."
969 (interactive)
970 (let ((files (git-get-filenames (git-marked-files-state 'unmerged))))
971 (when files
967 - (apply #'git-run-command nil nil "update-index" "--" files)
968 - (git-update-status-files files 'uptodate))))
972 + (apply #'git-call-process-env nil nil "update-index" "--" files)
973 + (git-update-status-files files 'uptodate)
974 + (git-success-message "Resolved" files))))
975
976 (defun git-remove-handled ()
977 "Remove handled files from the status list."
@@ -992,9 +998,11 @@ Return the list of files that haven't been handled."
998 (interactive)
999 (if (setq git-show-ignored (not git-show-ignored))
1000 (progn
1001 + (message "Inserting ignored files...")
1002 (git-run-ls-files-with-excludes git-status nil 'ignored "-o" "-i")
1003 (git-refresh-files)
997 - (git-refresh-ewoc-hf git-status))
1004 + (git-refresh-ewoc-hf git-status)
1005 + (message "Inserting ignored files...done"))
1006 (git-remove-handled)))
1007
1008 (defun git-toggle-show-unknown ()
@@ -1002,9 +1010,11 @@ Return the list of files that haven't been handled."
1010 (interactive)
1011 (if (setq git-show-unknown (not git-show-unknown))
1012 (progn
1013 + (message "Inserting unknown files...")
1014 (git-run-ls-files-with-excludes git-status nil 'unknown "-o")
1015 (git-refresh-files)
1007 - (git-refresh-ewoc-hf git-status))
1016 + (git-refresh-ewoc-hf git-status)
1017 + (message "Inserting unknown files...done"))
1018 (git-remove-handled)))
1019
1020 (defun git-setup-diff-buffer (buffer)
@@ -1207,7 +1217,8 @@ Return the list of files that haven't been handled."
1217 (marked-files (git-get-filenames (ewoc-collect status (lambda (info) (git-fileinfo->marked info)))))
1218 (cur-name (and pos (git-fileinfo->name (ewoc-data pos)))))
1219 (unless status (error "Not in git-status buffer."))
1210 - (git-run-command nil nil "update-index" "--refresh")
1220 + (message "Refreshing git status...")
1221 + (git-call-process-env nil nil "update-index" "--refresh")
1222 (git-clear-status status)
1223 (git-update-status-files nil)
1224 ; restore file marks
@@ -1219,6 +1230,7 @@ Return the list of files that haven't been handled."
1230 marked-files)
1231 (git-refresh-files))
1232 ; move point to the current file name if any
1233 + (message "Refreshing git status...done")
1234 (let ((node (and cur-name (git-find-status-file status cur-name))))
1235 (when node (ewoc-goto-node status node)))))
1236