git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix file mark handling and sort side-effects in git.el
@ 2009-02-11  6:12 Brent Goodrick
  2009-02-11 10:56 ` Alexandre Julliard
  0 siblings, 1 reply; 7+ messages in thread
From: Brent Goodrick @ 2009-02-11  6:12 UTC (permalink / raw)
  To: git


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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-16  0:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11  6:12 [PATCH] Fix file mark handling and sort side-effects in git.el Brent Goodrick
2009-02-11 10:56 ` Alexandre Julliard
     [not found]   ` <e38bce640902120738h7b9bb75o42e1524cbfd95169@mail.gmail.com>
2009-02-12 17:08     ` Brent Goodrick
2009-02-15 17:08       ` Alexandre Julliard
2009-02-15 18:35         ` Brent Goodrick
2009-02-15 19:15           ` Alexandre Julliard
2009-02-16  0:04             ` Brent Goodrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).