Files
tar/tests/exclude23.at
T
Sergey Poznyakoff f022ac4ee0 Fix handling of negated and rooted entries in .gitignore files.
* src/exclist.c (struct vcs_ignore_file): New field: matchfn.
(struct exclist): New field: vcs.
(info_attach_exclist): Initialize vcs.
(excluded_name): Rewrite using excluded_file_name_status from gnulib.
(git_addfn): Special handling for entries starting with '!' and '/'.
(vcs_ignore_files): Initialize matchfn member in the ".gitignore"
entry.

* tests/exclude23.at: New test.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Include new test.
2026-08-18 21:51:55 +03:00

56 lines
1.5 KiB
Plaintext

# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2026 Free Software Foundation, Inc.
# This file is part of GNU tar.
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([gitignore excludes])
AT_KEYWORDS([exclude gitignore extract exclude23])
AT_TAR_CHECK([
AT_SORT_PREREQ
# Test whether negations (!) and rooted patterns (/) work in
# .gitignore files.
mkdir dir dir/subdir
touch dir/subdir/some.1 dir/subdir/any.1 dir/subdir/bar dir/subdir/FILE
cat > dir/subdir/.gitignore <<EOT
!any.1
EOT
touch dir/foo.1 dir/file.1 dir/file.2 dir/file.3 dir/file.4 dir/FILE
cat > dir/.gitignore <<EOT
*.1
*.2
!foo.1
*.3
/FILE
/subdir/b?r
EOT
set -e
tar --exclude-ignore-recursive=.gitignore -cf dir.tar dir
tar tf dir.tar | sort
],
[0],
[dir/
dir/.gitignore
dir/file.4
dir/foo.1
dir/subdir/
dir/subdir/.gitignore
dir/subdir/FILE
dir/subdir/any.1
])
AT_CLEANUP