Skip to content

Commit e2d2052

Browse files
authored
Merge pull request #367 from sisong/dev
cmdline add option "-info diffFile"
2 parents b41e117 + 3a92366 commit e2d2052

File tree

17 files changed

+471
-303
lines changed

17 files changed

+471
-303
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
full changelog at: https://github.com/sisong/HDiffPatch/commits
44

5+
## [v4.6.9](https://github.com/sisong/HDiffPatch/tree/v4.6.9) - 2023-12-01
6+
### Added
7+
* cmdline hdiffz & hpatchz support option "-info diffFile", print infos of diffFile;
8+
59
## [v4.6.8](https://github.com/sisong/HDiffPatch/tree/v4.6.8) - 2023-11-02
610
### Changed
711
* hdiffz.exe&hpatchz.exe support long path on Windows OS;

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ else
334334
endif
335335
ifeq ($(MINS),0)
336336
else
337-
DIFF_LINK += -Wl,--gc-sections,--as-needed
337+
DIFF_LINK += -s -Wl,--gc-sections,--as-needed
338338
endif
339339
ifeq ($(CL),1)
340340
CXX := clang++

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [HDiffPatch]
2-
[![release](https://img.shields.io/badge/release-v4.6.8-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
2+
[![release](https://img.shields.io/badge/release-v4.6.9-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
33
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE)
44
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls)
55
[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues)
@@ -8,7 +8,7 @@
88
[![Build status](https://ci.appveyor.com/api/projects/status/t9ow8dft8lt898cv/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/hdiffpatch/branch/master)
99
english | [中文版](README_cn.md)
1010

11-
[HDiffPatch] is a C\C++ library and command-line tools for **diff** & **patch** between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch.
11+
[HDiffPatch] is a C\C++ library and command-line tools for **diff** & **patch** between binary files or directories(folder); cross-platform; fast running; create small delta/differential; support large files and limit memory requires when diff & patch.
1212

1313
[HDiffPatch] defines its own patch file format, this lib is also compatible with the [bsdiff4] patch file format and partially compatible with the [open-vcdiff] and [xdelta3] patch file format [VCDIFF(RFC 3284)].
1414

@@ -88,12 +88,13 @@ diff usage: **hdiffz** [options] **oldPath newPath outDiffFile**
8888
compress usage: **hdiffz** [-c-...] **"" newPath outDiffFile**
8989
test usage: **hdiffz** -t **oldPath newPath testDiffFile**
9090
resave usage: **hdiffz** [-c-...] **diffFile outDiffFile**
91+
print info: **hdiffz** -info **diffFile**
9192
get manifest: **hdiffz** [-g#...] [-C-checksumType] **inputPath -M#outManifestTxtFile**
9293
manifest diff: **hdiffz** [options] **-M-old#oldManifestFile -M-new#newManifestFile oldPath newPath outDiffFile**
9394
```
9495
oldPath newPath inputPath can be file or directory(folder),
9596
oldPath can empty, and input parameter ""
96-
memory options:
97+
options:
9798
-m[-matchScore]
9899
DEFAULT; all file load into Memory; best diffFileSize;
99100
requires (newFileSize+ oldFileSize*5(or *9 when oldFileSize>=2GB))+O(1)
@@ -103,7 +104,6 @@ memory options:
103104
all file load as Stream; fast;
104105
requires O(oldFileSize*16/matchBlockSize+matchBlockSize*5*parallelThreadNumber)bytes of memory;
105106
matchBlockSize>=4, DEFAULT -s-64, recommended 16,32,48,1k,64k,1m etc...
106-
special options:
107107
-block-fastMatchBlockSize
108108
must run with -m;
109109
set block match befor slow byte-by-byte match, DEFAULT -block-4k;
@@ -159,7 +159,7 @@ special options:
159159
support run by multi-thread parallel, fast!
160160
WARNING: code not compatible with it compressed by -c-lzma!
161161
-c-zstd[-{0..22}[-dictBits]] DEFAULT level 20
162-
dictBits can 10--31, DEFAULT 23.
162+
dictBits can 10--30, DEFAULT 23.
163163
support run by multi-thread parallel, fast!
164164
-C-checksumType
165165
set outDiffFile Checksum type for directory diff, DEFAULT -C-fadler64;
@@ -202,19 +202,23 @@ special options:
202202
if used -f and write path is exist directory, will always return error.
203203
--patch
204204
swap to hpatchz mode.
205-
-v output Version info.
205+
-info
206+
print infos of diffFile.
207+
-v print Version info.
206208
-h (or -?)
207-
output usage info.
209+
print usage info.
208210
```
209211

210212
## **patch** command line usage:
211213
patch usage: **hpatchz** [options] **oldPath diffFile outNewPath**
212214
uncompress usage: **hpatchz** [options] **"" diffFile outNewPath**
215+
print info: **hpatchz** -info **diffFile**
213216
create SFX: **hpatchz** [-X-exe#selfExecuteFile] **diffFile -X#outSelfExtractArchive**
214217
run SFX: **selfExtractArchive** [options] **oldPath -X outNewPath**
215218
extract SFX: **selfExtractArchive** (same as: selfExtractArchive -f "" -X "./")
216219
```
217-
memory options:
220+
if oldPath is empty input parameter ""
221+
options:
218222
-s[-cacheSize]
219223
DEFAULT -s-4m; oldPath loaded as Stream;
220224
cacheSize can like 262144 or 256k or 512m or 2g etc....
@@ -233,7 +237,6 @@ memory options:
233237
(oldFileSize + 3*decompress buffer size)+O(1) bytes of memory.
234238
if diffFile is VCDIFF(created by hdiffz -VCD,xdelta3,open-vcdiff), then requires
235239
(sourceWindowSize+targetWindowSize + 3*decompress buffer size)+O(1) bytes of memory.
236-
special options:
237240
-C-checksumSets
238241
set Checksum data for directory patch, DEFAULT -C-new-copy;
239242
checksumSets support (can choose multiple):
@@ -259,14 +262,16 @@ special options:
259262
if patch output file, will always return error;
260263
if patch output directory, will overwrite, but not delete
261264
needless existing files in directory.
262-
-v output Version info.
265+
-info
266+
print infos of diffFile.
267+
-v print Version info.
263268
-h (or -?)
264-
output usage info.
269+
print usage info.
265270
```
266271

267272
---
268273
## library API usage:
269-
all **diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDiffPatch/HPatch/patch.h`
274+
**diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDiffPatch/HPatch/patch.h`
270275
**dir_diff()** & **dir patch** in: `dirDiffPatch/dir_diff/dir_diff.h` & `dirDiffPatch/dir_patch/dir_patch.h`
271276
### manual:
272277
* **create diff**(in newData,in oldData,out diffData);
@@ -320,7 +325,7 @@ all **diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDif
320325

321326
---
322327
## [HDiffPatch] vs [bsdiff4] & [xdelta3]:
323-
case list([download from OneDrive](https://1drv.ms/u/s!Aj8ygMPeifoQgUIZxYac5_uflNoN)):
328+
case list([download from OneDrive](https://1drv.ms/u/s!Aj8ygMPeifoQgULlawtabR9lhrQ8)):
324329
| |newFile <-- oldFile|newSize|oldSize|
325330
|----:|:----|----:|----:|
326331
|1|7-Zip_22.01.win.tar <-- 7-Zip_21.07.win.tar|5908992|5748224|

README_cn.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [HDiffPatch]
2-
[![release](https://img.shields.io/badge/release-v4.6.8-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
2+
[![release](https://img.shields.io/badge/release-v4.6.9-blue.svg)](https://github.com/sisong/HDiffPatch/releases)
33
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE)
44
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls)
55
[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues)
@@ -8,17 +8,17 @@
88
[![Build status](https://ci.appveyor.com/api/projects/status/t9ow8dft8lt898cv/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/hdiffpatch/branch/master)
99
中文版 | [english](README.md)
1010

11-
[HDiffPatch] 是一个C\C++库和命令行工具,用于在二进制文件或文件夹之间执行**diff**(创建补丁)**patch**(打补丁);跨平台、运行快、创建的补丁小、支持巨大的文件并且可控制diff和patch时的内存占用量
11+
[HDiffPatch] 是一个C\C++库和命令行工具,用于在二进制文件或文件夹之间执行 **diff**(创建补丁)**patch**(打补丁);跨平台、运行速度快、创建的补丁小、支持巨大的文件并且diff和patch时都可以控制内存占用量
1212

1313
[HDiffPatch] 定义了自己的补丁包格式,同时这个库也完全兼容了 [bsdiff4] 的补丁包格式,并部分兼容 [open-vcdiff][xdelta3] 的补丁包格式 [VCDIFF(RFC 3284)]
1414

15-
如果需要在嵌入式系统(MCU、NB-IoT)等设备上进行增量更新(OTA), 可以看看例子 [HPatchLite], +[tinyuz] 解压缩器可以在1KB内存的设备上运行!
15+
如果你需要在嵌入式系统(MCU、NB-IoT)等设备上进行增量更新(OTA), 可以看看例子 [HPatchLite], +[tinyuz] 解压缩器可以在1KB内存的设备上运行!
1616

17-
需要更新你自己的安卓apk? 需要对Jar或Zip文件执行 diff & patch ? 可以试试 [ApkDiffPatch], 可以创建更小的补丁! 注意: *ApkDiffPath 不能被安卓应用商店作为增量更新使用,因为该算法要求在diff前对apk文件进行重新签名。*
17+
需要更新你自己的安卓apk? 需要对Jar或Zip文件执行 diff patch ? 可以试试 [ApkDiffPatch], 可以创建更小的补丁! 注意: *ApkDiffPath 不能被安卓应用商店作为增量更新所用,因为该算法要求在diff前对apk文件进行重新签名。*
1818

1919
[sfpatcher] 不要求对apk文件进行重新签名 (类似 [archive-patcher]),是为安卓应用商店专门设计优化的算法,patch速度是 archive-patcher 的xx倍,并且只需要O(1)内存。
2020

21-
如果你没有旧版本的数据(或者旧版本非常多或者被修改),因此不能提前创建好所有补丁包。那你可以看看使用同步算法来进行增量更新的例子 [hsynz] (类似 [zsync]),新版本只需要发布处理一次,然后旧版本数据的拥有者可以根据获得的新版本的信息自己执行diff和patch。hsynz 支持 zstd 压缩算法并且比 zsync 速度更快。
21+
如果你没有旧版本的数据(或者旧版本非常多或者被修改),因此不能提前创建好补丁包。那你可以看看使用同步算法来进行增量更新的例子 [hsynz] (类似 [zsync]),新版本只需要发布处理一次,然后旧版本数据的拥有者可以根据获得的新版本的信息自己执行diff和patch。hsynz 支持 zstd 压缩算法并且比 zsync 速度更快。
2222

2323
注意: *本库不处理文件元数据,如文件最后写入时间、权限、链接文件等。对于这个库,文件就像一个字节流;如果需要您可以扩展此库或使用其他工具。*
2424

@@ -88,12 +88,13 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
8888
压缩一个文件或文件夹: **hdiffz** [-c-...] **"" newPath outDiffFile**
8989
测试补丁是否正确: **hdiffz** -t **oldPath newPath testDiffFile**
9090
补丁使用新的压缩插件另存: **hdiffz** [-c-...] **diffFile outDiffFile**
91+
显示补丁的信息: **hdiffz** -info **diffFile**
9192
创建该版本的校验清单: **hdiffz** [-g#...] [-C-checksumType] **inputPath -M#outManifestTxtFile**
9293
校验输入数据后创建补丁: **hdiffz** [options] **-M-old#oldManifestFile -M-new#newManifestFile oldPath newPath outDiffFile**
9394
```
9495
oldPath、newPath、inputPath 可以是文件或文件夹,
9596
oldPath可以为空, 输入参数为 ""
96-
内存选项:
97+
选项:
9798
-m[-matchScore]
9899
默认选项; 所有文件都会被加载到内存; 一般生成的补丁文件比较小;
99100
需要的内存大小:(新版本文件大小+ 旧版本文件大小*5(或*9 当旧版本文件大小>=2GB时))+O(1);
@@ -104,7 +105,6 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
104105
需要的内存大小: O(旧版本文件大小*16/matchBlockSize+matchBlockSize*5*parallelThreadNumber);
105106
匹配块大小matchBlockSize>=4, 默认为64, 推荐16,32,48,1k,64k,1m等;
106107
一般匹配块越大,内存占用越小,速度越快,但补丁包可能变大。
107-
其他选项:
108108
-block-fastMatchBlockSize
109109
必须和-m配合使用;
110110
在使用较慢的逐字节匹配之前使用基于块的快速匹配, 默认-block-4k;
@@ -157,7 +157,7 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
157157
支持多线程并行压缩,很快。
158158
警告: lzma和lzma2是不同的压缩编码格式。
159159
-c-zstd[-{0..22}[-dictBits]] 默认级别 20
160-
压缩字典比特数dictBits 可以为10到31, 默认为24
160+
压缩字典比特数dictBits 可以为10到30, 默认为23
161161
支持多线程并行压缩,很快。
162162
-C-checksumType
163163
为文件夹间diff设置数据校验算法, 默认为fadler64;
@@ -198,6 +198,8 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
198198
如果设置了-f,但路径已经存在并且是一个文件夹, 那么会始终返回错误。
199199
--patch
200200
切换到 hpatchz 模式; 可以支持hpatchz命令行的相关参数和功能。
201+
-info
202+
显示补丁的信息。
201203
-v 输出程序版本信息。
202204
-h 或 -?
203205
输出命令行帮助信息 (该说明)。
@@ -206,13 +208,15 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
206208
## patch 命令行用法和参数说明:
207209
打补丁: **hpatchz** [options] **oldPath diffFile outNewPath**
208210
解压缩一个文件或文件夹: **hpatchz** [options] **"" diffFile outNewPath**
211+
显示补丁的信息: **hpatchz** -info **diffFile**
209212
创建一个自释放包: **hpatchz** [-X-exe#selfExecuteFile] **diffFile -X#outSelfExtractArchive**
210213
(将目标平台的hpatchz可执行文件和补丁包文件合并成一个可执行文件, 称作自释放包SFX)
211214
执行一个自释放包: **selfExtractArchive** [options] **oldPath -X outNewPath**
212215
(利用自释放包来打补丁,将包中自带的补丁数据应用到oldPath上, 合成outNewPath)
213216
执行一个自解压包: **selfExtractArchive** (等价于: selfExtractArchive -f "" -X "./")
214217
```
215-
内存选项:
218+
oldPath可以为空, 输入参数为 ""
219+
选项:
216220
-s[-cacheSize]
217221
默认选项,并且默认设置为-s-4m; oldPath所有文件被当作文件流来加载;
218222
cacheSize可以设置为262144 或 256k, 512m, 2g等
@@ -231,7 +235,6 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
231235
那需要的内存大小: (oldFileSize + 3*解压缩缓冲区);
232236
如果diffFile是VCDIFF格式补丁文件(用hdiffz -VCD、xdelta3、open-vcdiff所创建)
233237
那需要的内存大小: (源窗口大小+目标窗口大小 + 3*解压缩缓冲区);
234-
其他选项:
235238
-C-checksumSets
236239
为文件夹patch设置校验方式, 默认设置为 -C-new-copy;
237240
校验设置支持(可以多选):
@@ -255,14 +258,16 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
255258
如果设置了-f,但outNewPath已经存在并且是一个文件夹:
256259
如果patch输出一个文件, 那么会始终返回错误;
257260
如果patch输出一个文件夹, 那么会执行写覆盖, 但不会删除文件夹中已经存在的无关文件。
261+
-info
262+
显示补丁的信息。
258263
-v 输出程序版本信息。
259264
-h 或 -?
260265
输出命令行帮助信息 (该说明)。
261266
```
262267

263268
---
264269
## 库 API 使用说明:
265-
所有 **diff****patch** 函数在文件: `libHDiffPatch/HDiff/diff.h` & `libHDiffPatch/HPatch/patch.h`
270+
**diff****patch** 函数在文件: `libHDiffPatch/HDiff/diff.h` & `libHDiffPatch/HPatch/patch.h`
266271
**dir_diff()****dir patch** 在: `dirDiffPatch/dir_diff/dir_diff.h` & `dirDiffPatch/dir_patch/dir_patch.h`
267272
### 使用方式:
268273
* **create diff**(in newData,in oldData,out diffData);
@@ -316,7 +321,7 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
316321

317322
---
318323
## [HDiffPatch] vs [bsdiff4] & [xdelta3]:
319-
测试例子([从 OneDrive 下载](https://1drv.ms/u/s!Aj8ygMPeifoQgUIZxYac5_uflNoN)):
324+
测试用例([从 OneDrive 下载](https://1drv.ms/u/s!Aj8ygMPeifoQgULlawtabR9lhrQ8)):
320325
| |newFile <-- oldFile|newSize|oldSize|
321326
|----:|:----|----:|----:|
322327
|1|7-Zip_22.01.win.tar <-- 7-Zip_21.07.win.tar|5908992|5748224|
@@ -343,7 +348,7 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2
343348

344349
**测试 PC**: Windows11, CPU R9-7945HX, SSD PCIe4.0x4 4T, DDR5 5200MHz 32Gx2
345350
**参与测试的程序和版本**: HDiffPatch4.6.3, hsynz 0.9.3, BsDiff4.3, xdelta3.1, zstd1.5.2
346-
**参与测试程序的参数**:
351+
**参与测试的程序的参数**:
347352
**zstd --patch-from** diff with `--ultra -21 --long=24 -f --patch-from={old} {new} -o {pat}`
348353
zstd patch with `-d -f --memory=2047MB --patch-from={old} {pat} -o {new}`
349354
**xdelta3** diff with `-S lzma -e -9 -n -f -s {old} {new} {pat}`

0 commit comments

Comments
 (0)