git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git ls files recursively show ignored files

From
Shawn Pearce <spearce@spearce.org>
Date
Feb 24, 2006, 22:02 UTC
Message-ID
<20060224220234.GB29982@spearce.org>

Make git-ls-files --others --ignored recurse into non-excluded subdirectories.

Typically when asking git-ls-files to display all files which are ignored by one or more exclude patterns one would want it to recurse into subdirectories which are not themselves excluded to see if there are any excluded files contained within those subdirectories.

---
 I found this issue while trying to find temporary garbage that was
 created within a tracked subdirectory:
   touch a/b/foo#1
   git-ls-files --others --ignored --exclude='*#1'
 would never display a/b/foo#1 as the directory 'a' was not itself
 excluded.  It would be rather nice if git-ls-files actually
 showed it.
 ls-files.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

base 98214e96be00c5132047ae80bca20d4690933c33 last 809da5f8a21a10112eece4ee9be55fe64371ce68

diff --git a/ls-files.c b/ls-files.c
index 90b289f03d987c6c90214fc12d00c30b4e28bb27..df25c8c012a96a8277413ca3a81490b81b7dc067 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -279,8 +279,11 @@ static void read_directory(const char *p
 				continue;
 			len = strlen(de->d_name);
 			memcpy(fullname + baselen, de->d_name, len+1);
-			if (excluded(fullname) != show_ignored)
-				continue;
+			if (excluded(fullname) != show_ignored) {
+				if (!show_ignored || DTYPE(de) != DT_DIR) {
+					continue;
+				}
+			}
 
 			switch (DTYPE(de)) {
 			struct stat st;
-- 
1.2.3.g809d
Message 1 of 1 in “git ls files recursively show ignored files”
  1. git ls files recursively show ignored filesShawn Pearce, Feb 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.