X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Femacs%2Fgit.el;h=0312d891fd1ddfe87f452611c24af7178313092e;hb=a1eebfb3a90b6c240afd1a32cfebe6ee5dbd72c5;hp=c82601758050342c9369b728f931774dffea058c;hpb=87e3d812943f3d9c5f9464b0aee83398dd9d028e;p=git.git diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index c82601758..0312d891f 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -538,10 +538,10 @@ and returns the process output as a string." ('ignored (propertize "Ignored " 'face 'git-ignored-face)) (t "? "))) -(defun git-file-type-as-string (info) - "Return a string describing the file type of INFO." - (let* ((old-type (lsh (or (git-fileinfo->old-perm info) 0) -9)) - (new-type (lsh (or (git-fileinfo->new-perm info) 0) -9)) +(defun git-file-type-as-string (old-perm new-perm) + "Return a string describing the file type based on its permissions." + (let* ((old-type (lsh (or old-perm 0) -9)) + (new-type (lsh (or new-perm 0) -9)) (str (case new-type (?\100 ;; file (case old-type @@ -590,12 +590,14 @@ and returns the process output as a string." (defun git-fileinfo-prettyprint (info) "Pretty-printer for the git-fileinfo structure." - (insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ") - " " (git-status-code-as-string (git-fileinfo->state info)) - " " (git-permissions-as-string (git-fileinfo->old-perm info) (git-fileinfo->new-perm info)) - " " (git-escape-file-name (git-fileinfo->name info)) - (git-file-type-as-string info) - (git-rename-as-string info)))) + (let ((old-perm (git-fileinfo->old-perm info)) + (new-perm (git-fileinfo->new-perm info))) + (insert (concat " " (if (git-fileinfo->marked info) (propertize "*" 'face 'git-mark-face) " ") + " " (git-status-code-as-string (git-fileinfo->state info)) + " " (git-permissions-as-string old-perm new-perm) + " " (git-escape-file-name (git-fileinfo->name info)) + (git-file-type-as-string old-perm new-perm) + (git-rename-as-string info))))) (defun git-insert-info-list (status infolist) "Insert a list of file infos in the status buffer, replacing existing ones if any." @@ -606,7 +608,6 @@ and returns the process output as a string." (let ((info (pop infolist)) (node (ewoc-nth status 0))) (while info - (setf (git-fileinfo->needs-refresh info) t) (cond ((not node) (setq node (ewoc-enter-last status info)) (setq info (pop infolist))) @@ -617,6 +618,7 @@ and returns the process output as a string." (git-fileinfo->name info)) ;; preserve the marked flag (setf (git-fileinfo->marked info) (git-fileinfo->marked (ewoc-data node))) + (setf (git-fileinfo->needs-refresh info) t) (setf (ewoc-data node) info) (setq info (pop infolist))) (t @@ -626,7 +628,8 @@ and returns the process output as a string." (defun git-run-diff-index (status files) "Run git-diff-index on FILES and parse the results into STATUS. Return the list of files that haven't been handled." - (let (infolist) + (let ((remaining (copy-sequence files)) + infolist) (with-temp-buffer (apply #'git-call-process-env t nil "diff-index" "-z" "-M" "HEAD" "--" files) (goto-char (point-min)) @@ -644,10 +647,10 @@ Return the list of files that haven't been handled." (push (git-create-fileinfo 'deleted name 0 0 'rename new-name) infolist) (push (git-create-fileinfo 'added new-name old-perm new-perm 'rename name) infolist)) (push (git-create-fileinfo (git-state-code state) name old-perm new-perm) infolist)) - (setq files (delete name files)) - (when new-name (setq files (delete new-name files)))))) + (setq remaining (delete name remaining)) + (when new-name (setq remaining (delete new-name remaining)))))) (git-insert-info-list status infolist) - files)) + remaining)) (defun git-find-status-file (status file) "Find a given file in the status ewoc and return its node." @@ -673,7 +676,8 @@ Return the list of files that haven't been handled." (defun git-run-ls-files-cached (status files default-state) "Run git-ls-files -c on FILES and parse the results into STATUS. Return the list of files that haven't been handled." - (let (infolist) + (let ((remaining (copy-sequence files)) + infolist) (with-temp-buffer (apply #'git-call-process-env t nil "ls-files" "-z" "-s" "-c" "--" files) (goto-char (point-min)) @@ -682,9 +686,9 @@ Return the list of files that haven't been handled." (old-perm (if (eq default-state 'added) 0 new-perm)) (name (match-string 2))) (push (git-create-fileinfo default-state name old-perm new-perm) infolist) - (setq files (delete name files))))) + (setq remaining (delete name remaining))))) (git-insert-info-list status infolist) - files)) + remaining)) (defun git-run-ls-unmerged (status files) "Run git-ls-files -u on FILES and parse the results into STATUS." @@ -716,8 +720,8 @@ Return the list of files that haven't been handled." (defun git-update-status-files (files &optional default-state) "Update the status of FILES from the index." (unless git-status (error "Not in git-status buffer.")) - (unless files - (when git-show-uptodate (git-run-ls-files-cached git-status nil 'uptodate))) + (when (or git-show-uptodate files) + (git-run-ls-files-cached git-status files 'uptodate)) (let* ((remaining-files (if (git-empty-db-p) ; we need some special handling for an empty db (git-run-ls-files-cached git-status files 'added) @@ -839,7 +843,7 @@ Return the list of files that haven't been handled." (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil)) (condition-case nil (delete-file ".git/MERGE_MSG") (error nil)) (with-current-buffer buffer (erase-buffer)) - (dolist (info files) (git-set-fileinfo-state info 'uptodate)) + (git-update-status-files (git-get-filenames files) 'uptodate) (git-call-process-env nil nil "rerere") (git-call-process-env nil nil "gc" "--auto") (git-refresh-files) @@ -1428,7 +1432,7 @@ Commands: (with-current-buffer buffer (when (and list-buffers-directory (string-equal fulldir (expand-file-name list-buffers-directory)) - (string-match "\\*git-status\\*$" (buffer-name buffer))) + (eq major-mode 'git-status-mode)) (setq found buffer)))) (setq list (cdr list))) found))