Skip to content

Commit

Permalink
Merge pull request #3963 from felixhandte/also-handle-hidden-files-ou…
Browse files Browse the repository at this point in the history
…tput-dir-mirror

Remove Erroneous Exclusion of Hidden Files and Folders in `--output-dir-mirror`
  • Loading branch information
felixhandte authored Mar 14, 2024
2 parents 216099a + 86b8e39 commit 490163a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
3 changes: 0 additions & 3 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,9 +1135,6 @@ static char* mallocAndJoin2Dir(const char *dir1, const char *dir2)
memcpy(outDirBuffer, dir1, dir1Size);
outDirBuffer[dir1Size] = '\0';

if (dir2[0] == '.')
return outDirBuffer;

buffer = outDirBuffer + dir1Size;
if (dir1Size > 0 && *(buffer - 1) != PATH_SEP) {
*buffer = PATH_SEP;
Expand Down
49 changes: 49 additions & 0 deletions tests/cli-tests/file-handling/directory-mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
set -e

# setup
mkdir -p src/.hidden src/dir
mkdir mid dst

echo "file1" > src/file1
echo "file2" > src/.file2
echo "file3" > src/.hidden/.file3
echo "file4" > src/dir/.file4

# relative paths
zstd -q -r --output-dir-mirror mid/ src/
zstd -q -d -r --output-dir-mirror dst/ mid/src/

diff --brief --recursive --new-file src/ dst/mid/src/

# reset
rm -rf mid dst
mkdir mid dst

# from inside the directory
(cd src; zstd -q -r --output-dir-mirror ../mid/ ./)
(cd mid; zstd -q -d -r --output-dir-mirror ../dst/ ./)

diff --brief --recursive --new-file src/ dst/

# reset
rm -rf mid dst
mkdir mid dst

# absolute paths
export BASE_PATH="$(pwd)"

zstd -q -r --output-dir-mirror mid/ "${BASE_PATH}/src/"
zstd -q -d -r --output-dir-mirror dst/ "${BASE_PATH}/mid/${BASE_PATH}/src/"

diff --brief --recursive --new-file src/ "dst/${BASE_PATH}/mid/${BASE_PATH}/src/"

# reset
rm -rf mid dst
mkdir mid dst

# dots
zstd -q -r --output-dir-mirror mid/ ./src/./
zstd -q -d -r --output-dir-mirror dst/ ./mid/./src/./

diff --brief --recursive --new-file src/ dst/mid/src/
Empty file.
Empty file.

0 comments on commit 490163a

Please sign in to comment.