[PATCH] Fix file mark handling and sort side-effects in git.el

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The `sort' Elisp function works destructively, causing anomalies where
operations on multiple files would be performed on one file.  This
checkin works around that by doing a deep copy with `append'.

Also, git-add-file needed to pass 'modified to git-marked-files-state,
as otherwise, files that are modified but not yet in the index would
not show up in the git-marked-files-state return value, which would
then cause a prompt for file to show up when the files are clearly
marked in the status buffer.

Signed-off-by: Brent Goodrick <bgoodr@xxxxxxxxx>
---
 contrib/emacs/git.el |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index fcbe2d9..93e47c1 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -532,7 +532,7 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
 (defun git-status-filenames-map (status func files &rest args)
   "Apply FUNC to the status files names in the FILES list."
   (when files
-    (setq files (sort files #'string-lessp))
+    (setq files (sort (append files nil) #'string-lessp))
     (let ((file (pop files))
           (node (ewoc-nth status 0)))
       (while (and file node)
@@ -773,7 +773,7 @@ Return the list of files that haven't been handled."
   "Update the status of FILES from the index."
   (unless git-status (error "Not in git-status buffer."))
   ;; set the needs-update flag on existing files
-  (if (setq files (sort files #'string-lessp))
+  (if (setq files (sort (append files nil) #'string-lessp))
       (git-status-filenames-map
        git-status (lambda (info) (setf (git-fileinfo->needs-update info) t)) files)
     (ewoc-map (lambda (info) (setf (git-fileinfo->needs-update info) t) nil) git-status)
@@ -1041,7 +1041,7 @@ Return the list of files that haven't been handled."
 (defun git-add-file ()
   "Add marked file(s) to the index cache."
   (interactive)
-  (let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored))))
+  (let ((files (git-get-filenames (git-marked-files-state 'modified 'unknown 'ignored))))
     ;; FIXME: add support for directories
     (unless files
       (push (file-relative-name (read-file-name "File to add: " nil nil t)) files))
-- 
1.6.2.rc0.10.gf6b9.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux