Skip to content

Commit 23e8812

Browse files
authored
Merge pull request #4350 from Cyan4973/patchapply
add --patch-apply command
2 parents 12ea5f6 + eb168a0 commit 23e8812

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

programs/zstdcli.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ static void usageAdvanced(const char* programName)
230230
#endif
231231
DISPLAYOUT(" --adapt Dynamically adapt compression level to I/O conditions.\n");
232232
DISPLAYOUT(" --long[=#] Enable long distance matching with window log #. [Default: %u]\n", g_defaultMaxWindowLog);
233-
DISPLAYOUT(" --patch-from=REF Use REF as the reference point for Zstandard's diff engine. \n\n");
233+
DISPLAYOUT(" --patch-from=REF Use REF as the reference point for Zstandard's diff engine. \n");
234+
DISPLAYOUT(" --patch-apply Equivalent for `-d --patch-from` \n\n");
234235
# ifdef ZSTD_MULTITHREAD
235236
DISPLAYOUT(" -T# Spawn # compression threads. [Default: 1; pass 0 for core count.]\n");
236237
DISPLAYOUT(" --single-thread Share a single thread for I/O and compression (slightly different than `-T1`).\n");
@@ -1124,6 +1125,7 @@ int main(int argCount, const char* argv[])
11241125
if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; }
11251126
#endif
11261127
if (longCommandWArg(&argument, "--patch-from")) { NEXT_FIELD(patchFromDictFileName); ultra = 1; continue; }
1128+
if (longCommandWArg(&argument, "--patch-apply")) { operation=zom_decompress; NEXT_FIELD(patchFromDictFileName); memLimit= 1U << ZSTD_WINDOWLOG_MAX; continue; }
11271129
if (longCommandWArg(&argument, "--long")) {
11281130
unsigned ldmWindowLog = 0;
11291131
ldmFlag = 1;

tests/playTests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,11 +1777,15 @@ datagen -g1000 -P10 > tmp_patch
17771777
zstd --patch-from=tmp_dict tmp_patch -o tmp_patch_diff
17781778
zstd -d --patch-from=tmp_dict tmp_patch_diff -o tmp_patch_recon
17791779
$DIFF -s tmp_patch_recon tmp_patch
1780+
zstd -f --patch-apply=tmp_dict tmp_patch_diff -o tmp_patch_recon
1781+
$DIFF -s tmp_patch_recon tmp_patch
17801782

17811783
println "\n===> alternate syntax: patch-from origin"
17821784
zstd -f --patch-from tmp_dict tmp_patch -o tmp_patch_diff
17831785
zstd -df --patch-from tmp_dict tmp_patch_diff -o tmp_patch_recon
17841786
$DIFF -s tmp_patch_recon tmp_patch
1787+
zstd -f --patch-apply tmp_dict tmp_patch_diff -o tmp_patch_recon
1788+
$DIFF -s tmp_patch_recon tmp_patch
17851789
rm -rf tmp_*
17861790

17871791
println "\n===> patch-from recursive tests"

0 commit comments

Comments
 (0)