Excluded toplevel directories are still listed in snapshot

Hi!

Thanks for a great tool!

I came across a small inconsistency and wanted to ask whether it was intented or not:
If one specifies a wildcard inclusion in an include file, and some of the top-level includes are excluded afterwards, these are still listed in the snapshot, even though they have no content.

It is probable easier to understand/explain with an example.
Consider therefore the following directory/file structure:

repo/
src/dir1/dir1_file1.txt
src/dir2/dir2_file2.txt

and an include file include_file_wild.txt:

src/*

and an exclude file exclude_file.txt:

src/dir1

Then calling restic as follows:
EDIT: using restic version: restic 0.17.3 compiled with go1.23.3 on linux/amd64

restic -r ./repo --insecure-no-password init
restic -r ./repo --insecure-no-password backup --files-from include_file_wild.txt --exclude-file exclude_file.txt
restic -r ./repo --insecure-no-password snapshots

will result in an output (removed absolute paths and host info):

repository c4f48141 opened (version 2, compression level auto)
ID        Time                 Host              Tags        Paths                            Size
-----------------------------------------------------------------------------------------------------
617c28e6  2025-04-06 15:37:03  somehost                      /home/someuser/src/dir1          11 B
                                                             /home/someuser/src/dir2
-----------------------------------------------------------------------------------------------------

So on the first sight, it seems like dir1 is included.
However, listing the snapshot shows that the content (and the toplevel dir1) is excluded as desired:

repository c4f48141 opened (version 2, compression level auto)
[0:00] 100.00%  1 / 1 index files loaded
snapshot 617c28e6 of [/home/someuser/src/dir1 /home/someuser/src/dir2] at 2025-04-06 16:05:29.09377055 +0200 CEST by REMOVED filtered by []:
drwxrwxr-x  1000  1000      0 2025-04-06 16:05:27 /src
drwxrwxr-x  1000  1000      0 2025-04-06 16:05:27 /src/dir2
-rw-rw-r--  1000  1000     11 2025-04-06 16:05:27 /src/dir2/dir2_file1.txt

If I instead take include_file.txt with the following content:

src/

And then the corresponding call:

restic -r ./repo --insecure-no-password backup --files-from include_file.txt --exclude-file exclude_file.txt 
restic -r ./repo --insecure-no-password snapshots

yields:

ID        Time                 Host      Tags        Paths                            Size
------------------------------------------------------------------------------------------------
617c28e6  2025-04-06 16:05:29  somehost              /home/someuser/src/dir1          11 B
                                                     /home/someuser/src/dir2

17bff745  2025-04-06 16:05:30  somehost              /home/someuser/src               11 B
-------------------------------------------------------------------------------------------------

listing again:

drwxrwxr-x  1000  1000      0 2025-04-06 16:05:27 /src
drwxrwxr-x  1000  1000      0 2025-04-06 16:05:27 /src/dir2
-rw-rw-r--  1000  1000     11 2025-04-06 16:05:27 /src/dir2/dir2_file1.txt

So in principle, the same files are backed up, however in the first case, the listing of the snapshot is misleading.

Is this intented behaviour? I think I would prefer that a directory that is matching the excludes and thus is empty, should not be included in the snapshots overview.

Thanks!
Jochen

PS: If someone wants to play with this, the following script creates the environment and reproduces the issue:

#!/bin/sh -x
mkdir repo
mkdir src
mkdir src/dir1
mkdir src/dir2
echo "dir1_file1" > src/dir1/dir1_file1.txt
echo "dir2_file1" > src/dir2/dir2_file1.txt
echo "src/*" > include_file_wild.txt
echo "src/dir1" > exclude_file.txt
restic -r ./repo --insecure-no-password init
restic -r ./repo --insecure-no-password backup --files-from include_file_wild.txt --exclude-file exclude_file.txt 
restic -r ./repo --insecure-no-password snapshots
restic -r ./repo --insecure-no-password ls -long latest

echo "src/" > include_file.txt
restic -r ./repo --insecure-no-password backup --files-from include_file.txt --exclude-file exclude_file.txt 
restic -r ./repo --insecure-no-password snapshots
restic -r ./repo --insecure-no-password ls -long latest

Personally, that behavior is what I would have expected: the Paths are what is included (on the command line or with a --files-from file) and are not affected by the exclusions. Usually exclusions are specific, are files and subfolders. Some files here and there might be excluded from the backup and that can’t be reflected in the Paths in a sensible way. In your rare case, where a whole path in Paths is excluded, you could indicate that by removing it from Paths as you suggest. But IMHO that makes things unnecessarily complicated as it interleaves backup paths and exclusions. That’s just my personal point of view.