git.el: Support for showing unknown/ignored directories.
PATCH 1/4 git.el: Support for showing unknown/ignored directories.
Instead of recursing into directories that only contain unknown files, display only the directory itself. Its contents can be expanded with git-find-file (bound to C-m).
--- contrib/emacs/git.el | 38 +++++++++++++++++++++++++++++--------- 1 files changed, 29 insertions(+), 9 deletions(-)
contrib/emacs/git.el +29 -9
@@ -558,12 +558,15 @@ and returns the process output as a string." (?\100 " (type change file -> subproject)") (?\120 " (type change symlink -> subproject)") (t " (subproject)"))) + (?\110 nil) ;; directory (internal, not a real git state) (?\000 ;; deleted or unknown (case old-type (?\120 " (symlink)") (?\160 " (subproject)"))) (t (format " (unknown type %o)" new-type))))) - (if str (propertize str 'face 'git-status-face) ""))) + (cond (str (propertize str 'face 'git-status-face)) + ((eq new-type ?\110) "/") + (t "")))) (defun git-rename-as-string (info) "Return a string describing the copy or rename associated with INFO, or an empty string if none."
@@ -666,9 +669,11 @@ Return the list of files that haven't been handled." (with-temp-buffer (apply #'git-call-process-env t nil "ls-files" "-z" (append options (list "--") files)) (goto-char (point-min)) - (while (re-search-forward "\\([^\0]*\\)\0" nil t 1) + (while (re-search-forward "\\([^\0]*?\\)\\(/?\\)\0" nil t 1) (let ((name (match-string 1))) - (push (git-create-fileinfo default-state name) infolist) + (push (git-create-fileinfo default-state name 0 + (if (string-equal "/" (match-string 2)) (lsh ?\110 9) 0)) + infolist) (setq files (delete name files))))) (git-insert-info-list status infolist) files))
@@ -713,7 +718,7 @@ Return the list of files that haven't been handled." (defun git-run-ls-files-with-excludes (status files default-state &rest options) "Run git-ls-files on FILES with appropriate --exclude-from options." (let ((exclude-files (git-get-exclude-files))) - (apply #'git-run-ls-files status files default-state + (apply #'git-run-ls-files status files default-state "--directory" (concat "--exclude-per-directory=" git-per-dir-ignore-file) (append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
@@ -957,6 +962,7 @@ Return the list of files that haven't been handled." "Add marked file(s) to the index cache." (interactive) (let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored)))) + ;; FIXME: add support for directories (unless files (push (file-relative-name (read-file-name "File to add: " nil nil t)) files)) (apply #'git-call-process-env nil nil "update-index" "--add" "--" files)
@@ -983,7 +989,10 @@ Return the list of files that haven't been handled." (format "Remove %d file%s? " (length files) (if (> (length files) 1) "s" ""))) (progn (dolist (name files) - (when (file-exists-p name) (delete-file name))) + (ignore-errors + (if (file-directory-p name) + (delete-directory name) + (delete-file name)))) (apply #'git-call-process-env nil nil "update-index" "--remove" "--" files) (git-update-status-files files nil) (git-success-message "Removed" files))
@@ -992,7 +1001,7 @@ Return the list of files that haven't been handled." (defun git-revert-file () "Revert changes to the marked file(s)." (interactive) - (let ((files (git-marked-files)) + (let ((files (git-marked-files-state 'added 'deleted 'modified 'unmerged)) added modified) (when (and files (yes-or-no-p
@@ -1063,6 +1072,16 @@ Return the list of files that haven't been handled." (message "Inserting unknown files...done")) (git-remove-handled))) +(defun git-expand-directory (info) + "Expand the directory represented by INFO to list its files." + (when (eq (lsh (git-fileinfo->new-perm info) -9) ?\110) + (let ((dir (git-fileinfo->name info))) + (git-set-filenames-state git-status (list dir) nil) + (git-run-ls-files-with-excludes git-status (list (concat dir "/")) 'unknown "-o") + (git-refresh-files) + (git-refresh-ewoc-hf git-status) + t))) + (defun git-setup-diff-buffer (buffer) "Setup a buffer for displaying a diff." (let ((dir default-directory))
@@ -1237,9 +1256,10 @@ Return the list of files that haven't been handled." (interactive) (unless git-status (error "Not in git-status buffer.")) (let ((info (ewoc-data (ewoc-locate git-status)))) - (find-file (git-fileinfo->name info)) - (when (eq 'unmerged (git-fileinfo->state info)) - (smerge-mode 1)))) + (unless (git-expand-directory info) + (find-file (git-fileinfo->name info)) + (when (eq 'unmerged (git-fileinfo->state info)) + (smerge-mode 1))))) (defun git-find-file-other-window () "Visit the current file in its own buffer in another window."
Signature · 5 lines
1.5.4.38.g0d380 -- Alexandre Julliard [email protected]
Quoted 3 lines · Alexandre Julliard
Instead of recursing into directories that only contain unknown files, display only the directory itself. Its contents can be expanded with git-find-file (bound to C-m).
I have a bunch of directories in my tree with only ignored files in them. They used to not show up at all, but now they do. If I press return with the cursor on top of one of them, it vanishes (which is equivalent to expanding to all the 0 non-ignored files in that directory, I guess).
I presume this wasn't the intended behavior? I like the idea for subdirectories that actually contain non-ignored files, but directories with only ignored files should really not be shown at all.
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 12 lines · Karl Hasselström
Quoted 3 lines · Alexandre Julliard
Instead of recursing into directories that only contain unknown files, display only the directory itself. Its contents can be expanded with git-find-file (bound to C-m).
I have a bunch of directories in my tree with only ignored files in them. They used to not show up at all, but now they do. If I press return with the cursor on top of one of them, it vanishes (which is equivalent to expanding to all the 0 non-ignored files in that directory, I guess).
Quoted 3 lines
I presume this wasn't the intended behavior? I like the idea for subdirectories that actually contain non-ignored files, but directories with only ignored files should really not be shown at all.
It probably needs something like this:
From b32a397a64eec64d433aa0ee00147003723cfeee Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <[email protected]>
Date: Fri, 22 Feb 2008 16:48:53 +0100
Subject: [PATCH] git.el: Do not display empty directories.
--- contrib/emacs/git.el | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
contrib/emacs/git.el +1 -1
@@ -753,7 +753,7 @@ Return the list of files that haven't been handled." (defun git-run-ls-files-with-excludes (status files default-state &rest options) "Run git-ls-files on FILES with appropriate --exclude-from options." (let ((exclude-files (git-get-exclude-files))) - (apply #'git-run-ls-files status files default-state "--directory" + (apply #'git-run-ls-files status files default-state "--directory" "--no-empty-directory" (concat "--exclude-per-directory=" git-per-dir-ignore-file) (append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
Signature · 5 lines
1.5.4.1.132.gd85f75 -- Alexandre Julliard [email protected]
Karl Hasselström
Tested-byQuoted 6 lines · Alexandre Julliard
Quoted 2 lines · Karl Hasselström
I have a bunch of directories in my tree with only ignored files in them. They used to not show up at all, but now they do.
It probably needs something like this:
That fixed the problem. Thanks!
Quoted 1 line
Signed-off-by Alexandre Julliard <[email protected]>
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 7 lines · Karl Hasselström
Quoted 5 lines · Alexandre Julliard
Quoted 2 lines · Karl Hasselström
I have a bunch of directories in my tree with only ignored files in them. They used to not show up at all, but now they do.
Quoted 7 lines
Quoted 1 line
It probably needs something like this:
That fixed the problem. Thanks!
Quoted 1 line
Signed-off-by Alexandre Julliard <[email protected]>Tested-by Karl Hasselström <[email protected]>
Junio, did you see this bugfix? (I just realized you weren't cc'ed, so I guess not.)
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 10 lines · Karl Hasselström
On 2008-02-22 18:10:52 +0100, Karl Hasselström wrote:
...Quoted 5 lines
That fixed the problem. Thanks!
Quoted 1 line
Signed-off-by Alexandre Julliard <[email protected]>Tested-by Karl Hasselström <[email protected]>Junio, did you see this bugfix? (I just realized you weren't cc'ed, so I guess not.)
No, and thanks.
So I'll take
From: Alexandre Julliard <[email protected]>
Message-ID: <[email protected]>
aka
http://article.gmane.org/gmane.comp.version-control.git/74730
in this thread with your Tested-by: and apply to fix 3f3d564 (git.el: Support for showing unknown/ignored directories.)?
Quoted 12 lines · Junio C Hamano
Quoted 2 lines · Karl Hasselström
Junio, did you see this bugfix? (I just realized you weren't cc'ed, so I guess not.)
No, and thanks.
So I'll take
From: Alexandre Julliard <[email protected]>
Message-ID: <[email protected]>
Quoted 6 lines
aka
http://article.gmane.org/gmane.comp.version-control.git/74730in this thread with your Tested-by: and apply to fix 3f3d564 (git.el: Support for showing unknown/ignored directories.)?
Yes, exactly. Thanks.
(Would you like this kind of detailed pointer in a reminder, or is the threading support in your mailer good enough that just replying to the right mail will do it?)
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 3 lines · Karl Hasselström
(Would you like this kind of detailed pointer in a reminder, or is the threading support in your mailer good enough that just replying to the right mail will do it?)
I'd actually like a forwarded message that I can directly feed to "git am", with Sign-offs and Acked-bys, but being explicit would be good enough.
I often do not have enough mental and time bandwidth to hunt for messages more than 2 weeks old in the list archive, so unless the response is direct reply to the original, I'd rather not rely on the threading feature. IOW, I can move to grandparent by typing ^ just fine, but uncles and aunts are harder to find without reloading my MUA full message archive for N weeks worth.