Skip to content

Commit 63e6aed

Browse files
committed
update to v1.9.0
Libgit advises using the CollisionDetect option for SHA1 support, which provides some extra security and matches Git's implementation. So SHA1 uses CollisionDetect by default now. SHA256 still uses the respective backend's implementation. I look forward to v2.0.0 which should simplify the build script a lot.
1 parent 1e564a5 commit 63e6aed

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2024 Julian Del Signore
1+
Copyright 2025 Julian Del Signore
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

build.zig

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn build(b: *std.Build) !void {
6060
.GIT_HTTPS = 1,
6161
.GIT_WINHTTP = 1,
6262

63-
.GIT_SHA1_WIN32 = 1,
63+
.GIT_SHA1_COLLISIONDETECT = 1,
6464
.GIT_SHA256_WIN32 = 1,
6565

6666
.GIT_IO_WSAPOLL = 1,
@@ -79,15 +79,16 @@ pub fn build(b: *std.Build) !void {
7979
features.addValues(.{
8080
.GIT_HTTPS = 1,
8181
.GIT_OPENSSL = 1,
82-
.GIT_SHA1_OPENSSL = 1,
82+
83+
.GIT_SHA1_COLLISIONDETECT = 1,
8384
.GIT_SHA256_OPENSSL = 1,
8485

8586
.GIT_USE_FUTIMENS = 1,
8687
.GIT_IO_POLL = 1,
8788
.GIT_IO_SELECT = 1,
8889
});
8990
} else {
90-
// mbedTLS backend
91+
// MbedTLS backend
9192
tls_dep = b.lazyDependency("mbedtls", .{
9293
.target = target,
9394
.optimize = optimize,
@@ -96,7 +97,8 @@ pub fn build(b: *std.Build) !void {
9697
features.addValues(.{
9798
.GIT_HTTPS = 1,
9899
.GIT_MBEDTLS = 1,
99-
.GIT_SHA1_MBEDTLS = 1,
100+
101+
.GIT_SHA1_COLLISIONDETECT = 1,
100102
.GIT_SHA256_MBEDTLS = 1,
101103

102104
.GIT_USE_FUTIMENS = 1,
@@ -161,6 +163,17 @@ pub fn build(b: *std.Build) !void {
161163
});
162164
}
163165

166+
// SHA1 collisiondetect
167+
lib.addCSourceFiles(.{
168+
.root = libgit_root,
169+
.files = &util_sha1dc_sources,
170+
.flags = &(flags ++ .{
171+
"-DSHA1DC_NO_STANDARD_INCLUDES",
172+
"-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"git2_util.h\"",
173+
"-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git2_util.h\"",
174+
}),
175+
});
176+
164177
if (b.option(bool, "enable-ssh", "Enable SSH support") orelse false) {
165178
lib.linkSystemLibrary("ssh2");
166179
features.addValues(.{
@@ -204,12 +217,11 @@ pub fn build(b: *std.Build) !void {
204217
.PCRE_PARENS_NEST_LIMIT = 250,
205218
.PCRE_MATCH_LIMIT = 10000000,
206219
.PCRE_MATCH_LIMIT_RECURSION = "MATCH_LIMIT",
207-
.NEWLINE = 10, // LF
220+
.NEWLINE = '\n',
208221
.NO_RECURSE = 1,
209222
.PCRE_POSIX_MALLOC_THRESHOLD = 10,
210223
.BSR_ANYCRLF = 0,
211-
// "-DMAX_NAME_SIZE=32",
212-
// "-DMAX_NAME_COUNT=10000",
224+
.PCREGREP_BUFSIZE = null,
213225
},
214226
));
215227
pcre.addIncludePath(libgit_src.path("deps/pcre"));
@@ -257,10 +269,6 @@ pub fn build(b: *std.Build) !void {
257269
{
258270
// Bundled xdiff dependency relies on libgit2 headers & utils, so we
259271
// just add the source files directly instead of making a static lib step.
260-
261-
// (Note from CMakeLists file:
262-
// the xdiff dependency is not (yet) warning-free, disable warnings
263-
// as errors for the xdiff sources until we've sorted them out)
264272
lib.addCSourceFiles(.{
265273
.root = libgit_root,
266274
.files = &xdiff_sources,
@@ -317,7 +325,7 @@ pub fn build(b: *std.Build) !void {
317325
// .flags = &.{"-std=c90"},
318326
});
319327

320-
// independant install step so you can easily access the binary
328+
// independent install step so you can easily access the binary
321329
const cli_install = b.addInstallArtifact(cli, .{});
322330
const cli_run = b.addRunArtifact(cli);
323331
if (b.args) |args| {
@@ -437,9 +445,9 @@ const libgit_sources = [_][]const u8{
437445
"src/libgit2/graph.c",
438446
"src/libgit2/hashsig.c",
439447
"src/libgit2/ident.c",
440-
"src/libgit2/idxmap.c",
441448
"src/libgit2/ignore.c",
442449
"src/libgit2/index.c",
450+
"src/libgit2/index_map.c",
443451
"src/libgit2/indexer.c",
444452
"src/libgit2/iterator.c",
445453
"src/libgit2/libgit2.c",
@@ -457,10 +465,8 @@ const libgit_sources = [_][]const u8{
457465
"src/libgit2/odb_loose.c",
458466
"src/libgit2/odb_mempack.c",
459467
"src/libgit2/odb_pack.c",
460-
"src/libgit2/offmap.c",
461468
"src/libgit2/oid.c",
462469
"src/libgit2/oidarray.c",
463-
"src/libgit2/oidmap.c",
464470
"src/libgit2/pack-objects.c",
465471
"src/libgit2/pack.c",
466472
"src/libgit2/parse.c",
@@ -530,6 +536,7 @@ const libgit_sources = [_][]const u8{
530536

531537
const util_sources = [_][]const u8{
532538
"src/util/alloc.c",
539+
"src/util/allocators/debugalloc.c",
533540
"src/util/allocators/failalloc.c",
534541
"src/util/allocators/stdalloc.c",
535542
"src/util/allocators/win32_leakcheck.c",
@@ -549,7 +556,6 @@ const util_sources = [_][]const u8{
549556
"src/util/sortedcache.c",
550557
"src/util/str.c",
551558
"src/util/strlist.c",
552-
"src/util/strmap.c",
553559
"src/util/thread.c",
554560
"src/util/tsort.c",
555561
"src/util/utf8.c",
@@ -583,6 +589,12 @@ const util_win32_sources = [_][]const u8{
583589
"src/util/hash/win32.c",
584590
};
585591

592+
const util_sha1dc_sources = [_][]const u8{
593+
"src/util/hash/collisiondetect.c",
594+
"src/util/hash/sha1dc/sha1.c",
595+
"src/util/hash/sha1dc/ubc_check.c",
596+
};
597+
586598
const llhttp_sources = [_][]const u8{
587599
"deps/llhttp/api.c",
588600
"deps/llhttp/http.c",
@@ -646,12 +658,14 @@ const ntlm_sources = [_][]const u8{
646658

647659
const cli_sources = [_][]const u8{
648660
"src/cli/cmd.c",
661+
"src/cli/cmd_blame.c",
649662
"src/cli/cmd_cat_file.c",
650663
"src/cli/cmd_clone.c",
651664
"src/cli/cmd_config.c",
652665
"src/cli/cmd_hash_object.c",
653666
"src/cli/cmd_help.c",
654667
"src/cli/cmd_index_pack.c",
668+
"src/cli/cmd_init.c",
655669
"src/cli/common.c",
656670
"src/cli/main.c",
657671
"src/cli/opt.c",

build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.{
22
.name = "libgit2",
3-
.version = "1.8.1",
3+
.version = "1.9.0",
44
.minimum_zig_version = "0.13.0",
55
.dependencies = .{
66
.libgit2 = .{
7-
.url = "https://github.com/libgit2/libgit2/archive/refs/tags/v1.8.1.tar.gz",
8-
.hash = "12208db692747f305b79ecfb3ac69e691d0b9584383ec4bcb0eb07b62b73de77b1cf",
7+
.url = "https://github.com/libgit2/libgit2/archive/refs/tags/v1.9.0.tar.gz",
8+
.hash = "1220c7c470d6933d22e96211e85a4d7bab5748bcda3ee5adbc10603b8b1803043987",
99
},
1010
.openssl = .{
1111
.url = "https://github.com/allyourcodebase/openssl/archive/refs/tags/3.3.1-1.tar.gz",

0 commit comments

Comments
 (0)