[PATCH 2/2] Workaround git < 1.2.0 ignoring .gitignore in parent directories
- From
- Pavel 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