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

[PATCH] ls-files: honour per-directory ignore file from higher directories.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 9, 2006, 08:16 UTC
Message-ID
<7vmzh1eykq.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<20060125061140.GA8408@mars.ravnborg.org>

When git-ls-files -o --exclude-per-directory=.gitignore is run from a subdirectory, it did not read from .gitignore from its parent directory. Reading from them makes output from these two commands consistent:

    $ git ls-files -o --exclude-per-directory=.gitignore Documentation
    $ cd Documentation &&
      git ls-files -o --exclude-per-directory=.gitignore
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * If there are positive feedbacks on this one, I consider it
   a safe enough candidate to be included in 1.2.0 release.
 ls-files.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
701ca744e386c2429ca44072ea987bbb4bdac7ce
diff --git a/ls-files.c b/ls-files.c
index 6af3b09..7024cf1 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -474,8 +474,28 @@ static void show_files(void)
 		const char *path = ".", *base = "";
 		int baselen = prefix_len;
 
-		if (baselen)
+		if (baselen) {
 			path = base = prefix;
+			if (exclude_per_dir) {
+				char *p, *pp = xmalloc(baselen+1);
+				memcpy(pp, prefix, baselen+1);
+				p = pp;
+				while (1) {
+					char save = *p;
+					*p = 0;
+					push_exclude_per_directory(pp, p-pp);
+					*p++ = save;
+					if (!save)
+						break;
+					p = strchr(p, '/');
+					if (p)
+						p++;
+					else
+						p = pp + baselen;
+				}
+				free(pp);
+			}
+		}
 		read_directory(path, base, baselen);
 		qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
 		if (show_others)
-- 
1.1.6.gbb042
Previous: Sam RavnborgNext: Pavel Roskin
Message 4 of 6 in “git-ls-files in subdirectories ignore higher-up .gitignore”
  1. Pavel RoskinJan 24, 2006
  2. Junio C HamanoJan 25, 2006
  3. Sam RavnborgJan 25, 2006
  4. ls-files: honour per-directory ignore file from higher directories.Junio C Hamano, Feb 9, 2006
  5. Pavel RoskinFeb 10, 2006
  6. Junio C HamanoFeb 10, 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.