about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-11-20 17:55:53 +0100
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-11-22 18:51:00 +0100
commit827232d6dd2b7787749afdfef614fbea8d88ebe9 (patch)
treef8f14186e02249a65b37148eb07d8b40cbb6cd5f /lib
parent1cc2c2f13d7a548759a55f710fd0222da14c5403 (diff)
lib.fileset: Document decision for strict existence checks
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fileset/README.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/fileset/README.md b/lib/fileset/README.md
index f44df6fffecaa..93e0199c32a4b 100644
--- a/lib/fileset/README.md
+++ b/lib/fileset/README.md
@@ -252,3 +252,16 @@ The `fileFilter` function takes a path, and not a file set, as its second argume
     - (+) That can change depending on which files are included, so if it's used for `fileFilter`
       it would change the `subpath`/`components` value depending on which files are included.
 - (+) If necessary, this restriction can be relaxed later, the opposite wouldn't be possible
+
+### Strict path existence checking
+
+Coercing paths that don't exist to file sets always gives an error.
+
+- (-) Sometimes you want to remove a file that may not always exist using `difference ./. ./does-not-exist`,
+  but this does not work because coercion of `./does-not-exist` fails,
+  even though its existence would have no influence on the result.
+  - (+) This is dangerous, because you wouldn't be protected against typos anymore.
+    E.g. when trying to prevent `./secret` from being imported, a typo like `difference ./. ./sercet` would import it regardless.
+  - (+) `difference ./. (maybeMissing ./does-not-exist)` can be used to do this more explicitly.
+  - (+) `difference ./. (difference ./foo ./foo/bar)` should report an error when `./foo/bar` does not exist ("double negation"). Unfortunately, the current internal representation does not lend itself to a behavior where both `difference x ./does-not-exists` and double negation are handled and checked correctly.
+    This could be fixed, but would require significant changes to the internal representation that are not worth the effort and the risk of introducing implicit behavior.