diff --git a/CHANGELOG.md b/CHANGELOG.md index b96f654..0e1b491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed +- Building against a libgit2 compiled with `GIT_EXPERIMENTAL_SHA256` is + now rejected at compile time with an actionable `#error` message via + the new `src/git_compat.hpp` (the single include point for git2 + headers, probing `GIT_OID_SHA256_HEXSIZE`): the experimental build's + 3-argument `git_oid_fromstr` and larger `git_oid` ABI are unsupported + in v0.1, and the previous failure was a bare "too few arguments" at + two call sites with no guidance. +- The system libgit2 minimum is now 1.7 (was 1.4, a declaration that did + not match reality): `git_repository_oid_type` and the `git_oid_t` enum + first appeared in libgit2 v1.7.0, so 1.4–1.6 system libraries failed + to compile. The vendored path pins v1.9.7 and is unaffected. +- RFC 0000 §1.3 (non-goals) now records SHA-256 object-format + repositories as out of scope for v0.1 — they require an experimental + libgit2 build, which the compile-time guard rejects until properly + supported. + ## [0.0.4] - 2026-09-26 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index f178ad1..71fe0d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,14 +25,17 @@ find_package(PkgConfig REQUIRED) pkg_check_modules(FUSE3 REQUIRED IMPORTED_TARGET fuse3>=3.10) find_package(Threads REQUIRED) -# System libgit2 (>= 1.4) by default; a pinned vendored copy (v1.9.7, +# System libgit2 (>= 1.7) by default; a pinned vendored copy (v1.9.7, # static, network backends disabled) is used when the system version is # too old — e.g. Ubuntu 22.04 ships libgit2 1.1. The vendored path also # produces release binaries with one less runtime dependency. option(GITMOUNT_USE_SYSTEM_LIBGIT2 "Link the system libgit2 (pkg-config); OFF builds a pinned vendored copy" ON) if(GITMOUNT_USE_SYSTEM_LIBGIT2) - pkg_check_modules(LIBGIT2 REQUIRED IMPORTED_TARGET libgit2>=1.4) + # git_repository_oid_type (gitrepo.cpp) and the git_oid_t enum (rawobj) + # first appeared in libgit2 v1.7.0 — older system libraries fail to + # compile. The vendored path pins v1.9.7 and is unaffected. + pkg_check_modules(LIBGIT2 REQUIRED IMPORTED_TARGET libgit2>=1.7) set(GITMOUNT_LIBGIT2_TARGET PkgConfig::LIBGIT2) else() include(FetchContent) diff --git a/rfc/0000-gitmount.md b/rfc/0000-gitmount.md index 2d70fbe..c2386cd 100644 --- a/rfc/0000-gitmount.md +++ b/rfc/0000-gitmount.md @@ -101,6 +101,8 @@ commit 解析为一个 commit 对象, - 稀疏检出、部分克隆(partial clone)。 - macOS(osxfuse/macFUSE)与 BSD 移植(接口层预留抽象)。 - 工作区(index)视图、stash 视图。 +- SHA-256 对象格式仓库(v0.1;需 libgit2 实验构建,编译期守卫先行 + 拒绝)。 ## 2. 术语与要求用语 diff --git a/src/errmap.cpp b/src/errmap.cpp index 21b6163..3da8e8e 100644 --- a/src/errmap.cpp +++ b/src/errmap.cpp @@ -5,7 +5,7 @@ #include -#include +#include "git_compat.hpp" namespace gitmount { diff --git a/src/git_compat.hpp b/src/git_compat.hpp new file mode 100644 index 0000000..7f97a3b --- /dev/null +++ b/src/git_compat.hpp @@ -0,0 +1,17 @@ +// gitmount — read-only git-to-FUSE filesystem (RFC 0000). +// SPDX-FileCopyrightText: 2026 The gitmount authors +// SPDX-License-Identifier: GPL-3.0-or-later +// +// Unified libgit2 include point (issue #8): every translation unit that +// needs git2 headers includes this file instead of directly, so +// the compile-time guard below is enforced for the whole program — not +// just the TUs that happen to include themselves. +#pragma once + +#include + +#ifdef GIT_OID_SHA256_HEXSIZE +// 该宏仅在 libgit2 以 GIT_EXPERIMENTAL_SHA256 构建的头文件分支中定义。 +#error \ + "gitmount v0.1 does not support libgit2 built with GIT_EXPERIMENTAL_SHA256: the git_oid API/ABI differs (3-argument git_oid_fromstr, larger git_oid). See RFC 0000 §1.3." +#endif diff --git a/src/gitrepo.hpp b/src/gitrepo.hpp index 02bbd21..07bff87 100644 --- a/src/gitrepo.hpp +++ b/src/gitrepo.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include "git_compat.hpp" namespace gitmount { diff --git a/src/rawobj.hpp b/src/rawobj.hpp index 7d34a26..2e3a1c2 100644 --- a/src/rawobj.hpp +++ b/src/rawobj.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include "git_compat.hpp" namespace gitmount::rawobj { diff --git a/tests/unit/test_errmap.cpp b/tests/unit/test_errmap.cpp index b0ae296..96ab711 100644 --- a/tests/unit/test_errmap.cpp +++ b/tests/unit/test_errmap.cpp @@ -7,7 +7,7 @@ #include "errmap.hpp" -#include +#include "git_compat.hpp" using gitmount::git_to_errno;