Skip to content

Commit 2d602e9

Browse files
committed
Merge branch 'for-junio' of git://source.winehq.org/~julliard/git/git
* 'for-junio' of git://source.winehq.org/~julliard/git/git: Add a README in the contrib/emacs directory. git.el: Improve the confirmation message on remove and revert. git.el: Make sure that file lists are sorted as they are created.
2 parents 7dff9b3 + 6f3c504 commit 2d602e9

File tree

2 files changed

+61
-15
lines changed

2 files changed

+61
-15
lines changed

contrib/emacs/README

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
This directory contains various modules for Emacs support.
2+
3+
To make the modules available to Emacs, you should add this directory
4+
to your load-path, and then require the modules you want. This can be
5+
done by adding to your .emacs something like this:
6+
7+
(add-to-list 'load-path ".../git/contrib/emacs")
8+
(require 'git)
9+
(require 'git-blame)
10+
11+
12+
The following modules are available:
13+
14+
* git.el:
15+
16+
Status manager that displays the state of all the files of the
17+
project, and provides easy access to the most frequently used git
18+
commands. The user interface is as far as possible compatible with
19+
the pcl-cvs mode. It can be started with `M-x git-status'.
20+
21+
* git-blame.el:
22+
23+
Emacs implementation of incremental git-blame. When you turn it on
24+
while viewing a file, the editor buffer will be updated by setting
25+
the background of individual lines to a color that reflects which
26+
commit it comes from. And when you move around the buffer, a
27+
one-line summary will be shown in the echo area.
28+
29+
* vc-git.el:
30+
31+
This file used to contain the VC-mode backend for git, but it is no
32+
longer distributed with git. It is now maintained as part of Emacs
33+
and included in standard Emacs distributions starting from version
34+
22.2.
35+
36+
If you have an earlier Emacs version, upgrading to Emacs 22 is
37+
recommended, since the VC mode in older Emacs is not generic enough
38+
to be able to support git in a reasonable manner, and no attempt has
39+
been made to backport vc-git.el.

contrib/emacs/git.el

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
530530
(git-fileinfo->needs-refresh info) t)))
531531

532532
(defun git-status-filenames-map (status func files &rest args)
533-
"Apply FUNC to the status files names in the FILES list."
533+
"Apply FUNC to the status files names in the FILES list.
534+
The list must be sorted."
534535
(when files
535-
(setq files (sort files #'string-lessp))
536536
(let ((file (pop files))
537537
(node (ewoc-nth status 0)))
538538
(while (and file node)
@@ -545,7 +545,7 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
545545
(setq file (pop files))))))))
546546

547547
(defun git-set-filenames-state (status files state)
548-
"Set the state of a list of named files."
548+
"Set the state of a list of named files. The list must be sorted"
549549
(when files
550550
(git-status-filenames-map status #'git-set-fileinfo-state files state)
551551
(unless state ;; delete files whose state has been set to nil
@@ -750,6 +750,7 @@ Return the list of files that haven't been handled."
750750
(let (unmerged-files)
751751
(while (re-search-forward "[0-7]\\{6\\} [0-9a-f]\\{40\\} [123]\t\\([^\0]+\\)\0" nil t)
752752
(push (match-string 1) unmerged-files))
753+
(setq unmerged-files (nreverse unmerged-files)) ;; assume it is sorted already
753754
(git-set-filenames-state status unmerged-files 'unmerged))))
754755

755756
(defun git-get-exclude-files ()
@@ -770,17 +771,18 @@ Return the list of files that haven't been handled."
770771
(append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
771772

772773
(defun git-update-status-files (&optional files mark-files)
773-
"Update the status of FILES from the index."
774+
"Update the status of FILES from the index.
775+
The FILES list must be sorted."
774776
(unless git-status (error "Not in git-status buffer."))
775777
;; set the needs-update flag on existing files
776-
(if (setq files (sort files #'string-lessp))
778+
(if files
777779
(git-status-filenames-map
778780
git-status (lambda (info) (setf (git-fileinfo->needs-update info) t)) files)
779781
(ewoc-map (lambda (info) (setf (git-fileinfo->needs-update info) t) nil) git-status)
780782
(git-call-process nil "update-index" "--refresh")
781783
(when git-show-uptodate
782784
(git-run-ls-files-cached git-status nil 'uptodate)))
783-
(let* ((remaining-files
785+
(let ((remaining-files
784786
(if (git-empty-db-p) ; we need some special handling for an empty db
785787
(git-run-ls-files-cached git-status files 'added)
786788
(git-run-diff-index git-status files))))
@@ -825,13 +827,13 @@ Return the list of files that haven't been handled."
825827
(list (ewoc-data (ewoc-locate git-status)))))
826828

827829
(defun git-marked-files-state (&rest states)
828-
"Return marked files that are in the specified states."
830+
"Return a sorted list of marked files that are in the specified states."
829831
(let ((files (git-marked-files))
830832
result)
831833
(dolist (info files)
832834
(when (memq (git-fileinfo->state info) states)
833835
(push info result)))
834-
result))
836+
(nreverse result)))
835837

836838
(defun git-refresh-files ()
837839
"Refresh all files that need it and clear the needs-refresh flag."
@@ -1066,7 +1068,9 @@ Return the list of files that haven't been handled."
10661068
(unless files
10671069
(push (file-relative-name (read-file-name "File to remove: " nil nil t)) files))
10681070
(if (yes-or-no-p
1069-
(format "Remove %d file%s? " (length files) (if (> (length files) 1) "s" "")))
1071+
(if (cdr files)
1072+
(format "Remove %d files? " (length files))
1073+
(format "Remove %s? " (car files))))
10701074
(progn
10711075
(dolist (name files)
10721076
(ignore-errors
@@ -1085,7 +1089,9 @@ Return the list of files that haven't been handled."
10851089
added modified)
10861090
(when (and files
10871091
(yes-or-no-p
1088-
(format "Revert %d file%s? " (length files) (if (> (length files) 1) "s" ""))))
1092+
(if (cdr files)
1093+
(format "Revert %d files? " (length files))
1094+
(format "Revert %s? " (git-fileinfo->name (car files))))))
10891095
(dolist (info files)
10901096
(case (git-fileinfo->state info)
10911097
('added (push (git-fileinfo->name info) added))
@@ -1101,13 +1107,14 @@ Return the list of files that haven't been handled."
11011107
(or (not added)
11021108
(apply 'git-call-process-display-error "update-index" "--force-remove" "--" added))
11031109
(or (not modified)
1104-
(apply 'git-call-process-display-error "checkout" "HEAD" modified)))))
1105-
(git-update-status-files (append added modified))
1110+
(apply 'git-call-process-display-error "checkout" "HEAD" modified))))
1111+
(names (git-get-filenames files)))
1112+
(git-update-status-files names)
11061113
(when ok
11071114
(dolist (file modified)
11081115
(let ((buffer (get-file-buffer file)))
11091116
(when buffer (with-current-buffer buffer (revert-buffer t t t)))))
1110-
(git-success-message "Reverted" (git-get-filenames files)))))))
1117+
(git-success-message "Reverted" names))))))
11111118

11121119
(defun git-resolve-file ()
11131120
"Resolve conflicts in marked file(s)."
@@ -1365,14 +1372,14 @@ Return the list of files that haven't been handled."
13651372
(mapconcat #'identity msg "\n"))))
13661373

13671374
(defun git-get-commit-files (commit)
1368-
"Retrieve the list of files modified by COMMIT."
1375+
"Retrieve a sorted list of files modified by COMMIT."
13691376
(let (files)
13701377
(with-temp-buffer
13711378
(git-call-process t "diff-tree" "-m" "-r" "-z" "--name-only" "--no-commit-id" "--root" commit)
13721379
(goto-char (point-min))
13731380
(while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
13741381
(push (match-string 1) files)))
1375-
files))
1382+
(sort files #'string-lessp)))
13761383

13771384
(defun git-read-commit-name (prompt &optional default)
13781385
"Ask for a commit name, with completion for local branch, remote branch and tag."

0 commit comments

Comments
 (0)