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

[PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored

From
MSMichael Spang <mspang@uwaterloo.ca>
Date
May 6, 2007, 18:09 UTC
Message-ID
<463E19D4.4030400@uwaterloo.ca>
In-Reply-To
<463E1705.2090201@gmail.com>

This makes "git-ls-files --others --directory --ignored" behave as documented and consequently also fixes "git-clean -d -X". Previously, git-clean would remove non-excluded directories even when using the -X option.

Signed-off-by: Michael Spang <mspang@uwaterloo.ca>
---
 dir.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/dir.c b/dir.c
index d306352..adb3e62 100644
--- a/dir.c
+++ b/dir.c
@@ -448,6 +448,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
 
 		while ((de = readdir(fdir)) != NULL) {
 			int len;
+			int exclude;
 
 			if ((de->d_name[0] == '.') &&
 			    (de->d_name[1] == 0 ||
@@ -461,7 +462,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
 			memcpy(fullname + baselen, de->d_name, len+1);
 			if (simplify_away(fullname, baselen + len, simplify))
 				continue;
-			if (excluded(dir, fullname) != dir->show_ignored) {
+			if ((exclude = excluded(dir, fullname)) != dir->show_ignored) {
 				if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
 					continue;
 				}
@@ -484,6 +485,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
 				len++;
 				switch (treat_directory(dir, fullname, baselen + len, simplify)) {
 				case show_directory:
+					if (exclude != dir->show_ignored)
+						continue;
 					break;
 				case recurse_into_directory:
 					contents += read_directory_recursive(dir,
-- 
1.5.2.rc1.4.g47e1
Next: Linus Torvalds
Message 1 of 8 in “dir.c: Omit non-excluded directories with dir->show_ignored”
  1. 2/3 dir.c: Omit non-excluded directories with dir->show_ignoredMichael Spang, May 6, 2007
  2. Linus TorvaldsMay 6, 2007
  3. Michael SpangMay 6, 2007
  4. Michael SpangMay 7, 2007
  5. 3/3 Fix minor documentation errorsMichael Spang, May 6, 2007
  6. 4/3 t7300: Tests for git-clean using filenames with spaces/punctuationMichael Spang, May 6, 2007
  7. Junio C HamanoMay 6, 2007
  8. Michael SpangMay 6, 2007

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.