git.el: Retrieve the permissions for up-to-date files.
This allows displaying correctly the executable flag for the initial commit, and will make it possible to show the file type for up-to-date symlinks and subprojects. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexandre Julliard committed
Jan 6, 2008 at 12:13 UTC
5e3cb7e5038f99d442c484d5839bd6bf02adb58c
1 file changed
+18
-2
contrib/emacs/git.el
+18
-2
@@ -642,6 +642,22 @@ Return the list of files that haven't been handled."
642
(git-insert-info-list status infolist)
643
files))
644
645
+(defun git-run-ls-files-cached (status files default-state)
646
+ "Run git-ls-files -c on FILES and parse the results into STATUS.
647
+Return the list of files that haven't been handled."
648
+ (let (infolist)
649
+ (with-temp-buffer
650
+ (apply #'git-call-process-env t nil "ls-files" "-z" "-s" "-c" "--" files)
651
+ (goto-char (point-min))
652
+ (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-3]\t\\([^\0]+\\)\0" nil t)
653
+ (let* ((new-perm (string-to-number (match-string 1) 8))
654
+ (old-perm (if (eq default-state 'added) 0 new-perm))
655
+ (name (match-string 2)))
656
+ (push (git-create-fileinfo default-state name old-perm new-perm) infolist)
657
+ (setq files (delete name files)))))
658
+ (git-insert-info-list status infolist)
659
+ files))
660
+
661
(defun git-run-ls-unmerged (status files)
662
"Run git-ls-files -u on FILES and parse the results into STATUS."
663
(with-temp-buffer
@@ -673,10 +689,10 @@ Return the list of files that haven't been handled."
689
"Update the status of FILES from the index."
690
(unless git-status (error "Not in git-status buffer."))
691
(unless files
676
- (when git-show-uptodate (git-run-ls-files git-status nil 'uptodate "-c")))
692
+ (when git-show-uptodate (git-run-ls-files-cached git-status nil 'uptodate)))
693
(let* ((remaining-files
694
(if (git-empty-db-p) ; we need some special handling for an empty db
679
- (git-run-ls-files git-status files 'added "-c")
695
+ (git-run-ls-files-cached git-status files 'added)
696
(git-run-diff-index git-status files))))
697
(git-run-ls-unmerged git-status files)
698
(when (or remaining-files (and git-show-unknown (not files)))