@@ -530,9 +530,9 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
530
530
(git-fileinfo->needs-refresh info) t )))
531
531
532
532
(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."
534
535
(when files
535
- (setq files (sort files #'string-lessp ))
536
536
(let ((file (pop files ))
537
537
(node (ewoc-nth status 0 )))
538
538
(while (and file node)
@@ -545,7 +545,7 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
545
545
(setq file (pop files ))))))))
546
546
547
547
(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 "
549
549
(when files
550
550
(git-status-filenames-map status #'git-set-fileinfo-state files state)
551
551
(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."
750
750
(let (unmerged-files)
751
751
(while (re-search-forward " [0-7]\\ {6\\ } [0-9a-f]\\ {40\\ } [123]\t \\ ([^\0 ]+\\ )\0 " nil t )
752
752
(push (match-string 1 ) unmerged-files))
753
+ (setq unmerged-files (nreverse unmerged-files)) ; ; assume it is sorted already
753
754
(git-set-filenames-state status unmerged-files 'unmerged ))))
754
755
755
756
(defun git-get-exclude-files ()
@@ -770,17 +771,18 @@ Return the list of files that haven't been handled."
770
771
(append options (mapcar (lambda (f ) (concat " --exclude-from=" f)) exclude-files)))))
771
772
772
773
(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."
774
776
(unless git-status (error " Not in git-status buffer. " ))
775
777
; ; set the needs-update flag on existing files
776
- (if ( setq files ( sort files # 'string-lessp ))
778
+ (if files
777
779
(git-status-filenames-map
778
780
git-status (lambda (info ) (setf (git-fileinfo->needs-update info) t )) files )
779
781
(ewoc-map (lambda (info ) (setf (git-fileinfo->needs-update info) t ) nil ) git-status)
780
782
(git-call-process nil " update-index" " --refresh" )
781
783
(when git-show-uptodate
782
784
(git-run-ls-files-cached git-status nil 'uptodate )))
783
- (let* ((remaining-files
785
+ (let ((remaining-files
784
786
(if (git-empty-db-p) ; we need some special handling for an empty db
785
787
(git-run-ls-files-cached git-status files 'added )
786
788
(git-run-diff-index git-status files ))))
@@ -825,13 +827,13 @@ Return the list of files that haven't been handled."
825
827
(list (ewoc-data (ewoc-locate git-status)))))
826
828
827
829
(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."
829
831
(let ((files (git-marked-files))
830
832
result)
831
833
(dolist (info files )
832
834
(when (memq (git-fileinfo->state info) states)
833
835
(push info result)))
834
- result))
836
+ ( nreverse result) ))
835
837
836
838
(defun git-refresh-files ()
837
839
" 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."
1066
1068
(unless files
1067
1069
(push (file-relative-name (read-file-name " File to remove: " nil nil t )) files ))
1068
1070
(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 ))))
1070
1074
(progn
1071
1075
(dolist (name files )
1072
1076
(ignore-errors
@@ -1085,7 +1089,9 @@ Return the list of files that haven't been handled."
1085
1089
added modified)
1086
1090
(when (and files
1087
1091
(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 ))))))
1089
1095
(dolist (info files )
1090
1096
(case (git-fileinfo->state info)
1091
1097
('added (push (git-fileinfo->name info) added))
@@ -1101,13 +1107,14 @@ Return the list of files that haven't been handled."
1101
1107
(or (not added)
1102
1108
(apply 'git-call-process-display-error " update-index" " --force-remove" " --" added))
1103
1109
(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)
1106
1113
(when ok
1107
1114
(dolist (file modified)
1108
1115
(let ((buffer (get-file-buffer file)))
1109
1116
(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 ))))))
1111
1118
1112
1119
(defun git-resolve-file ()
1113
1120
" Resolve conflicts in marked file(s)."
@@ -1365,14 +1372,14 @@ Return the list of files that haven't been handled."
1365
1372
(mapconcat #'identity msg " \n " ))))
1366
1373
1367
1374
(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."
1369
1376
(let (files )
1370
1377
(with-temp-buffer
1371
1378
(git-call-process t " diff-tree" " -m" " -r" " -z" " --name-only" " --no-commit-id" " --root" commit)
1372
1379
(goto-char (point-min ))
1373
1380
(while (re-search-forward " \\ ([^\0 ]*\\ )\0 " nil t 1 )
1374
1381
(push (match-string 1 ) files )))
1375
- files ))
1382
+ ( sort files # 'string-lessp ) ))
1376
1383
1377
1384
(defun git-read-commit-name (prompt &optional default )
1378
1385
" Ask for a commit name, with completion for local branch, remote branch and tag."
0 commit comments