Skip to content

Commit 0b65571

Browse files
Docs: Clarify how reference and compared directories are processed (#83)
1 parent 7db7243 commit 0b65571

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ the files, so it is not able to report which values are different.
3636

3737
### Compare two directories
3838

39-
If one wants to compare two directories with the following structures:
39+
Let's compare two directories with the following structures:
4040

4141
```bash
4242
└── reference_dir
@@ -55,6 +55,9 @@ If one wants to compare two directories with the following structures:
5555
└── file_1.c
5656
```
5757

58+
The `reference` directory contains all the files that should be checked in the `compared` directory,
59+
which means that extraneous files in the `compared` directory are just ignored.
60+
5861
These two directories can be compared with the following code:
5962

6063
```python
@@ -63,7 +66,15 @@ import dir_content_diff
6366
dir_content_diff.compare_trees("reference_dir", "compared_dir")
6467
```
6568

66-
This code will return an empty dictionary because no difference was detected.
69+
> [!WARNING]
70+
> The order of the parameters is important: the first path is considered as the `reference`
71+
> directory while the second one is the `compared` directory. Inverting the parameters may return
72+
> a different result (in this example it would return that the file `sub_file_3.b` is missing).
73+
74+
If all the files are identical, this code will return an empty dictionary because no difference
75+
was detected. As mentioned previously, this is because `dir-content-diff` is only looking for files
76+
in the compared directory that are also present in the reference directory, so the file
77+
`sub_file_3.b` is just ignored in this case.
6778

6879
If ``reference_dir/file_1.c`` is the following JSON-like file:
6980

0 commit comments

Comments
 (0)