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

[PATCH 2/2] Workaround git < 1.2.0 ignoring .gitignore in parent directories

From
PRPavel Roskin <proski@gnu.org>
Date
Feb 14, 2006, 18:05 UTC
Message-ID
<20060214180522.13766.22633.stgit@dv.roinet.com>
In-Reply-To
<20060214180520.13766.78172.stgit@dv.roinet.com>

Add --exclude-from for all existing .gitignore files in parent directories up to the repository root. This is not needed for git 1.2.0 and newer.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 cg-Xlib |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/cg-Xlib b/cg-Xlib
index 85a21c2..af278b6 100644
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -230,6 +230,22 @@ list_untracked_files()
 			EXCLUDE[${#EXCLUDE[@]}]="--exclude-from=$EXCLUDEFILE"
 		fi
 		EXCLUDE[${#EXCLUDE[@]}]="--exclude-per-directory=.gitignore"
+		# Workaround for git < 1.2.0
+		if [ -n "$_git_relpath" ]; then
+			local dir="${_git_relpath%/}"
+			local reldir=".."
+			while [ "$dir" != "." ]; do
+				if [ "${dir%/*}" = "$dir" ]; then
+					dir="."
+				else
+					dir="${dir%/*}"
+				fi
+				if [ -f "$reldir/.gitignore" ]; then
+					EXCLUDE[${#EXCLUDE[@]}]="--exclude-from=$dir/.gitignore"
+				fi
+				reldir="../$reldir"
+			done
+		fi
 	fi
 	local listdirs=
 	[ "$squashflag" = "squashdirs" ] && listdirs=--directory
Previous: Pavel Roskin
Message 2 of 2 in “cg-clean shouldn't clean untracked directories without -d”
  1. 1/2 cg-clean shouldn't clean untracked directories without -dPavel Roskin, Feb 14, 2006
  2. 2/2 Workaround git < 1.2.0 ignoring .gitignore in parent directoriesPavel Roskin, Feb 14, 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.