All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brent Goodrick <bgoodr@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Fix file mark handling and sort side-effects in git.el
Date: Tue, 10 Feb 2009 22:12:28 -0800	[thread overview]
Message-ID: <18834.27724.991388.339214@hungover.brentg.com> (raw)


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

             reply	other threads:[~2009-02-11  6:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-11  6:12 Brent Goodrick [this message]
2009-02-11 10:56 ` [PATCH] Fix file mark handling and sort side-effects in git.el 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18834.27724.991388.339214@hungover.brentg.com \
    --to=bgoodr@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.